From c74875e75fd54d112b1facc54c8dcac9f9bc7ed7 Mon Sep 17 00:00:00 2001 From: islandbitcoin Date: Sat, 19 Nov 2022 18:11:57 -0600 Subject: [PATCH] refactored for x86_64 architecture --- .gitignore | 1 + Dockerfile | 8 ++++---- Makefile | 17 +++++++++++----- docker_entrypoint.sh | 2 +- manifest.yaml | 31 +++++++++--------------------- scripts/deps.ts | 2 +- scripts/embassy.ts | 2 ++ scripts/procedures/healthChecks.ts | 5 +++++ scripts/procedures/main.ts | 11 +++++++++++ scripts/procedures/migrations.ts | 2 +- 10 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 scripts/procedures/healthChecks.ts create mode 100644 scripts/procedures/main.ts diff --git a/.gitignore b/.gitignore index 74b9dd6..c2e894c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ image.tar scripts/*.js .DS_Store .vscode/ +docker-images/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 22e2329..0c6ab48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM recksato/robosats-client -RUN apt-get update && apt-get install wget curl sudo bash tini -y \ - && wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_arm.tar.gz -O - |\ - tar xz && mv yq_linux_arm /usr/bin/yq +FROM recksato/robosats-client@sha256:7718b0b5ae46d5d6acb06d36fc65025d3b8e04790a6c12ac9555a03d47482ca2 +RUN apt-get update && apt-get install wget curl sudo bash tini -y +RUN wget https://github.com/mikefarah/yq/releases/download/v4.6.3/yq_linux_amd64.tar.gz -O - |\ + tar xz && mv yq_linux_amd64 /usr/bin/yq ENV APP_HOST robosats.embassy ENV APP_PORT 12596 diff --git a/Makefile b/Makefile index ac9e765..c161637 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,11 @@ all: verify verify: $(PKG_ID).s9pk embassy-sdk verify s9pk $(PKG_ID).s9pk -install: all +install: $(PKG_ID).s9pk embassy-cli package install $(PKG_ID).s9pk clean: + rm -rf docker-images rm -f image.tar rm -f $(PKG_ID).s9pk rm -f scripts/*.js @@ -21,8 +22,14 @@ clean: scripts/embassy.js: $(TS_FILES) deno bundle scripts/embassy.ts scripts/embassy.js -image.tar: Dockerfile docker_entrypoint.sh - docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --platform=linux/arm64 -o type=docker,dest=image.tar . +docker-images/x86_64.tar: Dockerfile docker_entrypoint.sh + mkdir -p docker-images + docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --platform=linux/amd64 --build-arg PLATFORM=amd64 -o type=docker,dest=docker-images/x86_64.tar . -$(PKG_ID).s9pk: check-web.sh manifest.yaml instructions.md icon.png LICENSE scripts/embassy.js image.tar - embassy-sdk pack +docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh + mkdir -p docker-images + docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --platform=linux/arm64 --build-arg PLATFORM=arm64 -o type=docker,dest=docker-images/aarch64.tar . + +$(PKG_ID).s9pk: manifest.yaml instructions.md LICENSE icon.png scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar + if ! [ -z "$(ARCH)" ]; then cp docker-images/$(ARCH).tar image.tar; fi + embassy-sdk pack \ No newline at end of file diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index cccd657..4abb9dd 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -3,4 +3,4 @@ set -ea echo "Starting RoboSats..." -exec tini -s ./robosats-client.sh +exec tini ./robosats-client.sh diff --git a/manifest.yaml b/manifest.yaml index 05ce85a..6ccb014 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -5,9 +5,9 @@ id: robosats # A human readable service title title: "RoboSats" # Service version - accepts up to four digits, where the last confirms to revisions necessary for EmbassyOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service. -version: 0.1.0 +version: 0.1.0.1 # Release notes for the update - can be a string, paragraph or URL -release-notes: "Initial Release for EmabssyOS" +release-notes: Updated to run on x86_64 architecture # The type of license for the project. Include the LICENSE in the root of the project directory. A license is required for a Start9 package. license: mit # The Start9 wrapper repository URL for the package. This repo contains the manifest file (this), any scripts necessary for configuration, backups, actions, or health checks (more below). This key must exist. But could be embedded into the source repository. @@ -35,33 +35,20 @@ assets: icon: icon.png # Default = INSTRUCTIONS.md instructions: instructions.md - # Default = image.tar - docker-images: image.tar # The main action for initializing the service. Currently, the only type of action available is docker. +containers: + main: + image: main + mounts: + main: /root main: - # Docker is currently the only action implementation - type: docker - # Identifier for the main image volume, which will be used when other actions need to mount to this volume. - image: main - # The executable binary for starting the initialization action. For docker actions, this is typically a "docker_entrypoint.sh" file. See the Dockerfile and the docker_entrypoint.sh in this project for additional details. - entrypoint: "docker_entrypoint.sh" - # Any arguments that should be passed into the entrypoint executable - args: [] - # Specifies where to mount the data volume(s), if there are any. Mounts for pointer dependency volumes are also denoted here. These are necessary if data needs to be read from / written to these volumes. - mounts: - # Specifies where on the service's file system its persistence directory should be mounted prior to service startup - main: /root + type: script # Health checks health-checks: main: name: Web Interface success-message: The RoboSats UI is ready to visit in a web browser - type: docker - image: main - entrypoint: check-web.sh - args: [] - io-format: json - inject: true + type: script config: get: type: script diff --git a/scripts/deps.ts b/scripts/deps.ts index 090054d..3bfd85b 100644 --- a/scripts/deps.ts +++ b/scripts/deps.ts @@ -1 +1 @@ -export * from "https://deno.land/x/embassyd_sdk@v0.3.1.1.2/mod.ts"; +export * from "https://deno.land/x/embassyd_sdk@v0.3.3.0.2/mod.ts"; diff --git a/scripts/embassy.ts b/scripts/embassy.ts index 2c67511..877cb45 100644 --- a/scripts/embassy.ts +++ b/scripts/embassy.ts @@ -2,3 +2,5 @@ export { setConfig } from "./procedures/setConfig.ts"; export { getConfig } from "./procedures/getConfig.ts"; export { properties } from "./procedures/properties.ts"; export { migration } from "./procedures/migrations.ts"; +export { health } from "./procedures/healthChecks.ts"; +export { main } from "./procedures/main.ts"; diff --git a/scripts/procedures/healthChecks.ts b/scripts/procedures/healthChecks.ts new file mode 100644 index 0000000..6f3ed2a --- /dev/null +++ b/scripts/procedures/healthChecks.ts @@ -0,0 +1,5 @@ +import { types as T, healthUtil } from "../deps.ts"; + +export const health: T.ExpectedExports.health = { + "web-ui": healthUtil.checkWebUrl("http://robosats.embassy:12596") +} \ No newline at end of file diff --git a/scripts/procedures/main.ts b/scripts/procedures/main.ts new file mode 100644 index 0000000..716b723 --- /dev/null +++ b/scripts/procedures/main.ts @@ -0,0 +1,11 @@ +import { types as T, util } from "../deps.ts"; + +export const main: T.ExpectedExports.main = async (effects) => { + await effects.runDaemon( + { + command: "docker_entrypoint.sh", + args: [], + }, + ).wait(); + return util.ok; +}; \ No newline at end of file diff --git a/scripts/procedures/migrations.ts b/scripts/procedures/migrations.ts index 5986c61..cad7644 100644 --- a/scripts/procedures/migrations.ts +++ b/scripts/procedures/migrations.ts @@ -1,4 +1,4 @@ import { compat, types as T } from "../deps.ts"; export const migration: T.ExpectedExports.migration = compat.migrations - .fromMapping({}, "0.1.0" ); + .fromMapping({}, "0.1.0.1" );