Skip to content

armgit / lyftr

Public Imported from GitHub
0

Self-hosted fitness tracker. Log workouts, track nutrition, and monitor progress. Docker deployment, mobile-friendly.

Add GitHub Actions CI/CD pipeline for Docker Hub

Cawlumm4931b290add8
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 0000000..ce1c1b9
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,75 @@
+name: Build & Push to Docker Hub
+
+on:
+ push:
+ branches: [main]
+ tags: ['v*']
+ pull_request:
+ branches: [main]
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version: '1.26'
+ cache-dependency-path: backend/go.sum
+ - run: cd backend && go test ./controllers/ -timeout 30s
+
+ build-backend:
+ needs: test
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: docker/setup-qemu-action@v3
+ - uses: docker/setup-buildx-action@v3
+ - uses: docker/login-action@v3
+ if: github.event_name != 'pull_request'
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ - uses: docker/metadata-action@v5
+ id: meta
+ with:
+ images: cawlumm/lyftr-backend
+ tags: |
+ type=ref,event=tag
+ type=raw,value=latest,enable={{is_default_branch}}
+ - uses: docker/build-push-action@v6
+ with:
+ context: ./backend
+ platforms: linux/amd64,linux/arm64,linux/arm/v7
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ build-frontend:
+ needs: test
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: docker/setup-qemu-action@v3
+ - uses: docker/setup-buildx-action@v3
+ - uses: docker/login-action@v3
+ if: github.event_name != 'pull_request'
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ - uses: docker/metadata-action@v5
+ id: meta
+ with:
+ images: cawlumm/lyftr-frontend
+ tags: |
+ type=ref,event=tag
+ type=raw,value=latest,enable={{is_default_branch}}
+ - uses: docker/build-push-action@v6
+ with:
+ context: ./web
+ platforms: linux/amd64,linux/arm64,linux/arm/v7
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
diff --git a/docker-compose.yml b/docker-compose.yml
index 4c5d041..9d60724 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,6 +2,7 @@ version: '3.8'
services:
backend:
+ image: cawlumm/lyftr-backend:latest
build: ./backend
restart: unless-stopped
volumes:
@@ -22,6 +23,7 @@ services:
retries: 3
frontend:
+ image: cawlumm/lyftr-frontend:latest
build: ./web
restart: unless-stopped
ports: