Skip to content

chore: add GitHub Actions workflow for publishing Node image - #1166

Merged
MicBun merged 3 commits into
mainfrom
chore/ghcr-image
Sep 19, 2025
Merged

chore: add GitHub Actions workflow for publishing Node image#1166
MicBun merged 3 commits into
mainfrom
chore/ghcr-image

Conversation

@outerlook

@outerlook outerlook commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Description

This commit introduces a new workflow in .github/workflows/publish-node-image.yaml to automate the building and pushing of a Docker image to the GitHub Container Registry upon release events. Additionally, it updates the Dockerfile to use environment variables for configuration and refines the entrypoint script to improve clarity and maintainability.

Related Problem

How Has This Been Tested?

Summary by CodeRabbit

  • New Features

    • Official container image published to GHCR with semver, ref, and digest tags; optional latest tag. Multi-arch builds for linux/amd64 and linux/arm64.
  • Changes

    • Configuration keys updated (SETUP_CHAIN_ID, new SETUP_DB_OWNER) and CONFIG_PATH defaulted to /root/.kwild.
    • Startup now uses defaults for DB read timeout and snapshot settings (previous explicit flags removed).
  • Chores

    • Automated workflow added to build and publish the container image with metadata-driven tagging and release-triggered builds.

This commit introduces a new workflow in `.github/workflows/publish-node-image.yaml` to automate the building and pushing of a Docker image to the GitHub Container Registry upon release events. Additionally, it updates the `Dockerfile` to use environment variables for configuration and refines the entrypoint script to improve clarity and maintainability.
@outerlook outerlook self-assigned this Sep 19, 2025
@coderabbitai

coderabbitai Bot commented Sep 19, 2025

Copy link
Copy Markdown

Walkthrough

Adds a GitHub Actions workflow to build and publish a Docker image to GHCR on release or manual trigger. Updates Docker build configuration and entrypoint: renames/introduces setup environment variables, sets CONFIG_PATH=/root/.kwild, enables shell tracing, quotes env refs, and simplifies the kwild start command by removing specific flags.

Changes

Cohort / File(s) Summary
CI: Publish Node Image Workflow
.github/workflows/publish-node-image.yaml
New workflow “Publish Node Image” that runs on workflow_dispatch and release (published). Sets IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/tn-db, computes TAG_LATEST (release or input), extracts docker metadata (sha, ref, semver, conditional latest), builds from deployments/Dockerfile for linux/amd64, linux/arm64 using Buildx, pushes to GHCR, and prints a job summary.
Container Build
deployments/Dockerfile
Dockerfile updates: rename CHAIN_IDSETUP_CHAIN_ID, add SETUP_DB_OWNER, set CONFIG_PATH=/root/.kwild, quote environment variable usages, enable set -x for verbose shell tracing.
Entrypoint
deployments/tn-entrypoint.sh
Simplified entrypoint: replaced multi-line exec with exec /app/kwild start --root $CONFIG_PATH, removing --db.read-timeout "60s" and --snapshots.enable.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant GH as GitHub
  participant GHA as GitHub Actions
  participant Buildx as Docker Buildx
  participant GHCR as GitHub Container Registry

  Dev->>GH: create release or trigger workflow_dispatch
  GH->>GHA: start "Publish Node Image"
  GHA->>GHA: set IMAGE_NAME, compute TAG_LATEST
  GHA->>GHA: docker/metadata-action -> produce tags/labels
  GHA->>Buildx: build multi-arch image from deployments/Dockerfile
  GHA->>GHCR: push image with generated tags
  GHA-->>Dev: publish summary (image, ref, tags)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop where CI pipelines run,
building images, one by one.
Tags and carrots in a row,
GHCR's shelves begin to glow.
A tiny rabbit stamps "publish" — done! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request also modifies the Dockerfile’s environment variables and refactors the entrypoint script, which go beyond the publishing workflow’s scope defined by issue #1164. These configuration and script updates are not necessary to enable image publication and introduce changes unrelated to the primary goal. Consolidating them into a separate pull request would improve review focus and maintain clear separation of concerns. Consider extracting the Dockerfile and entrypoint script modifications into a dedicated pull request to keep this changeset focused solely on the publishing workflow.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title clearly states the addition of a GitHub Actions workflow for publishing the Node image to the registry, reflecting the main change introduced. It concisely highlights the purpose of the update without including extraneous details. This phrasing allows teammates to understand the primary intent when scanning history.
Linked Issues Check ✅ Passed The pull request adds a workflow that builds and pushes the Docker image to the GitHub Container Registry on release or dispatch, directly addressing issue #1164’s requirement to publish the Node image on GHCR. The workflow uses docker/metadata-action and docker/build-push-action to tag and push multi-architecture images, satisfying the core objective of automated publication. No further modifications were needed to meet the linked issue’s main goal.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/ghcr-image

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0310046 and 9a81cd5.

