From 6d4e5a740f9c7dddf952df6ec37219c688e0934b Mon Sep 17 00:00:00 2001 From: Anshul Sharma Date: Sat, 26 Apr 2025 23:10:10 +0530 Subject: [PATCH 1/5] added ui build step --- .github/workflows/docker_build.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker_build.yaml b/.github/workflows/docker_build.yaml index 4253ec8..a599721 100644 --- a/.github/workflows/docker_build.yaml +++ b/.github/workflows/docker_build.yaml @@ -149,14 +149,16 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository_owner }}/surfsense_backend + images: | + ghcr.io/${{ github.repository_owner }}/surfsense_backend + ghcr.io/${{ github.repository_owner }}/surfsense_ui tags: | # Use the tag generated in the previous job type=raw,value=${{ needs.tag_release.outputs.new_tag }} # Optionally add 'latest' tag if building from the default branch type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event.inputs.branch == github.event.repository.default_branch }} - - name: Build and push Docker image + - name: Build and push Backend Docker image uses: docker/build-push-action@v5 with: context: ./surfsense_backend @@ -166,3 +168,14 @@ jobs: # Optional: Add build cache for faster builds cache-from: type=gha cache-to: type=gha,mode=max + + - name: Build and push UI Docker image + uses: docker/build-push-action@v5 + with: + context: ./surfsense_web + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + # Optional: Add build cache for faster builds + cache-from: type=gha + cache-to: type=gha,mode=max From efd68a6f50c5939aca099639486b76643477f8f4 Mon Sep 17 00:00:00 2001 From: Anshul Sharma Date: Mon, 28 Apr 2025 00:04:20 +0530 Subject: [PATCH 2/5] use different job for each image --- .github/workflows/docker_build.yaml | 38 ++++++++++++++++++++++++++--- docker-compose.yml | 8 ++---- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker_build.yaml b/.github/workflows/docker_build.yaml index a599721..60c153a 100644 --- a/.github/workflows/docker_build.yaml +++ b/.github/workflows/docker_build.yaml @@ -124,7 +124,7 @@ jobs: git ls-remote --tags origin | grep "refs/tags/${{ steps.tag_version.outputs.next_version }}" || (echo "Tag push verification failed!" && exit 1) echo "Tag successfully pushed." - build_and_push_docker_image: + build_and_push_backend_image: runs-on: ubuntu-latest needs: tag_release # Depends on the tag being created successfully permissions: @@ -149,9 +149,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: | - ghcr.io/${{ github.repository_owner }}/surfsense_backend - ghcr.io/${{ github.repository_owner }}/surfsense_ui + images: ghcr.io/${{ github.repository_owner }}/surfsense_backend tags: | # Use the tag generated in the previous job type=raw,value=${{ needs.tag_release.outputs.new_tag }} @@ -169,6 +167,38 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max + build_and_push_ui_image: + runs-on: ubuntu-latest + needs: tag_release # Depends on the tag being created successfully + permissions: + packages: write # Need permission to write to GHCR + contents: read # Need permission to read repo contents (checkout) + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for Docker build + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/surfsense_ui + tags: | + # Use the tag generated in the previous job + type=raw,value=${{ needs.tag_release.outputs.new_tag }} + # Optionally add 'latest' tag if building from the default branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event.inputs.branch == github.event.repository.default_branch }} + - name: Build and push UI Docker image uses: docker/build-push-action@v5 with: diff --git a/docker-compose.yml b/docker-compose.yml index 736400a..71fe7ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,7 @@ version: '3.8' services: frontend: - build: - context: ./surfsense_web - dockerfile: Dockerfile + images: ghcr.io/anshul7665/surfsense_ui:latest ports: - "3000:3000" volumes: @@ -16,9 +14,7 @@ services: - NEXT_PUBLIC_API_URL=http://backend:8000 backend: - build: - context: ./surfsense_backend - dockerfile: Dockerfile + images: ghcr.io/anshul7665/surfsense_backend:latest ports: - "8000:8000" volumes: From 2a6304283a522e6a6ddae250f174bfff4fddc537 Mon Sep 17 00:00:00 2001 From: Anshul Sharma <153057617+anshul7665@users.noreply.github.com> Date: Tue, 3 Jun 2025 11:36:53 +0530 Subject: [PATCH 3/5] use latest released images --- docker-compose.override.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index c971c68..bf66278 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -2,9 +2,7 @@ version: '3.8' services: frontend: - build: - context: ./surfsense_web - dockerfile: Dockerfile + image: docker pull ghcr.io/modsetter/surfsense_backend:latest ports: - "${FRONTEND_PORT:-3000}:3000" volumes: @@ -16,9 +14,7 @@ services: - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://backend:8000} backend: - build: - context: ./surfsense_backend - dockerfile: Dockerfile + image: docker pull ghcr.io/modsetter/surfsense_ui:latest ports: - "${BACKEND_PORT:-8000}:8000" volumes: From 285e0e34350408bc4021724bb077204252af4aef Mon Sep 17 00:00:00 2001 From: Anshul Sharma <153057617+anshul7665@users.noreply.github.com> Date: Wed, 4 Jun 2025 12:45:50 +0530 Subject: [PATCH 4/5] Fixed image urls --- docker-compose.override.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index bf66278..1016c28 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -2,7 +2,7 @@ version: '3.8' services: frontend: - image: docker pull ghcr.io/modsetter/surfsense_backend:latest + image: docker pull ghcr.io/modsetter/surfsense_ui:latest ports: - "${FRONTEND_PORT:-3000}:3000" volumes: @@ -14,7 +14,7 @@ services: - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://backend:8000} backend: - image: docker pull ghcr.io/modsetter/surfsense_ui:latest + image: docker pull ghcr.io/modsetter/surfsense_backend:latest ports: - "${BACKEND_PORT:-8000}:8000" volumes: From 818706558affc3f594f20b020e20056353feed72 Mon Sep 17 00:00:00 2001 From: Anshul Sharma <153057617+anshul7665@users.noreply.github.com> Date: Wed, 4 Jun 2025 12:54:24 +0530 Subject: [PATCH 5/5] reference image only --- docker-compose.override.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 1016c28..3064949 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -2,7 +2,7 @@ version: '3.8' services: frontend: - image: docker pull ghcr.io/modsetter/surfsense_ui:latest + image: ghcr.io/modsetter/surfsense_ui:latest ports: - "${FRONTEND_PORT:-3000}:3000" volumes: @@ -14,7 +14,7 @@ services: - NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://backend:8000} backend: - image: docker pull ghcr.io/modsetter/surfsense_backend:latest + image: ghcr.io/modsetter/surfsense_backend:latest ports: - "${BACKEND_PORT:-8000}:8000" volumes: