This example uses a custom Dockerfile and docker-compose.yml to provide a Python development container with a PostgreSQL service.
It is intended as a starting point for a repository that will contain a FastAPI application with a local PostgreSQL database.
- Python 3.12 on Debian Bookworm slim, built through
Dockerfile - Git, OpenSSH client, and PostgreSQL client tools
- uv for Python dependency management
- Node.js 22 LTS for AI CLI installation
- PostgreSQL 17 in a separate Compose service
- PostgreSQL credentials for local development:
- database:
app - username:
postgres - password:
postgres - host from the app container:
postgres - connection string:
postgresql+asyncpg://postgres:postgres@postgres:5432/app
- database:
- VS Code extensions:
- Codex - OpenAI's coding agent:
openai.chatgpt - Claude Code for VS Code:
Anthropic.claude-code - Python, Pylance, Ruff, and SQLTools PostgreSQL support
- Codex - OpenAI's coding agent:
- CLIs installed by
scripts/post-create.sh:- Codex CLI:
@openai/codex - Claude Code CLI:
@anthropic-ai/claude-code
- Codex CLI:
- Startup database readiness check through
scripts/post-start.sh
devcontainer.json: devcontainer configuration, VS Code customizations, and lifecycle commandsDockerfile: app container image with Python, Node.js, uv, and database client toolsdocker-compose.yml: app container plus PostgreSQL servicescripts/post-create.sh: installs AI CLIs and optionally Python dependencies after the container is createdscripts/post-start.sh: waits for PostgreSQL and verifies the connection
There is no initializeCommand script in this example because no host-side initialization is required.
Copy all files from this folder into a target repository's .devcontainer/ folder, then rebuild or reopen the project in a devcontainer-compatible editor.
The workspace itself is mounted at /workspace. The devcontainer does not create application source code automatically, so it is safe to copy into an existing repository.
For a new project, create the application files after the container starts. Example commands:
uv init
uv add fastapi "uvicorn[standard]" sqlalchemy[asyncio] asyncpg alembicBoth AI CLIs require authentication before use:
codex
claudeThe PostgreSQL service stores data in the named Compose volume postgres-data. Remove that volume if you need to reset the local database.
