From 7c5e7b83c68948ce6dfdc077d4df9e4abd828e16 Mon Sep 17 00:00:00 2001 From: Trezy Date: Fri, 13 Feb 2026 10:43:51 -0600 Subject: [PATCH] feat: add Dockerfile, docker-compose, and CI workflow --- .dockerignore | 7 ++++ .github/workflows/docker.yml | 61 +++++++++++++++++++++++++++++++++++ Dockerfile | 26 +++++++++++++++ docker-compose.yml | 62 ++++++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d034916 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +target/ +tests/ +.git/ +.github/ +.claude/ +.env +docker-compose*.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..058c270 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,61 @@ +name: Build and Publish Docker Image + +on: + push: + branches: [main] + tags: ["v*"] + +env: + IMAGE_NAME: happyview + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - uses: docker/setup-qemu-action@v3 + + - uses: docker/setup-buildx-action@v3 + + - name: Log in to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in to atcr + if: vars.ATCR_REGISTRY != '' + uses: docker/login-action@v3 + with: + registry: ${{ vars.ATCR_REGISTRY }} + username: ${{ secrets.ATCR_USERNAME }} + password: ${{ secrets.ATCR_PASSWORD }} + + - name: Generate image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} + ${{ vars.ATCR_REGISTRY && format('{0}/{1}', vars.ATCR_REGISTRY, env.IMAGE_NAME) || '' }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=sha,prefix= + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1ee8aa1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM rust:1.93 AS builder + +WORKDIR /app + +COPY Cargo.toml Cargo.lock ./ +COPY src/ src/ +COPY migrations/ migrations/ + +ENV SQLX_OFFLINE=true +RUN cargo build --release + +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -r -s /bin/false happyview + +COPY --from=builder /app/target/release/happyview /usr/local/bin/happyview + +USER happyview + +EXPOSE 3000 + +ENTRYPOINT ["happyview"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d81fc33 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,62 @@ +services: + postgres: + image: postgres:17 + environment: + POSTGRES_USER: happyview + POSTGRES_PASSWORD: happyview + POSTGRES_DB: happyview + ports: + - "5432:5432" + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U happyview"] + interval: 5s + timeout: 3s + retries: 5 + + aip-postgres: + image: postgres:17 + environment: + POSTGRES_USER: aip + POSTGRES_PASSWORD: aip + POSTGRES_DB: aip + volumes: + - aip-pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U aip"] + interval: 5s + timeout: 3s + retries: 5 + + aip: + image: atcr.io/gamesgamesgamesgames.games/aip:latest + ports: + - "8080:8080" + environment: + DATABASE_URL: postgres://aip:aip@aip-postgres/aip + STORAGE_BACKEND: postgres + EXTERNAL_BASE: http://localhost:8080 + DPOP_NONCE_SEED: ${DPOP_NONCE_SEED} + HTTP_PORT: 8080 + depends_on: + aip-postgres: + condition: service_healthy + + happyview: + build: . + ports: + - "3000:3000" + environment: + DATABASE_URL: postgres://happyview:happyview@postgres/happyview + AIP_URL: http://aip:8080 + ADMIN_SECRET: ${ADMIN_SECRET:-dev-secret} + depends_on: + postgres: + condition: service_healthy + aip: + condition: service_started + +volumes: + pgdata: + aip-pgdata: -- 2.51.2