Skip to content

Commit

Permalink
chore: add docker image workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
listlessbird committed Nov 6, 2024
1 parent d3aced9 commit ac281d0
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 35 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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 repository
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- 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: Generate metadata for renderer
id: meta-renderer
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-renderer
tags: type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'release') }}

- name: Generate metadata for web-app
id: meta-web
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-web
tags: type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'release') }}

- name: Build and push renderer
id: push-renderer
uses: docker/build-push-action@v2
with:
context: ./renderer
file: ./renderer/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-renderer.outputs.tags }}
labels: ${{ steps.meta-renderer.outputs.labels }}

- name: Build and push web-app
id: push-web
uses: docker/build-push-action@v2
with:
context: ./web
file: ./web/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-web.outputs.tags }}
labels: ${{ steps.meta-web.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

- name: Create GitHub Release
if: success()
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
name: "${{ github.ref_name }}"
body: "Automated release of images for `${{ github.ref_name }}`"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 changes: 39 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 2 additions & 35 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit ac281d0

Please sign in to comment.