Add CI to build/push Docker image, switch compose to pull it
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 36s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 36s
Matches the etsy-finance-tracker pattern: Forgejo Actions builds and pushes the image on every push to main, and docker-compose.yml now pulls that image instead of building from source on the deploy host. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
84c4922bbc
commit
9e39792d49
2 changed files with 45 additions and 1 deletions
44
.forgejo/workflows/docker-build.yml
Normal file
44
.forgejo/workflows/docker-build.yml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: sh
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
# Runner offers ubuntu-latest; the label only selects the runner. The job
|
||||
# overrides the image below with docker:cli and mounts the host socket.
|
||||
runs-on: ubuntu-latest
|
||||
# Run the job in a Docker-CLI container. act_runner already auto-mounts the
|
||||
# host Docker socket (OrbStack), so `docker` reaches the host daemon — don't
|
||||
# mount it again here or Docker errors with "Duplicate mount point".
|
||||
container:
|
||||
image: docker:cli
|
||||
steps:
|
||||
- name: Install git
|
||||
run: apk add --no-cache git
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git config --global --add safe.directory '*'
|
||||
git init -q .
|
||||
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@git.plexultra.com/${{ github.repository }}.git" \
|
||||
|| git remote set-url origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@git.plexultra.com/${{ github.repository }}.git"
|
||||
git fetch --depth 1 origin "${{ github.ref_name }}"
|
||||
git checkout -q -f FETCH_HEAD
|
||||
|
||||
# Uses a Forgejo token with write:package scope (the auto GITHUB_TOKEN
|
||||
# can't write packages — push fails with 'unauthorized: reqPackageAccess')
|
||||
- name: Log in to Forgejo container registry
|
||||
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.plexultra.com -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Build and push image
|
||||
run: |
|
||||
IMAGE=git.plexultra.com/${{ github.repository }}
|
||||
docker build -t "$IMAGE:main" -t "$IMAGE:${{ github.sha }}" .
|
||||
docker push "$IMAGE:main"
|
||||
docker push "$IMAGE:${{ github.sha }}"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
services:
|
||||
power-compare:
|
||||
build: .
|
||||
image: git.plexultra.com/dlawler489/power-compare:main
|
||||
ports:
|
||||
- "8000:8000"
|
||||
env_file:
|
||||
|
|
|
|||
Loading…
Reference in a new issue