Skip to content

Commit

Permalink
add example workflow to publish docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
willemolding committed Apr 15, 2024
1 parent fcbe60f commit 2a28506
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish Docker images

on:
release:
types: [published]

jobs:
push_fullnode_to_registry:
name: Push fullnode Docker image to fly.io
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: 🔑 Fly Registry Auth
uses: docker/login-action@v1
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}

- name: 🐳 Docker build (fullnode)
uses: docker/build-push-action@v2
with:
context: .
file: ./fullnode.Dockerfile
push: true
tags: registry.fly.io/cartezcash-fullnode:latest
build-args: |
COMMIT_SHA=${{ github.sha }}
push_cartesi_node_to_registry:
name: Push cartesi node Docker image to fly.io
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: 🔑 Fly Registry Auth
uses: docker/login-action@v1
with:
registry: registry.fly.io
username: x
password: ${{ secrets.FLY_API_TOKEN }}

- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"

- name: Install Sunodo and build
run: |
npm install -g @sunodo/cli
IMAGE_TAG=$(sunodo deploy build --platform linux/amd64 | grep "Application node Docker image" | awk '{print $NF}')
docker push $IMAGE_TAG:registry.fly.io/cartezcash:latest
14 changes: 9 additions & 5 deletions .github/workflows/fly.yml → .github/workflows/fly.yml.scratch
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Fly Deploy
name: Fly.io Deploy

on:
push:
branches:
- main
workflow_run:
workflows: ["Publish Docker images"]
types:
- completed

jobs:
deploy-node:
name: Deploy Cartesi node
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
Expand All @@ -17,6 +21,7 @@ jobs:

deploy-fullnode:
name: Deploy fullnode
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
Expand All @@ -25,4 +30,3 @@ jobs:
- run: fflyctl deploy --config fly.fullnode.toml --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

2 changes: 1 addition & 1 deletion fly.fullnode.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
app = "cartezcash-fullnode"

[build]
image = "registry.fly.io/cartezcash-fullnode"
image = "registry.fly.io/cartezcash-fullnode:latest"

[[services]]
internal_port = 50051
Expand Down
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
app = "cartezcash"

[build]
image = "registry.fly.io/cartezcash"
image = "registry.fly.io/cartezcash:latest"

[http_service]
internal_port = 10000
Expand Down

0 comments on commit 2a28506

Please sign in to comment.