Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
**/.env*
**/*.pyc
**/__pycache__/
**/.gitignore
.git
.github
.venv
venv
tests
.pytest_cache
.ruff_cache
*.md
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ci

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- run: uv sync --frozen
- run: uv run ruff format --check app tests
- run: uv run ruff check app tests
- run: uv run pytest -q

docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t tplinkcloud-service .
17 changes: 0 additions & 17 deletions .github/workflows/heroku-app-logs.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/package-publish-heroku.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/package-publish.yml

This file was deleted.

52 changes: 0 additions & 52 deletions .github/workflows/package-python.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: release

on:
push:
tags: ['v*']

permissions:
contents: read

jobs:
# Gate the publish on the same checks as CI so a tag on a broken commit
# can't publish a green image.
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- run: uv sync --frozen
- run: uv run ruff format --check app tests
- run: uv run ruff check app tests
- run: uv run pytest -q

publish:
needs: verify
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
21 changes: 16 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
FROM python:3.9
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder

COPY ./app /app
WORKDIR /srv
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=0
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev
COPY app ./app

WORKDIR /app
FROM python:3.13-slim-bookworm

RUN pip install --no-cache-dir --upgrade -r requirements.txt
WORKDIR /srv
RUN useradd --system --no-create-home appuser
COPY --from=builder /srv/.venv /srv/.venv
COPY app ./app
ENV PATH="/srv/.venv/bin:$PATH"
USER appuser
EXPOSE 8000

CMD gunicorn -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT main:app
# PORT is honored for cloud platforms that inject it; defaults to 8000
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
Loading
Loading