📒 Files selected for processing (1)
  • .github/workflows/publish-node-image.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/publish-node-image.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: acceptance-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This commit adds an input option to the workflow for tagging builds as 'latest' during manual dispatch. It also introduces an environment variable to control the tagging logic based on the event type, improving the flexibility of the image publishing process.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
deployments/Dockerfile (1)

45-56: BUG: CONFIG_PATH is expanded at build-time, breaking runtime overrides.

In these echo lines, $CONFIG_PATH is expanded while building the image, hard-coding /root/.kwild into /app/config.sh. Users cannot override CONFIG_PATH at runtime. Also, cp with a glob misses dotfiles and can fail when the directory is empty.

Apply runtime-safe escaping and robust copy:

-    echo "set -xe" >> /app/config.sh && \
-    echo "if [ ! -f $CONFIG_PATH/config.toml ]; then" >> /app/config.sh && \
+    echo "set -xe" >> /app/config.sh && \
+    echo "if [ ! -f \"\$CONFIG_PATH/config.toml\" ]; then" >> /app/config.sh && \
     echo "    echo 'Configuration does not exist';" >> /app/config.sh && \
     echo "    echo 'Creating configuration';" >> /app/config.sh && \
     echo "    ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" --db-owner \"\$SETUP_DB_OWNER\" -r '/root/.kwil-new';" >> /app/config.sh && \
-    echo "    mkdir -p $CONFIG_PATH;" >> /app/config.sh && \
-    echo "    cp /root/.kwil-new/* $CONFIG_PATH;" >> /app/config.sh && \
+    echo "    mkdir -p \"\$CONFIG_PATH\";" >> /app/config.sh && \
+    echo "    cp -a /root/.kwil-new/. \"\$CONFIG_PATH/\";" >> /app/config.sh && \
     echo "    rm -rf /root/.kwil-new;" >> /app/config.sh && \
     echo "    echo 'Configuration created';" >> /app/config.sh && \
     echo "else" >> /app/config.sh && \
     echo "    echo 'Configuration already exists';" >> /app/config.sh && \
     echo "fi" >> /app/config.sh
🧹 Nitpick comments (6)
deployments/tn-entrypoint.sh (1)

17-17: Quote CONFIG_PATH in exec to avoid word splitting; verify removed flags’ defaults.

Use quotes for safety. Also confirm kwild’s defaults for the removed options are acceptable in prod.

-exec /app/kwild start --root $CONFIG_PATH
+exec /app/kwild start --root "$CONFIG_PATH"
deployments/Dockerfile (2)

45-56: Make db-owner optional to avoid passing an empty value to kwild.

If SETUP_DB_OWNER is unset, kwild may reject --db-owner "". Gate the flag conditionally in the script.

Proposed inline script logic:

-    echo "    ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" --db-owner \"\$SETUP_DB_OWNER\" -r '/root/.kwil-new';" >> /app/config.sh && \
+    echo "    OWNER_FLAG=\"\"; [ -n \"\$SETUP_DB_OWNER\" ] && OWNER_FLAG=\"--db-owner \\\"\$SETUP_DB_OWNER\\\"\";" >> /app/config.sh && \
+    echo "    ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" \$OWNER_FLAG -r '/root/.kwil-new';" >> /app/config.sh && \

43-56: Prefer a heredoc over chained echos for maintainability and correct quoting.

This avoids accidental expansions and is easier to diff.

