feat(docker): publish ready-to-use iklobato/lightapi image#30
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:latestWhat ships
Dockerfile—python:3.12-slim, installslightapi[async]+psycopg2-binary, drops to a non-root user.LIGHTAPI_VERSIONbuild arg pins the wheel.docker/entrypoint.py— loads/app/lightapi.yaml(overridable viaLIGHTAPI_CONFIG), builds the Starlette app, and starts uvicorn withproxy_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 toiklobato/lightapionmasterpush and onv*.*.*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
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:
The Docker Hub token needs Read, Write, Delete scope on
iklobato/lightapi(generate at https://hub.docker.com/settings/security).Tag schedule
v0.1.22iklobato/lightapi:0.1.22,:0.1,:latestmasteriklobato/lightapi:masterworkflow_dispatchiklobato/lightapi:manual-<run-number>Test plan
docker buildsucceeds on darwin/arm64docker runwith the example YAML responds 200/201 on documented routesDOCKERHUB_USERNAME+DOCKERHUB_TOKENsecretsdocker-publish.ymlsucceeds on master mergedocker pull iklobato/lightapi:latestworks from an unrelated machine