Skip to content

feat(docker): publish ready-to-use iklobato/lightapi image#30

Merged
iklobato merged 1 commit into
masterfrom
feat/docker-image
May 19, 2026
Merged

feat(docker): publish ready-to-use iklobato/lightapi image#30
iklobato merged 1 commit into
masterfrom
feat/docker-image

Conversation

@iklobato
Copy link
Copy Markdown
Owner

Summary

Adds an official Docker image so users can run a fully-functional LightAPI
server by mounting a YAML config — no Python install, no build step.

docker run --rm -p 8000:8000 \
    -v "$(pwd)/lightapi.yaml:/app/lightapi.yaml:ro" \
    -e DATABASE_URL=sqlite:////app/data.db \
    iklobato/lightapi:latest

What ships

  • Dockerfilepython:3.12-slim, installs lightapi[async] + psycopg2-binary, drops to a non-root user. LIGHTAPI_VERSION build arg pins the wheel.
  • docker/entrypoint.py — loads /app/lightapi.yaml (overridable via LIGHTAPI_CONFIG), builds the Starlette app, and starts uvicorn with proxy_headers=True.
  • docker/lightapi.example.yaml — minimal config used as a smoke-test fixture.
  • .github/workflows/docker-publish.yml — multi-arch (linux/amd64, linux/arm64) build that pushes to iklobato/lightapi on master push and on v*.*.* tags.
  • docs/deployment/docker.md — complete rewrite covering quickstart, env vars, docker compose + PostgreSQL, JWT-auth setup, and the publish pipeline.
  • README.md — added a Docker quickstart block.

Verified locally

docker build --build-arg LIGHTAPI_VERSION=0.1.21 -t lightapi:smoke .
docker run -d --rm --name lightapi-smoke -p 18000:8000 \
    -v "$(pwd)/docker/lightapi.example.yaml:/app/lightapi.yaml:ro" \
    -e DATABASE_URL=sqlite:////tmp/data.db lightapi:smoke

All endpoints returned correct responses: empty list → POST creates row → GET returns it with pagination envelope.

Required setup before merge

The workflow needs two repository secrets. Before merging this PR:

gh secret set DOCKERHUB_USERNAME --body "iklobato"
gh secret set DOCKERHUB_TOKEN    --body "<your-dockerhub-access-token>"

The Docker Hub token needs Read, Write, Delete scope on iklobato/lightapi (generate at https://hub.docker.com/settings/security).

Tag schedule

Event Tags pushed
Push of v0.1.22 iklobato/lightapi:0.1.22, :0.1, :latest
Push to master iklobato/lightapi:master
Manual workflow_dispatch iklobato/lightapi:manual-<run-number>

Test plan

  • Local docker build succeeds on darwin/arm64
  • docker run with the example YAML responds 200/201 on documented routes
  • Set DOCKERHUB_USERNAME + DOCKERHUB_TOKEN secrets
  • docker-publish.yml succeeds on master merge
  • docker pull iklobato/lightapi:latest works from an unrelated machine

End-user flow:
  docker run --rm -p 8000:8000 \
      -v ./lightapi.yaml:/app/lightapi.yaml:ro \
      -e DATABASE_URL=sqlite:////app/data.db \
      iklobato/lightapi:latest

What ships:
- Dockerfile (python:3.12-slim base, multi-arch friendly).
  Pre-installs lightapi[async] + psycopg2-binary so both sync PostgreSQL
  and async asyncpg/aiosqlite engines work out of the box. Drops privileges
  to a non-root `lightapi` user. Build arg LIGHTAPI_VERSION pins the wheel
  the workflow installs (kept in sync with pyproject.toml at publish time).
- docker/entrypoint.py: 60-line launcher that locates the YAML at
  /app/lightapi.yaml (overridable via LIGHTAPI_CONFIG), runs
  LightApi.from_config() + build_app(), and starts uvicorn with
  proxy_headers=True so common reverse-proxy headers are respected.
- docker/lightapi.example.yaml: minimal config used as a smoke-test fixture.
- .dockerignore: excludes .git, .venv, tests, docs, examples, site, etc.
- .github/workflows/docker-publish.yml: builds linux/amd64 + linux/arm64
  on master pushes and v*.*.* tag pushes, pushes to iklobato/lightapi
  using DOCKERHUB_USERNAME + DOCKERHUB_TOKEN repo secrets. Tag rules:
    v0.1.21 tag → :0.1.21, :0.1, :latest
    master push → :master
    workflow_dispatch → :manual-<run-number>

Docs:
- README: new Docker quickstart block.
- docs/deployment/docker.md: complete rewrite covering quickstart, env
  vars, SQLite-with-volume, docker compose + PostgreSQL, Redis cache,
  JWT auth with a mounted login_validator module, custom image
  extension pattern, and the publish-pipeline secrets.

Verified locally with docker build + docker run; POST /books, GET
/books, POST /authors, GET /authors all return the expected responses
against the bundled example config.
@iklobato iklobato merged commit 2a32ad8 into master May 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant