From 4d4954910a828886defd79e3f736a3f993e6eaa5 Mon Sep 17 00:00:00 2001 From: listlessbird <124798751+listlessbird@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:35:44 +0530 Subject: [PATCH] chore: add docker image workflow --- .github/workflows/release.yml | 77 +++++++++++++++++++++++++++++++++++ docker-compose.dev.yml | 39 ++++++++++++++++++ docker-compose.yml | 37 +---------------- 3 files changed, 118 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 docker-compose.dev.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c1f573f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,77 @@ +on: + push: + branches: ["release"] + pull_request: + branches: ["release"] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-publish: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'release') }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push renderer + id: push-renderer + uses: docker/build-push-action@v2 + with: + context: . + file: ./renderer/dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push web-app + id: push-web + uses: docker/build-push-action@v2 + with: + context: . + file: ./web/dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation for renderer + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}-renderer + subject-digest: ${{ steps.push-renderer.outputs.digest }} + push-to-registry: true + + - name: Generate artifact attestation for web-app + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}-web + subject-digest: ${{ steps.push-web.outputs.digest }} + push-to-registry: true diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..8de54b5 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,39 @@ +name: sparkles + +services: + web: + image: web-ui + env_file: + - .env + build: + context: ./web + dockerfile: dockerfile + ports: + - "3000:3000" + environment: + - RENDERER_URL=http://renderer:3001 + - NEXT_PUBLIC_BASE_URL=http://web:3000 + - GROQ_API_KEY=${GROQ_API_KEY} + - GEMINI_API_KEY=${GEMINI_API_KEY} + - GOOGLE_API_KEY=${GOOGLE_API_KEY} + - CF_API_KEY=${CF_API_KEY} + - R2_ACCESS_KEY=${R2_ACCESS_KEY} + - R2_SECRET_KEY=${R2_SECRET_KEY} + - CF_ACCOUNT_ID=${CF_ACCOUNT_ID} + - BUCKET_NAME=${BUCKET_NAME} + - ASSEMBLY_API_KEY=${ASSEMBLY_API_KEY} + - REPLICATE_API_KEY=${REPLICATE_API_KEY} + - D1_ID=${D1_ID} + - D1_KEY=${D1_KEY} + - CF_ID=${CF_ID} + + renderer: + image: ai-short-gen-renderer + build: + context: ./renderer + ports: + - "3001:3001" + +networks: + default: + name: app-network diff --git a/docker-compose.yml b/docker-compose.yml index 81ca0f6..3a0725b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,12 +2,9 @@ name: sparkles services: web: - image: web-ui + image: ghcr.io/listlessbird/sparkles-web:latest env_file: - .env - build: - context: ./web - dockerfile: dockerfile ports: - "3000:3000" environment: @@ -28,40 +25,10 @@ services: - CF_ID=${CF_ID} renderer: - image: ai-short-gen-renderer - build: - context: ./renderer + image: ghcr.io/listlessbird/sparkles-renderer:latest ports: - "3001:3001" -# secrets: -# GROQ_API_KEY: -# file: ./secrets/GROQ_API_KEY -# GEMINI_API_KEY: -# file: ./secrets/GEMINI_API_KEY -# GOOGLE_API_KEY: -# file: ./secrets/GOOGLE_API_KEY -# CF_API_KEY: -# file: ./secrets/CF_API_KEY -# R2_ACCESS_KEY: -# file: ./secrets/R2_ACCESS_KEY -# R2_SECRET_KEY: -# file: ./secrets/R2_SECRET_KEY -# CF_ACCOUNT_ID: -# file: ./secrets/CF_ACCOUNT_ID -# BUCKET_NAME: -# file: ./secrets/BUCKET_NAME -# ASSEMBLY_API_KEY: -# file: ./secrets/ASSEMBLY_API_KEY -# REPLICATE_API_KEY: -# file: ./secrets/REPLICATE_API_KEY -# D1_ID: -# file: ./secrets/D1_ID -# D1_KEY: -# file: ./secrets/D1_KEY -# CF_ID: -# file: ./secrets/CF_ID - networks: default: name: app-network