Containerized Python web application with Docker Compose, environment-based configuration, Postgres service wiring, and a GitHub Actions workflow that builds and publishes the image to GitHub Container Registry.
- Building a lightweight Python application image with Docker.
- Running a local multi-service stack with Docker Compose.
- Managing application and database settings through environment variables.
- Publishing container images with GitHub Actions and GHCR.
- Keeping local configuration out of source control with
.env.
Browser
|
v
Python HTTP server container
|
v
Postgres container
GitHub push -> GitHub Actions -> Docker build -> GHCR image
.
|-- .github/workflows/docker-push.yml
|-- app.py
|-- docker-compose.yml
|-- Dockerfile
|-- .env.example
|-- .gitignore
`-- README.md
Copy the example environment file:
cp .env.example .envStart the stack:
docker compose up --buildOpen the application:
http://localhost:8000
Stop the stack:
docker compose downRemove volumes when you want a clean database:
docker compose down -v| Variable | Purpose |
|---|---|
APP_PORT |
Port exposed by the Python web application |
APP_MESSAGE |
Message rendered by the application |
POSTGRES_USER |
Local Postgres username |
POSTGRES_PASSWORD |
Local Postgres password |
POSTGRES_DB |
Local Postgres database name |
The GitHub Actions workflow in .github/workflows/docker-push.yml:
- Checks out the repository.
- Sets up Docker Buildx.
- Authenticates to GitHub Container Registry.
- Builds and pushes the container image.
This project shows container basics, local service orchestration, environment configuration, and image publishing. It pairs well with the larger Kubernetes and CI/CD projects in this portfolio.