-
Notifications
You must be signed in to change notification settings - Fork 740
feat: Add Docker build and publish CI for web app #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vishalmakwana111
wants to merge
34
commits into
elie222:main
Choose a base branch
from
vishalmakwana111:feat/docker-publish-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
919b82a
target fork GHCR for testing CI workflow
vishalmakwana111 5d92a4f
Update Dockerfile for production: ignore scripts during dependency in…
vishalmakwana111 95db09d
Add dummy DB URLs to Dockerfile for build-time Prisma schema loading
vishalmakwana111 61bbf73
Refactor Dockerfile for production: run prisma generate during build …
vishalmakwana111 4d20b6f
Add dummy environment variables for build-time in Dockerfile.prod
vishalmakwana111 5314216
Add dummy Redis and QStash environment variables for build-time in Do…
vishalmakwana111 6805597
Add dummy Sanity environment variables for build-time in Dockerfile.prod
vishalmakwana111 eec8f81
Refactor Dockerfile.prod: replace multiple dummy environment variable…
vishalmakwana111 dc31789
Enhance Dockerfile.prod: add comprehensive dummy environment variable…
vishalmakwana111 5842eb2
Update dummy Sanity environment variable format in Dockerfile.prod fo…
vishalmakwana111 3ffb32b
Add dummy Sanity environment variables for build-time in Dockerfile.prod
vishalmakwana111 4d54e72
fix(build): centralize sanity fetch skip for dummy build
vishalmakwana111 fcb4a2f
fix(blog): add dummy build check to generateStaticParams
vishalmakwana111 2de547a
Merge branch 'feat/docker-publish-ci' of https://github.com/vishalmak…
vishalmakwana111 d277431
fix(docker): correct dummy Sanity project ID format in Dockerfile.prod
vishalmakwana111 c1a540b
fix(docker): update dummy Sanity dataset variable format in Dockerfil…
vishalmakwana111 bd16b96
fix(docker): enable no-cache option in Docker publish workflow for im…
vishalmakwana111 36267bf
fix(docker): update dummy Sanity environment variable comments in Doc…
vishalmakwana111 c8eb138
chore(env): remove .env.build file and clean up dummy environment var…
vishalmakwana111 0d3bdef
fix(blog): skip Sanity fetch during build with dummy credentials
vishalmakwana111 e6bd788
chore(deps): add prettier-plugin-tailwindcss to package.json and upda…
vishalmakwana111 c9210c0
chore(docker): switch to pre-built web image in docker-compose.yml an…
vishalmakwana111 840a1af
chore(docker): install pnpm globally in Dockerfile.prod for improved …
vishalmakwana111 3b79018
chore(docker): update image tag to 'latest' in docker-compose.yml and…
vishalmakwana111 afe2633
chore(docker): modify CMD in Dockerfile.prod to use next-server.js fo…
vishalmakwana111 927b74e
chore(docker): add debugging commands in Dockerfile.prod to assist wi…
vishalmakwana111 d9f4c1c
chore(docker): add listing command for next binary in Dockerfile.prod…
vishalmakwana111 441bf27
chore(docker): re-install production dependencies and add debug comma…
vishalmakwana111 d28e9bf
chore(docker): comment out pruning and reinstall commands in Dockerfi…
vishalmakwana111 271660b
chore(docker): simplify Dockerfile.prod by removing unnecessary comme…
vishalmakwana111 374409a
chore(docker): adjust Dockerfile.prod to copy application code before…
vishalmakwana111 7e2bb3a
chore(docker): remove non-root user creation from Dockerfile.prod to …
vishalmakwana111 2b15101
chore(docker): clean up comments in docker-compose.yml and ensure tag…
vishalmakwana111 8118c41
chore(docker): update publish-docker.yml to trigger on main branch pu…
vishalmakwana111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# GitHub Actions workflow for building and publishing Docker images | ||
# See CICD_PLAN.md for details | ||
|
||
name: Publish Docker Image | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' # Trigger on tags like v1.0.0, v1.2.3, etc. | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write # Needed to push to GHCR | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/vishalmakwana111/inbox-zero | ||
tags: | | ||
type=semver,pattern={{version}} # e.g., v1.2.3 | ||
type=semver,pattern={{major}}.{{minor}} # e.g., v1.2 | ||
# type=sha # Optional: Add tag for git SHA | ||
# set latest tag for default branch - this requires triggering on push to main as well | ||
# type=raw,value=latest,enable={{is_default_branch}} | ||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile.prod | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
no-cache: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
FROM node:22-alpine | ||
|
||
WORKDIR /app | ||
|
||
# Install necessary tools | ||
RUN apk add --no-cache openssl | ||
RUN npm install -g pnpm | ||
|
||
# Copy all package manager files first for caching | ||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc* ./ | ||
COPY apps/web/package.json apps/web/ | ||
COPY apps/unsubscriber/package.json apps/unsubscriber/ | ||
COPY apps/mcp-server/package.json apps/mcp-server/ | ||
COPY packages/eslint-config/package.json packages/eslint-config/ | ||
COPY packages/loops/package.json packages/loops/ | ||
COPY packages/resend/package.json packages/resend/ | ||
COPY packages/tinybird/package.json packages/tinybird/ | ||
COPY packages/tinybird-ai-analytics/package.json packages/tinybird-ai-analytics/ | ||
COPY packages/tsconfig/package.json packages/tsconfig/ | ||
|
||
# Copy the rest of the application code FIRST | ||
COPY . . | ||
|
||
# Install ALL dependencies (including dev, no pruning) | ||
# This will now run postinstall scripts *after* source code is copied | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Set NODE_ENV for build and runtime | ||
ENV NODE_ENV=production | ||
|
||
# Provide dummy build-time ENV VARS (Still needed for build) | ||
ENV DATABASE_URL="postgresql://dummy:dummy@dummy:5432/dummy?schema=public" | ||
ENV DIRECT_URL="postgresql://dummy:dummy@dummy:5432/dummy?schema=public" | ||
ENV NEXTAUTH_SECRET="dummy_secret_for_build_only" | ||
ENV NEXTAUTH_URL="http://localhost:3000" | ||
ENV GOOGLE_CLIENT_ID="dummy_id_for_build_only" | ||
ENV GOOGLE_CLIENT_SECRET="dummy_secret_for_build_only" | ||
ENV GOOGLE_ENCRYPT_SECRET="dummy_encrypt_secret_for_build_only" | ||
ENV GOOGLE_ENCRYPT_SALT="dummy_encrypt_salt_for_build_only" | ||
ENV GOOGLE_PUBSUB_TOPIC_NAME="dummy_topic_for_build_only" | ||
ENV GOOGLE_PUBSUB_VERIFICATION_TOKEN="dummy_pubsub_token_for_build" | ||
ENV INTERNAL_API_KEY="dummy_apikey_for_build_only" | ||
ENV API_KEY_SALT="dummy_salt_for_build_only" | ||
ENV UPSTASH_REDIS_URL="http://dummy-redis-for-build:6379" | ||
ENV UPSTASH_REDIS_TOKEN="dummy_redis_token_for_build" | ||
ENV REDIS_URL="redis://dummy:dummy@dummy:6379" | ||
ENV QSTASH_TOKEN="dummy_qstash_token_for_build" | ||
ENV QSTASH_CURRENT_SIGNING_KEY="dummy_qstash_curr_key_for_build" | ||
ENV QSTASH_NEXT_SIGNING_KEY="dummy_qstash_next_key_for_build" | ||
ENV NEXT_PUBLIC_SANITY_PROJECT_ID="dummy-sanity-project-id-for-build" | ||
ENV NEXT_PUBLIC_SANITY_DATASET="dummy-sanity-dataset-for-build" | ||
|
||
# Ensure prisma generate runs | ||
RUN pnpm --filter inbox-zero-ai exec -- prisma generate | ||
|
||
# Build the Next.js application | ||
RUN pnpm --filter inbox-zero-ai exec -- next build | ||
|
||
# Expose port 3000 | ||
EXPOSE 3000 | ||
|
||
# Set the default command to start the production server | ||
# Use the simpler pnpm command, should work now as pnpm & next are installed | ||
CMD pnpm --filter inbox-zero-ai start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"husky": "9.1.7", | ||
"lint-staged": "15.5.1", | ||
"prettier": "3.5.3", | ||
"prettier-plugin-tailwindcss": "0.6.11", | ||
"turbo": "2.5.0" | ||
}, | ||
"packageManager": "[email protected]+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Update Docker image path after merging.
As mentioned in the PR description, the image path should be updated to use the repository owner variable after merging.
📝 Committable suggestion