-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add Docker build and publish CI for web app #432
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
Changes from all commits
4b25c16
dc0e78c
cd9c10a
5043a90
f7eee5d
7725427
bb30223
983dc0e
edc28a9
c1a1490
19892d4
be5c919
6fb48f0
7af3ad4
2662007
eb320d6
7b57859
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| name: "Build Inbox Zero Docker Image" | ||
| run-name: "Build Inbox Zero Docker Image" | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| paths-ignore: | ||
| - version.txt | ||
|
|
||
| permissions: | ||
| contents: write # Needed to commit version bump and push tags | ||
| packages: write # Needed to push Docker image to GHCR | ||
|
|
||
| env: | ||
| DOCKER_IMAGE_REGISTRY: "ghcr.io" | ||
| DOCKER_USERNAME: "elie222" | ||
|
|
||
| jobs: | ||
| set-version: | ||
| if: github.repository == 'elie222/inbox-zero' | ||
| runs-on: ubuntu-latest | ||
elie222 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| outputs: | ||
| version: ${{ steps.set_version.outputs.version }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4.1.1 | ||
|
|
||
| - name: Set version | ||
| id: set_version | ||
| run: | | ||
| version=$(cat version.txt) | ||
| echo "version=$version" >> $GITHUB_OUTPUT | ||
|
|
||
| build-docker: | ||
| if: github.repository == 'elie222/inbox-zero' | ||
| name: "Build Docker Image" | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - set-version | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Login to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.DOCKER_IMAGE_REGISTRY }} | ||
| username: ${{ env.DOCKER_USERNAME }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
|
|
||
| - name: Build and Push Docker Image | ||
| uses: docker/build-push-action@v4 | ||
| with: | ||
| context: . | ||
| file: docker/Dockerfile.prod | ||
| platforms: linux/arm64, linux/amd64 | ||
| push: true | ||
| cache-from: type=gha | ||
| cache-to: type=gha, mode=max | ||
| tags: | | ||
| ghcr.io/${{ env.DOCKER_USERNAME }}/inbox-zero:latest | ||
| ghcr.io/${{ env.DOCKER_USERNAME }}/inbox-zero:${{ needs.set-version.outputs.version }} | ||
|
|
||
| update_version_txt: | ||
| if: github.repository == 'elie222/inbox-zero' | ||
| needs: | ||
| - set-version | ||
| - build-docker | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4.1.1 | ||
| with: | ||
| ref: main | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Bump version on main branch | ||
| id: update_version | ||
| shell: bash | ||
| run: | | ||
| set -x | ||
| BASE_VERSION=${{ needs.set-version.outputs.version }} | ||
| IFS='.' read -r -a version_parts <<< "$BASE_VERSION" | ||
| for i in {0..2}; do | ||
| version_parts[$i]=${version_parts[$i]:-0} | ||
| done | ||
| version_parts[2]=$((version_parts[2] + 1)) | ||
| new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}" | ||
| echo "$new_version" > version.txt | ||
| echo "new_version=${new_version}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Commit updated version file | ||
| shell: bash | ||
| run: | | ||
| git config --local user.email "github-actions@inboxzero.com" | ||
| git config --local user.name "github-actions" | ||
| git tag -a "${{ needs.set-version.outputs.version }}" -m "Release version ${{ needs.set-version.outputs.version }}" | ||
| git commit -a -m "Bump version from ${{ needs.set-version.outputs.version }} to ${{ steps.update_version.outputs.new_version }}" | ||
| echo "Tagged version ${{ needs.set-version.outputs.version }}. Updated version.txt to ${{ steps.update_version.outputs.new_version }} on main." >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Push changes | ||
| uses: ad-m/github-push-action@v0.8.0 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| branch: ${{ github.ref }} | ||
| force_with_lease: true | ||
| tags: true | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,10 +38,13 @@ services: | |||||
| - inbox-zero-network | ||||||
|
|
||||||
| web: | ||||||
| image: ghcr.io/elie222/inbox-zero:latest | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainUpdate 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: Diff suggestion: - image: ghcr.io/elie222/inbox-zero:latest
+ image: ghcr.io/<ORG_OWNER>/inbox-zero:latestReplace 📝 Committable suggestion
Suggested change
|
||||||
| pull_policy: if_not_present | ||||||
| # The pre-built image will be used by default. For local development, | ||||||
| # use 'docker compose build web' to build from source instead. | ||||||
| build: | ||||||
| context: . | ||||||
| dockerfile: ./docker/Dockerfile.web | ||||||
| # image: ghcr.io/elie222/inbox-zero:latest | ||||||
| dockerfile: ./docker/Dockerfile.prod | ||||||
| env_file: | ||||||
| - ./apps/web/.env | ||||||
| depends_on: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| v1.0.0 |
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
Make the Docker username dynamic
Hard-coding
DOCKER_USERNAME: "elie222"forces a manual update after merging. Switch togithub.repository_ownerso it works in both forks and your main repo without edits:📝 Committable suggestion