feat: Add Docker build and publish CI for web app#432
Conversation
|
@gowthamkishore3799 is attempting to deploy a commit to the Inbox Zero Team on Vercel. A member of the Team first needs to authorize it. |
|
Caution Review failedThe pull request is closed. WalkthroughThis update introduces a new GitHub Actions workflow for automated Docker image building, versioning, and publishing to GitHub Container Registry. It also modifies the Docker build process, environment variable handling, and Sanity project ID checks in several files. The Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant GitHub as GitHub Actions
participant GHCR as GitHub Container Registry
participant Repo as Repository
Dev->>GitHub: Push to main branch
GitHub->>GitHub: set-version job (read version.txt)
GitHub->>GitHub: build-docker job (build & tag Docker image)
GitHub->>GHCR: Push Docker image (latest & version tag)
GitHub->>GitHub: update_version_txt job (increment version.txt, commit & tag)
GitHub->>Repo: Push updated version.txt and tag
Possibly related PRs
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
version.txt (1)
1-1: Add trailing newline characterThe version format looks good, but best practice is to include a trailing newline character at the end of text files for better compatibility with Unix tools and to avoid warnings from some tools.
-v1.0.0 +v1.0.0 +apps/web/app/blog/page.tsx (1)
1-7: Clean import organizationThe imports have been reorganized in a more logical way with type imports first, followed by component imports, and then utility imports. This improves code readability without affecting functionality.
.github/workflows/build_and_publish_docker.yml (1)
4-7: Consider adding tag-based triggers for semantic versioningThe workflow currently only triggers on pushes to the main branch. Consider adding tag-based triggers to enable semantic versioning (e.g., when tags matching v*.. are pushed).
on: push: branches: [ "main" ] + tags: + - 'v*.*.*'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.github/workflows/build_and_publish_docker.yml(1 hunks)apps/web/app/blog/page.tsx(2 hunks)apps/web/app/blog/post/[slug]/page.tsx(1 hunks)apps/web/app/sitemap.ts(1 hunks)docker-compose.yml(1 hunks)docker/Dockerfile.prod(2 hunks)version.txt(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/build_and_publish_docker.yml
51-51: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
54-54: the runner of "docker/build-push-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (9)
apps/web/app/blog/post/[slug]/page.tsx (1)
13-13: Environment check updated correctlyUpdating the environment check to use "project123" is consistent with the PR's goal of standardizing the project ID value used during Docker builds. This ensures that Sanity data fetches are properly skipped during build time when not needed.
apps/web/app/sitemap.ts (1)
8-8: Environment check updated correctlyThe change to use "project123" for the environment check is consistent with the updates in other files and aligns with the standardized approach for Docker builds. This ensures that Sanity data fetches are properly skipped during build time.
docker/Dockerfile.prod (3)
21-23: Improved dependency installation approachThe addition of
--prefer-offlineand--ignore-scriptsflags to the pnpm install command is a good optimization. The--prefer-offlineflag will use cached packages when available, speeding up builds, while--ignore-scriptsprevents running potentially unnecessary postinstall scripts at this stage.
28-30: Logical sequence for Prisma generateMoving the Prisma generate command to immediately follow dependency installation is a good practice. This ensures it runs with all build-time variables and leverages caching effectively.
54-54:Details
✅ Verification successful
Verify Sanity project ID consistency
The Sanity project ID has been changed to "project123", which aligns with the conditional checks in other files like
apps/web/app/blog/page.tsx. This ensures consistent handling of Sanity content fetching during build and runtime.
🏁 Script executed:
#!/bin/bash # Checking for consistent use of the new Sanity project ID across the codebase echo "Checking for consistent use of Sanity project ID..." rg "NEXT_PUBLIC_SANITY_PROJECT_ID.*project123" --type tsx --type ts rg "dummy-sanity-project-id-for-build" --type tsx --type tsLength of output: 298
🏁 Script executed:
#!/bin/bash set -e echo "🔍 Searching for NEXT_PUBLIC_SANITY_PROJECT_ID references across the repo" rg "NEXT_PUBLIC_SANITY_PROJECT_ID" || true echo echo "🔍 Searching for explicit “project123” usage in code" rg "project123" || true echo echo "🔍 Searching for placeholder “dummy-sanity-project-id-for-build”" rg "dummy-sanity-project-id-for-build" || trueLength of output: 1500
Sanity project ID updated consistently across the codebase
Verified that
NEXT_PUBLIC_SANITY_PROJECT_IDhas been set to"project123"indocker/Dockerfile.prodand that all runtime checks now reference this value. No remaining occurrences of the old placeholder (dummy-sanity-project-id-for-build) were found.Files updated and verified:
- docker/Dockerfile.prod: ENV NEXT_PUBLIC_SANITY_PROJECT_ID="project123"
- apps/web/sanity/env.ts & sanity.cli.ts: sourcing
process.env.NEXT_PUBLIC_SANITY_PROJECT_ID- apps/web/app/sitemap.ts, blog/page.tsx, blog/post/[slug]/page.tsx: conditional logic aligned to
"project123"All checks are in sync—LGTM!
apps/web/app/blog/page.tsx (1)
211-211: Consistent environment check for Sanity project IDThe environment variable check has been updated to match the new value in the Dockerfile ("project123"). This ensures that content is only fetched from Sanity when a real project ID is used, not the dummy one used for building.
.github/workflows/build_and_publish_docker.yml (3)
1-10: Good workflow setup with clear naming and configurationThe workflow is well-structured with descriptive name, trigger conditions, and environment variables for Docker image registry and username. These variables make the workflow more maintainable.
14-30: Well-structured versioning jobThe version setting job correctly reads from a version.txt file and makes it available as output for downstream jobs. The condition ensures it only runs in the intended repository.
66-111: Robust version updating mechanismThe version updating job correctly increments the patch version, commits the changes, and pushes them with appropriate tagging. The use of
force_with_leaseprovides a safer alternative to force push.
| - inbox-zero-network | ||
|
|
||
| web: | ||
| image: ghcr.io/elie222/inbox-zero:latest |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Update image repository owner before merging
As mentioned in the PR description, the image path should be updated to use the organization's repository owner.
🏁 Script executed:
#!/bin/bash
# Check the repository owner
echo "Current image path: ghcr.io/elie222/inbox-zero:latest"
echo "Repository owner: $(git remote get-url origin | sed -n 's/.*github.com[:\/]\([^\/]*\)\/.*/\1/p')"Length of output: 257
🏁 Script executed:
#!/bin/bash
# List all git remotes to identify the organization’s repository owner
git remote -v
if git remote get-url upstream &> /dev/null; then
echo "Upstream remote URL: $(git remote get-url upstream)"
echo "Upstream owner: $(git remote get-url upstream | sed -n 's/.*github.com[:\/]\([^\/]*\)\/.*/\1/p')"
else
echo "No 'upstream' remote configured"
fiLength of output: 249
Update image repository owner in docker-compose.yml
Please replace the personal namespace with your organization’s GitHub Container Registry owner before merging.
• File: docker-compose.yml
• Line 41
Diff suggestion:
- image: ghcr.io/elie222/inbox-zero:latest
+ image: ghcr.io/<ORG_OWNER>/inbox-zero:latestReplace <ORG_OWNER> with your official GitHub organization or team name.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| image: ghcr.io/elie222/inbox-zero:latest | |
| image: ghcr.io/<ORG_OWNER>/inbox-zero:latest |
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
.github/workflows/build_and_publish_docker.yml (1)
50-59: 🛠️ Refactor suggestionBump Docker actions and enable multi-arch builds
Thesetup-buildx-action@v2andbuild-push-action@v4versions are outdated, and you’re only targetinglinux/arm64. Upgrade to the latest stable releases and expand platforms tolinux/amd64,linux/arm64for broader compatibility.Proposed diff:
- - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.10.0 - - name: Build and Push Docker Image - uses: docker/build-push-action@v4 + - name: Build and Push Docker Image + uses: docker/build-push-action@v6.16.0 with: context: . file: docker/Dockerfile.prod - platforms: linux/arm64 + platforms: linux/amd64,linux/arm64🧰 Tools
🪛 actionlint (1.7.4)
51-51: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
54-54: the runner of "docker/build-push-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🧹 Nitpick comments (2)
.github/workflows/build_and_publish_docker.yml (2)
9-11: Standardize DOCKER_USERNAME for maintainability
Hardcodingelie222in the env block means that after merging, pushes will still target your fork. Use${{ github.repository_owner }}so the workflow automatically points to the correct registry owner.Proposed diff:
env: DOCKER_IMAGE_REGISTRY: "ghcr.io" - DOCKER_USERNAME: "elie222" + DOCKER_USERNAME: ${{ github.repository_owner }}
22-23: Unifyactions/checkoutversion
You’re usingactions/checkout@v4.1.1in set-version and@v4in build-docker. Pinning both to the same release reduces drift and unexpected behavior.Proposed diff:
- uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1Also applies to: 39-40
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/build_and_publish_docker.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/build_and_publish_docker.yml
51-51: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
54-54: the runner of "docker/build-push-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (2)
.github/workflows/build_and_publish_docker.yml (2)
51-52:⚠️ Potential issueUpgrade Docker Buildx action to v3.x
docker/setup-buildx-action@v2is deprecated on modern runners and may cause failures. Upgrade to the latest v3.x release (e.g.,v3.10.0).- - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.10.0🧰 Tools
🪛 actionlint (1.7.4)
51-51: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
54-55:⚠️ Potential issueUpgrade Docker Build and Push action to v6.x
docker/build-push-action@v4is outdated and will fail on current GitHub Actions runners. Bump tov6.16.0(or latest v6).- - name: Build and Push Docker Image - uses: docker/build-push-action@v4 + - name: Build and Push Docker Image + uses: docker/build-push-action@v6.16.0🧰 Tools
🪛 actionlint (1.7.4)
54-54: the runner of "docker/build-push-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🧹 Nitpick comments (1)
.github/workflows/build_and_publish_docker.yml (1)
10-10: MakeDOCKER_USERNAMEdynamic
Hard-codingelie222can lead to misconfiguration if the repository owner changes. Use${{ github.repository_owner }}for flexibility and future portability.- DOCKER_USERNAME: "elie222" + DOCKER_USERNAME: "${{ github.repository_owner }}"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/build_and_publish_docker.yml(1 hunks)docker-compose.yml(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- docker-compose.yml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/build_and_publish_docker.yml
51-51: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
54-54: the runner of "docker/build-push-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
| git tag -a "${{ needs.set-version.outputs.version }}" -m "Release version ${{ needs.set-version.outputs.version }}" | ||
| git commit -a -m "Update base version to ${{needs.set-version.outputs.version}}" | ||
| echo "Version updated to ${{needs.set-version.outputs.version}} on trails" >> $GITHUB_STEP_SUMMARY |
There was a problem hiding this comment.
Fix version bump commit and push branch
The update_version_txt job’s commit message uses the old version and the push action targets ${{ github.ref }} instead of main, which may not map correctly. Update the commit to reference the new bumped version and push explicitly to main.
- git tag -a "${{ needs.set-version.outputs.version }}" -m "Release version ${{ needs.set-version.outputs.version }}"
- git commit -a -m "Update base version to ${{needs.set-version.outputs.version}}"
+ git tag -a "${{ needs.set-version.outputs.version }}" -m "Release version ${{ needs.set-version.outputs.version }}"
+ git commit -a -m "Update base version to ${{ steps.update_version.outputs.new_version }}"
@@
- branch: ${{ github.ref }}
+ branch: mainAlso applies to: 108-109
|
Deployment failed with the following error: |
|
After this deployment is done, ill be adding turbo to fasten the build process Currently takes time in building during CI/CD, which is expected, turbo would fasten it up, instead of wrapping up everything in single pr, once this is done, ill be making seperate pr for it |
|
The previous related to CI/CD from vishal failed due to a const convention, which is fixed here |
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (3)
.github/workflows/build_and_publish_docker.yml (3)
58-59: 🛠️ Refactor suggestionUpgrade
docker/build-push-actionto the latest major version
v4is out of date. Use the currentv6.xrelease (e.g.,v6.16.0) to ensure full GitHub Actions compatibility and performance improvements:- - name: Build and Push Docker Image - uses: docker/build-push-action@v4 + - name: Build and Push Docker Image + uses: docker/build-push-action@v6.16.0🧰 Tools
🪛 actionlint (1.7.4)
58-58: the runner of "docker/build-push-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
54-56: 🛠️ Refactor suggestionUpgrade
docker/setup-buildx-actionto a recent version
v2is outdated and may no longer run on modern runners. Bump to the latestv3release (e.g.,v3.10.0) for compatibility:- - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.10.0🧰 Tools
🪛 actionlint (1.7.4)
55-55: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
108-113:⚠️ Potential issueFix the push branch in the Git push action
Using
branch: ${{ github.ref }}may resolve to a full ref (e.g.refs/heads/main) and fail. Explicitly push tomain(or use${{ github.ref_name }}if you want dynamic branches):- branch: ${{ github.ref }} + branch: main
🧹 Nitpick comments (2)
.github/workflows/build_and_publish_docker.yml (2)
4-7: (Optional) Trigger on version tags for automated image publishingIf you’d like Docker images to build when you push a new version tag (e.g.,
v1.2.3), expand your trigger:on: push: branches: ["main"] + tags: + - 'v*'
26-27: Unify checkout action versions for consistencyYou’re using both
actions/checkout@v4.1.1andactions/checkout@v4. It’s best to pin all to the same version to avoid unexpected behavior:- uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1Also applies to: 43-45, 79-82
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/build_and_publish_docker.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/build_and_publish_docker.yml
55-55: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
58-58: the runner of "docker/build-push-action@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (1)
.github/workflows/build_and_publish_docker.yml (1)
62-63: Multi-platform build is correctly configured 👍You’ve expanded to both
linux/arm64andlinux/amd64, ensuring broader compatibility.
| env: | ||
| DOCKER_IMAGE_REGISTRY: "ghcr.io" | ||
| DOCKER_USERNAME: "elie222" | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Make the Docker username dynamic
Hard-coding DOCKER_USERNAME: "elie222" forces a manual update after merging. Switch to github.repository_owner so it works in both forks and your main repo without edits:
env:
DOCKER_IMAGE_REGISTRY: "ghcr.io"
- DOCKER_USERNAME: "elie222"
+ DOCKER_USERNAME: "${{ github.repository_owner }}"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| env: | |
| DOCKER_IMAGE_REGISTRY: "ghcr.io" | |
| DOCKER_USERNAME: "elie222" | |
| env: | |
| DOCKER_IMAGE_REGISTRY: "ghcr.io" | |
| DOCKER_USERNAME: "${{ github.repository_owner }}" |
|
Thanks! |
|
@gowthamkishore3799 bug: #433 |
|
I think this doesn't run the DB migration on startup like the previous dev image did, so doesn't work for self hosts easily. |
|
Hey, don't think I changed anything here? Do you want to make an additional PR to add the changes in you want? |
This PR adds Docker support for the apps/web application and a GitHub Actions workflow to automatically build and publish images to GHCR.
Changes:
.github/workflows/build_and_publish_docker.yml: New GitHub Action workflow that:
Triggers on push to main branch.
Builds the image using Dockerfile.prod.
Pushes the tagged image to GHCR.
Note for Maintainers: Please update the images path in this workflow to ghcr.io/${{ github.repository_owner }}/inbox-zero after merging.
Code Changes (apps/web/...): Modified projectid to project123 for build.
Testing & Local Usage:
CI Workflow: Successfully tested in fork (gowthamkishore3799/inbox-zero). Pushing a version tag built and pushed a working image. You can test this specific image: docker pull ghcr.io/gowthamkishore3799/inbox-zero:v1.0.0
Local Build: You can build the image locally using docker build -t inbox-zero-test -f docker/Dockerfile.prod .
Running Pre-Built Image with Docker Compose:
To run the pre-built images from GHCR (after this PR is merged and images are published to the main repo's registry), modify your local docker-compose.yml file:
Comment out or remove the build: section for the web service (if present).
Ensure your local ./apps/web/.env file contains the necessary runtime environment variables.
Run docker compose up -d.
Addresses the request for an official Docker image raised in #389.
Summary by CodeRabbit
New Features
Introduced automated publishing of Docker images to GitHub Container Registry on version tag pushes.
Added a production-ready Dockerfile for optimized and reproducible builds.
Bug Fixes
Improved blog and sitemap build reliability by skipping Sanity data fetches when dummy credentials are detected.
Added a user-facing message when blog post content is unavailable.
Chores
Updated Docker Compose to use a pre-built image from a remote registry.
Summary by CodeRabbit
Chores
Refactor
Bug Fixes