From 4d6a8628afee3ba52d9c73ae06a201190dba93e4 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Sun, 22 Dec 2024 18:43:30 -0500 Subject: [PATCH] feature/deploy linux (#1206) * chore(deploy): remove devbox configuration * feat(taskfiles): add mount and platform specific start commands for IPFS --- .taskfiles/Hway.yml | 9 +++-- .taskfiles/IPFS.yml | 25 ++++++++++---- .taskfiles/Sonrd.yml | 10 ++---- Taskfile.yml | 69 +++++++++++++++++++++++++++++++++++-- deploy/devbox.json | 18 ---------- deploy/process-compose.yaml | 23 +++++-------- 6 files changed, 104 insertions(+), 50 deletions(-) delete mode 100644 deploy/devbox.json diff --git a/.taskfiles/Hway.yml b/.taskfiles/Hway.yml index 864547aba..e4f5e92c1 100644 --- a/.taskfiles/Hway.yml +++ b/.taskfiles/Hway.yml @@ -14,12 +14,17 @@ tasks: build: desc: Build the hway binary silent: true - cmds: + cmds: - gum spin --spinner dot --title "Build Hway Single Target ({{.OS}}/{{.ARCH}})..." -- goreleaser build --snapshot --clean --single-target --id hway -o {{.BIN_DIR}}/hway + install: + desc: Install the hway binary + silent: true + cmds: + - gum spin --spinner dot --title "Install Hway Single Target ({{.OS}}/{{.ARCH}})..." -- make install-hway + start: desc: Start the hway daemon silent: true - deps: [build] cmds: - "{{.BINARY}}" diff --git a/.taskfiles/IPFS.yml b/.taskfiles/IPFS.yml index 48c8c3e76..5819403cc 100644 --- a/.taskfiles/IPFS.yml +++ b/.taskfiles/IPFS.yml @@ -29,9 +29,22 @@ tasks: - ipfs config --json Peering.Peers {{.PEERS}} - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' -start: - desc: Start the ipfs daemon - silent: true - deps: [init] - cmds: - - ipfs daemon + mount: + desc: Mount the ipfs,ipns directories + silent: true + platforms: + - linux + cmds: + - ipfs config --json Mounts.FuseAllowOther true + + start: + desc: Start the ipfs daemon + silent: true + cmds: + - cmd: ipfs daemon --migrate + platforms: + - darwin + - task: mount + - cmd: ipfs daemon --mount + platforms: + - linux diff --git a/.taskfiles/Sonrd.yml b/.taskfiles/Sonrd.yml index cd98a0feb..b0b0bf8d8 100644 --- a/.taskfiles/Sonrd.yml +++ b/.taskfiles/Sonrd.yml @@ -4,13 +4,10 @@ vars: BINARY: sonrd BUILD_FLAGS: -mod=readonly -trimpath BUILD_TAGS: netgo,ledger - COMMIT: + COMMIT: sh: git rev-parse HEAD VERSION: sh: git describe --tags --always - DOPPLER_TOKEN: - sh: skate get DOPPLER_NETWORK - tasks: build: desc: Build the sonrd binary @@ -30,11 +27,11 @@ tasks: ./cmd/sonrd env: CGO_ENABLED: 1 - GOARCH: + GOARCH: sh: go env GOARCH GOOS: sh: go env GOOS - + install: desc: Install sonrd silent: true @@ -45,4 +42,3 @@ tasks: desc: Start the sonr node cmds: - sh scripts/test_dop_node.sh - diff --git a/Taskfile.yml b/Taskfile.yml index fd7828816..858c6a793 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -40,7 +40,13 @@ tasks: desc: Install go dependencies silent: true vars: - DEPS: ["github.com/apple/pkl-go/cmd/pkl-gen-go@latest", "github.com/sqlc-dev/sqlc/cmd/sqlc@latest", "github.com/goreleaser/goreleaser/v2@latest","github.com/a-h/templ/cmd/templ@latest"] + DEPS: + [ + "github.com/apple/pkl-go/cmd/pkl-gen-go@latest", + "github.com/sqlc-dev/sqlc/cmd/sqlc@latest", + "github.com/goreleaser/goreleaser/v2@latest", + "github.com/a-h/templ/cmd/templ@latest", + ] cmds: - for: { var: DEPS } cmd: gum spin --spinner dot --title "Installing go dependencies..." -- go install {{.ITEM}} @@ -54,7 +60,7 @@ tasks: cmds: - for: { var: FILES } cmd: gum spin --spinner dot --title "Generating PKL in Go..." -- pkl-gen-go {{.ITEM}} - + proto-gen: desc: Generate proto files silent: true @@ -70,3 +76,62 @@ tasks: desc: Generate templ files silent: true cmd: gum spin --spinner dot --title "Generating Templ..." -- templ generate + + start: + desc: Start the Network + silent: true + cmds: + - task: postgres:reset + - task: ipfs:init + - task: ipfs:mount + - task: sonrd:install + - task: hway:build + - task: procs-up + + status: + desc: Check the status of the Network + silent: true + cmds: + - task: procs-attach + + stop: + desc: Stop the Network + silent: true + cmds: + - task: procs-down + + procs-up: + internal: true + dir: "deploy" + cmds: + - cmd: process-compose up + platforms: + - darwin + + - cmd: process-compose up --use-uds --unix-socket /tmp/sonr-network.sock -D + platforms: + - linux + + procs-down: + internal: true + dir: "deploy" + cmds: + - cmd: process-compose down + platforms: + - darwin + + - cmd: process-compose down --use-uds --unix-socket /tmp/sonr-network.sock + platforms: + - linux + + procs-attach: + internal: true + dir: "deploy" + cmds: + - cmd: process-compose attach --use-uds --unix-socket /tmp/sonr-network.sock + platforms: + - linux + + - cmd: process-compose attach + platforms: + - darwin diff --git a/deploy/devbox.json b/deploy/devbox.json deleted file mode 100644 index 7d37ab03e..000000000 --- a/deploy/devbox.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.7/.schema/devbox.schema.json", - "packages": [ - "tigerbeetle@latest", - "ipfs@latest" - ], - "shell": { - "scripts": { - "init": [], - "start": [ - "devbox services up" - ], - "stop": [ - "devbox services down" - ] - } - } -} diff --git a/deploy/process-compose.yaml b/deploy/process-compose.yaml index ca5bfb5ff..4f72402cc 100644 --- a/deploy/process-compose.yaml +++ b/deploy/process-compose.yaml @@ -1,30 +1,23 @@ version: "0.5" -environment: - - "PC_DISABLE_TUI=true" -log_location: "./tmp/logs" -log_level: "debug" - processes: IPFS: namespace: testnet - command: "task ipfs:start" - availability: - restart: "always" + command: "ipfs daemon --mount" + ready_log_line: "Daemon is ready" Sonr: namespace: testnet command: "task sonrd:start" depends_on: - ipfs: - condition: process_completed - environment: - - "SONR_NETWORK=testnet" + IPFS: + condition: process_log_ready Hway: namespace: testnet command: "hway" depends_on: - sonr: - condition: process_completed_successfully - + IPFS: + condition: process_log_ready + Sonr: + condition: process_started