-RUN echo "#!/bin/sh" > /app/config.sh && \
-    echo "set -xe" >> /app/config.sh && \
-    echo "if [ ! -f \"\$CONFIG_PATH/config.toml\" ]; then" >> /app/config.sh && \
-    echo "    echo 'Configuration does not exist';" >> /app/config.sh && \
-    echo "    echo 'Creating configuration';" >> /app/config.sh && \
-    echo "    OWNER_FLAG=\"\"; [ -n \"\$SETUP_DB_OWNER\" ] && OWNER_FLAG=\"--db-owner \\\"\$SETUP_DB_OWNER\\\"\";" >> /app/config.sh && \
-    echo "    ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" \$OWNER_FLAG -r '/root/.kwil-new';" >> /app/config.sh && \
-    echo "    mkdir -p \"\$CONFIG_PATH\";" >> /app/config.sh && \
-    echo "    cp -a /root/.kwil-new/. \"\$CONFIG_PATH/\";" >> /app/config.sh && \
-    echo "    rm -rf /root/.kwil-new;" >> /app/config.sh && \
-    echo "    echo 'Configuration created';" >> /app/config.sh && \
-    echo "else" >> /app/config.sh && \
-    echo "    echo 'Configuration already exists';" >> /app/config.sh && \
-    echo "fi" >> /app/config.sh
+RUN cat > /app/config.sh <<'EOF'
+#!/bin/sh
+set -xe
+if [ ! -f "$CONFIG_PATH/config.toml" ]; then
+  echo 'Configuration does not exist'
+  echo 'Creating configuration'
+  OWNER_FLAG=""
+  if [ -n "$SETUP_DB_OWNER" ]; then OWNER_FLAG="--db-owner $SETUP_DB_OWNER"; fi
+  ./kwild setup init --chain-id "$SETUP_CHAIN_ID" $OWNER_FLAG -r '/root/.kwil-new'
+  mkdir -p "$CONFIG_PATH"
+  cp -a /root/.kwil-new/. "$CONFIG_PATH/"
+  rm -rf /root/.kwil-new
+  echo 'Configuration created'
+else
+  echo 'Configuration already exists'
+fi
+EOF
.github/workflows/publish-node-image.yaml (3)

62-66: Use printf for newlines; echo won’t expand \n reliably.

Actionlint SC2028 is valid here; switch to printf.

-      - name: Summary
-        run: |
-          echo "Image pushed: ${{ env.IMAGE_NAME }}"
-          echo "Ref: ${{ github.ref }}"
-          echo "Tags:\n${{ steps.meta.outputs.tags }}"
+      - name: Summary
+        run: |
+          printf 'Image pushed: %s\n' '${{ env.IMAGE_NAME }}'
+          printf 'Ref: %s\n' '${{ github.ref }}'
+          printf 'Tags:\n%s\n' '${{ steps.meta.outputs.tags }}'

52-61: Enable build cache to speed repeated builds.

GHA cache with Buildx is low-risk and improves CI latency.

       - name: Build and push image
         uses: docker/build-push-action@v5
         with:
           context: .
           file: deployments/Dockerfile
           push: true
           platforms: linux/amd64
           tags: ${{ steps.meta.outputs.tags }}
           labels: ${{ steps.meta.outputs.labels }}
+          cache-from: type=gha
+          cache-to: type=gha,mode=max

14-17: Add concurrency to prevent overlapping publishes from racing tags.

Avoids concurrent runs pushing different images under the same tag.

 permissions:
   contents: read
   packages: write

+concurrency:
+  group: publish-node-image-${{ github.ref }}
+  cancel-in-progress: false
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc2ced and 0310046.

📒 Files selected for processing (3)
  • .github/workflows/publish-node-image.yaml (1 hunks)
  • deployments/Dockerfile (2 hunks)
  • deployments/tn-entrypoint.sh (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/publish-node-image.yaml

63-63: shellcheck reported issue in this script: SC2028:info:3:6: echo may not expand escape sequences. Use printf

(shellcheck)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: acceptance-test

@holdex

holdex Bot commented Sep 19, 2025

Copy link
Copy Markdown

Time Submission Status

Member Status Time Action Last Update
outerlook ✅ Submitted 1h Update time Sep 19, 2025, 3:06 PM
MicBun ✅ Submitted 15min Update time Sep 19, 2025, 10:35 PM

…ilds

This commit modifies the Node image publishing workflow to enable building and pushing Docker images for both amd64 and arm64 architectures. This enhancement improves compatibility and accessibility of the published images across different platforms.
@outerlook
outerlook requested a review from MicBun September 19, 2025 15:04

@MicBun MicBun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@MicBun
MicBun merged commit e62eb37 into main Sep 19, 2025
6 of 7 checks passed
@MicBun
MicBun deleted the chore/ghcr-image branch September 19, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem: Node docker image isn't published on GHCR

2 participants