fix: docker build context and validation (#324)

Updates Dockerfile and Fly config to build from the project root context, allowing access to root-level files like README.md. Adds a CI workflow to validate the Docker build on PRs.

authored by zzstoatzz.io and committed by GitHub 8e0235c3 4a13dc4c

+25
.github/workflows/build-docker.yml
··· 1 + name: validate docker build 2 + 3 + on: 4 + pull_request: 5 + paths: 6 + - "backend/src/**" 7 + - "backend/Dockerfile" 8 + - "backend/pyproject.toml" 9 + - "backend/uv.lock" 10 + - "README.md" 11 + - ".github/workflows/build-docker.yml" 12 + 13 + jobs: 14 + build: 15 + name: build backend image 16 + runs-on: ubuntu-latest 17 + steps: 18 + - uses: actions/checkout@v4 19 + 20 + - name: set up docker buildx 21 + uses: docker/setup-buildx-action@v3 22 + 23 + - name: build docker image 24 + # Build from root context using backend/Dockerfile 25 + run: docker build -f backend/Dockerfile .
+1 -2
.github/workflows/deploy-prod.yml
··· 25 25 if [ "${{ steps.changes.outputs.migrations }}" == "true" ]; then 26 26 echo "🔄 migrations detected - will run via release_command before deployment" 27 27 fi 28 - cd backend 29 - flyctl deploy --config fly.toml --remote-only -a relay-api 28 + flyctl deploy --config backend/fly.toml --remote-only -a relay-api 30 29 env: 31 30 FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_PROD }}
+1 -2
.github/workflows/deploy-staging.yml
··· 36 36 if [ "${{ steps.changes.outputs.migrations }}" == "true" ]; then 37 37 echo "🔄 migrations detected - will run via release_command before deployment" 38 38 fi 39 - cd backend 40 - flyctl deploy --config fly.staging.toml --remote-only -a relay-api-staging 39 + flyctl deploy --config backend/fly.staging.toml --remote-only -a relay-api-staging 41 40 env: 42 41 FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STAGING }}
+6 -5
backend/Dockerfile
··· 9 9 WORKDIR /app 10 10 11 11 # install dependencies (separate layer for better caching) 12 - COPY pyproject.toml uv.lock README.md ./ 12 + # COPY paths are relative to the build context (root) 13 + COPY backend/pyproject.toml backend/uv.lock README.md ./ 13 14 RUN --mount=type=cache,target=/root/.cache/uv \ 14 15 uv sync --frozen --no-dev --no-install-project --compile-bytecode 15 16 16 17 # copy application code 17 - COPY src ./src 18 + COPY backend/src ./src 18 19 19 20 # copy alembic migration files 20 - COPY alembic.ini ./ 21 - COPY alembic ./alembic 21 + COPY backend/alembic.ini . 22 + COPY backend/alembic ./alembic 22 23 23 24 # install the project itself with bytecode compilation 24 25 RUN --mount=type=cache,target=/root/.cache/uv \ ··· 28 29 EXPOSE 8000 29 30 30 31 # run the application 31 - CMD ["uv", "run", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"] 32 + CMD ["uv", "run", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
+3 -1
backend/fly.staging.toml
··· 7 7 primary_region = 'iad' 8 8 9 9 [build] 10 + dockerfile = "backend/Dockerfile" 11 + ignore_file = "backend/.dockerignore" 10 12 11 13 [deploy] 12 14 release_command = 'uv run alembic upgrade head' ··· 35 37 [[vm]] 36 38 memory = '1gb' 37 39 cpu_kind = 'shared' 38 - cpus = 1 40 + cpus = 1
+3 -1
backend/fly.toml
··· 2 2 primary_region = 'iad' 3 3 4 4 [build] 5 + dockerfile = "backend/Dockerfile" 6 + ignore_file = "backend/.dockerignore" 5 7 6 8 [deploy] 7 9 release_command = "uv run alembic upgrade head" ··· 38 40 # - AWS_SECRET_ACCESS_KEY 39 41 # - ATPROTO_CLIENT_ID (will be https://api.plyr.fm/client-metadata.json after deployment) 40 42 # - ATPROTO_REDIRECT_URI (will be https://api.plyr.fm/auth/callback after deployment) 41 - # - OAUTH_ENCRYPTION_KEY (44-character base64 Fernet key, generate with: python -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())') 43 + # - OAUTH_ENCRYPTION_KEY (44-character base64 Fernet key, generate with: python -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())')