ci: add GitHub Actions workflow to publish Docker image to GHCR and add prod compose
Some checks are pending
Build and Publish Docker Image / Build and Push Docker Image (push) Waiting to run

This commit is contained in:
Murilo Scolari 2026-10-24 04:36:25 -03:00
parent bcc22e9863
commit 272e12ec99
2 changed files with 114 additions and 0 deletions

57
.github/workflows/docker-publish.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: Build and Publish Docker Image
on:
push:
branches:
- main
- feat/simpsync-hardened-backend
tags:
- 'v*.*.*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=latest
type=ref,event=branch
type=sha,format=short
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

57
docker-compose.prod.yml Normal file
View file

@ -0,0 +1,57 @@
services:
server:
image: ghcr.io/muriloscolari/simpsync:latest
container_name: simpsync-server
restart: unless-stopped
read_only: true
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
ports:
- "127.0.0.1:8787:8787"
environment:
- PORT=8787
- POSTGRES_HOST=simpsync-db
- POSTGRES_PORT=5432
- POSTGRES_USER=simpsync
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=simpsync
- AUTH_PEPPER=${AUTH_PEPPER}
- ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true}
- MAX_USERS=${MAX_USERS:-1}
- RATE_LIMIT_RPS=5
- RATE_LIMIT_BURST=10
- CLEANUP_INTERVAL_HOURS=24
depends_on:
simpsync-db:
condition: service_healthy
networks:
- simpsync-net
labels:
- "com.centurylinklabs.watchtower.enable=true"
simpsync-db:
image: postgres:15-alpine
container_name: simpsync-db
restart: unless-stopped
environment:
- POSTGRES_USER=simpsync
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=simpsync
volumes:
- simpsync_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U simpsync"]
interval: 5s
timeout: 5s
retries: 5
networks:
- simpsync-net
networks:
simpsync-net:
driver: bridge
volumes:
simpsync_pgdata: