Skip to content

Commit cdfc2f2

Browse files
pmcfadinclaude
andcommitted
ci: add container release workflow for GHCR
Add GitHub Actions workflow to build and publish container images to ghcr.io/killrvideo/kv-be-python-fastapi-dataapi-table on push to main and version tags. PRs get build-only validation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 76538e2 commit cdfc2f2

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.git
2+
.github
3+
.claude
4+
.venv
5+
.env
6+
.env.*
7+
__pycache__
8+
*.pyc
9+
*.pyo
10+
certs/
11+
data/
12+
logs/
13+
docs/
14+
scripts/
15+
tests/
16+
*.log
17+
.DS_Store
18+
.vscode
19+
VIDEO_DESCRIPTION_FIX.md
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Container Release
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
tags: ["v*"]
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to ghcr.io
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Extract metadata
32+
id: meta
33+
uses: docker/metadata-action@v5
34+
with:
35+
images: ghcr.io/killrvideo/kv-be-python-fastapi-dataapi-table
36+
tags: |
37+
type=sha,prefix=sha-
38+
type=raw,value=latest,enable={{is_default_branch}}
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
type=semver,pattern={{major}}
42+
43+
- name: Build and push
44+
uses: docker/build-push-action@v6
45+
with:
46+
context: .
47+
push: ${{ github.event_name != 'pull_request' }}
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
cache-from: type=gha
51+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM python:3.12-slim AS builder
2+
3+
WORKDIR /app
4+
5+
RUN pip install --no-cache-dir poetry && \
6+
poetry config virtualenvs.in-project true
7+
8+
COPY pyproject.toml poetry.lock ./
9+
RUN poetry install --only main --no-root --no-interaction
10+
11+
COPY README.md ./
12+
COPY app/ app/
13+
RUN poetry install --only main --no-interaction
14+
15+
# ---------------------------------------------------------------------------
16+
17+
FROM python:3.12-slim
18+
19+
WORKDIR /app
20+
21+
COPY --from=builder /app/.venv /app/.venv
22+
COPY --from=builder /app/app /app/app
23+
24+
ENV PATH="/app/.venv/bin:$PATH" \
25+
PYTHONUNBUFFERED=1
26+
27+
EXPOSE 8000
28+
29+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)