Skip to content

Conversation

f213
Copy link

@f213 f213 commented Sep 4, 2025

Current container implemntation takes 10 secs to stop after pressing Ctrl-C. This happens because of node.js not handling docker signals.

Summary by CodeRabbit

  • Chores
    • Updated container base image to a newer Alpine variant for improved compatibility and security.
    • Added a lightweight init wrapper to improve signal handling and ensure clean shutdowns.
    • Switched image publishing from Docker Hub to GitHub Container Registry and updated authentication for CI publishing.
    • No user-facing application changes; deployment and CI improvements only.

Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

Switch Docker base image to node:22-alpine3.21, add dumb-init and set it as container ENTRYPOINT; update CI workflow to publish images to GitHub Container Registry (GHCR) and adjust authentication and image name.

Changes

Cohort / File(s) Summary of Changes
Container base & init
Dockerfile
- Bump base image: node:22-alpinenode:22-alpine3.21
- Add build-time package: apk add --no-cache dumb-init==1.2.5-r3
- Set ENTRYPOINT to ["/usr/bin/dumb-init", "--"]
- Preserve CMD: ["node", "dist/index.js"]
CI: image publish
.github/workflows/docker-publish.yml
- Change registry: docker.ioghcr.io and image name updated (zerob13/mock-openai-apif213/mock-openai-api).
- Update login/authentication to GHCR using github.repository_owner and secrets.GITHUB_TOKEN.
- Minor formatting adjustment in readme/update step (whitespace).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Docker as Docker daemon
  participant Init as /usr/bin/dumb-init
  participant App as node (dist/index.js)

  Docker->>Init: start container (ENTRYPOINT)
  Init-->>Docker: reap signals / forward signals
  Init->>App: exec node dist/index.js (CMD)
  App-->>Init: respond / exit
  Init-->>Docker: exit status forwarded
  note right of Init #CFE9F8: dumb-init added to manage\nsignal handling and reaping
Loading
sequenceDiagram
  autonumber
  participant GHAction as GitHub Actions
  participant GHCR as ghcr.io

  GHAction->>GHCR: authenticate using GITHUB_TOKEN (repository_owner)
  GHAction->>GHCR: build and push image f213/mock-openai-api
  GHCR-->>GHAction: push result / image digest
  note right of GHCR #F0F4C3: Registry switched from Docker Hub to GHCR
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble at the Docker root tonight,
A tiny init to keep things light 🥕
Alpine tuned and publish switched,
Containers calm, the workflow fixed—
Hop, push, and rest until daylight 🌙

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

dosubot bot commented Sep 4, 2025

Related Documentation

Checked 1 published document(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
Dockerfile (3)

2-2: Base image bump looks good; consider digest pin and clarifying stage.

  • Nice move to node:22-alpine3.21 for musl-based small images.
  • For reproducibility, consider pinning by digest.
  • The header says “Build stage” but there’s only one stage. Either rename the comment or convert to a true multi-stage build to drop dev deps from the runtime image.

Apply if you just want to clarify intent:

-# Build stage
+# Base image
 FROM node:22-alpine3.21

If you prefer multi-stage (optional skeleton):

-FROM node:22-alpine3.21
+FROM node:22-alpine3.21 AS builder
 ...
-RUN npm i
+RUN npm ci
 ...
 RUN npm run build
 ...
-EXPOSE 3000
-ENV NODE_ENV=production
-ENV PORT=3000
-ENV HOST=0.0.0.0
-ENV VERBOSE=true
-ENTRYPOINT ["/usr/bin/dumb-init", "--"]
-# Start the application with verbose logging enabled
-CMD ["node", "dist/index.js"]
+FROM node:22-alpine3.21 AS runner
+WORKDIR /app
+# Only runtime deps
+COPY package*.json ./
+RUN npm ci --omit=dev --ignore-scripts
+COPY --from=builder /app/dist ./dist
+EXPOSE 3000
+ENV NODE_ENV=production
+ENV PORT=3000
+ENV HOST=0.0.0.0
+ENV VERBOSE=true
+ENTRYPOINT ["/usr/bin/dumb-init", "--"]
+CMD ["node", "dist/index.js"]

5-6: Fix comment typo and validate package pin.

  • “Install pages” → “Install dumb-init” (typo).
  • Version pin dumb-init==1.2.5-r3 is good for repeatability but can break if the repo rotates; ensure it exists for alpine3.21.

Apply the typo fix:

-# Install pages
+# Install dumb-init (for proper signal handling as PID 1)
 RUN apk add --no-cache dumb-init==1.2.5-r3

Please verify the pin matches the base repo by running locally:

docker run --rm node:22-alpine3.21 sh -lc 'apk add --no-cache dumb-init==1.2.5-r3 && dumb-init --version'

32-35: ENTRYPOINT via dumb-init: good; add STOPSIGNAL and note behavior change.

  • Good use of exec-form with dumb-init to forward signals and reap zombies.
  • Recommend declaring STOPSIGNAL to align with graceful shutdown.
  • ENTRYPOINT changes container UX (overriding CMD no longer bypasses dumb-init). Document in README or release notes.

Apply:

+STOPSIGNAL SIGTERM
 ENTRYPOINT ["/usr/bin/dumb-init", "--"]

If you prefer not to bake init into the image, an alternative is advising docker run --init … or Compose init: true in ops docs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8a8e94f and 4b1da24.

📒 Files selected for processing (1)
  • Dockerfile (2 hunks)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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)
.github/workflows/docker-publish.yml (1)

65-73: Remove or disable stale Docker Hub description step
The Update Docker Hub description step still depends on Docker Hub credentials and uses ${{ env.IMAGE_NAME }} (now pointing to GHCR), causing failures post-migration. Choose one:

  • Option A — Guard and point to an explicit Docker Hub repo:

          - name: Update Docker Hub description
          - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
          + name: Update Docker Hub description
          + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && env.DOCKERHUB_REPOSITORY != ''
           uses: peter-evans/dockerhub-description@v4
           with:
             username: ${{ secrets.DOCKERHUB_USERNAME }}
             password: ${{ secrets.DOCKERHUB_TOKEN }}
          -  repository: ${{ env.IMAGE_NAME }}
          +  repository: ${{ env.DOCKERHUB_REPOSITORY }}
             readme-filepath: ./README.md

    And add at top-level env::

    DOCKERHUB_REPOSITORY: ""  # e.g., "username/repo" if you still maintain Docker Hub
  • Option B — Remove this step entirely if Docker Hub is no longer used.

🧹 Nitpick comments (2)
.github/workflows/docker-publish.yml (2)

16-17: Parameterize image name to avoid hardcoding owner/repo.

Hardcoding f213/mock-openai-api makes forks/org renames brittle. Prefer deriving from the repository.

Apply:

-  REGISTRY: ghcr.io
-  IMAGE_NAME: f213/mock-openai-api
+  REGISTRY: ghcr.io
+  IMAGE_NAME: ${{ github.repository }}

33-39: Step name and auth now target GHCR, not Docker Hub.

Rename for clarity; config is correct for GHCR with GITHUB_TOKEN and packages: write.

-      - name: Log in to Docker Hub
+      - name: Log in to GHCR
         if: github.event_name != 'pull_request'
         uses: docker/login-action@v3
         with:
           registry: ${{ env.REGISTRY }}
           username: ${{ github.repository_owner }}
           password: ${{ secrets.GITHUB_TOKEN }}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3ba171a and 6953225.

📒 Files selected for processing (1)
  • .github/workflows/docker-publish.yml (3 hunks)

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.

1 participant