|
1 | | -# This is an empty README |
| 1 | +# Python DevContainer |
| 2 | + |
| 3 | +Sample Python project using `uv` and an Alpine-based Dev Container. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Multi-stage Docker setup with dedicated `dev_image` and `release` targets |
| 8 | +- Dev Container ready for VS Code (`.devcontainer/devcontainer.json`) |
| 9 | +- Tooling preinstalled in container: `uv`, `ruff`, `ty`, `trivy`, `prek` |
| 10 | +- Simple app entrypoint exposed as `app` |
| 11 | + |
| 12 | +## Project Layout |
| 13 | + |
| 14 | +```text |
| 15 | +. |
| 16 | +├── .devcontainer/ |
| 17 | +├── src/ |
| 18 | +│ └── example/ |
| 19 | +│ ├── __init__.py |
| 20 | +│ └── main.py |
| 21 | +├── tests/ |
| 22 | +├── Dockerfile |
| 23 | +├── pyproject.toml |
| 24 | +└── README.md |
| 25 | +``` |
| 26 | + |
| 27 | +## Requirements |
| 28 | + |
| 29 | +- Docker (for Dev Container workflow) |
| 30 | +- VS Code + Dev Containers extension |
| 31 | +- Optional local workflow: `uv` |
| 32 | + |
| 33 | +## Getting Started |
| 34 | + |
| 35 | +### Option 1: Use the Dev Container (recommended) |
| 36 | + |
| 37 | +1. Open this folder in VS Code. |
| 38 | +2. Run **Dev Containers: Reopen in Container**. |
| 39 | +3. Wait for the image to build and attach. |
| 40 | + |
| 41 | +When attached, dependencies are synced automatically via `postAttachCommand`. |
| 42 | + |
| 43 | +### Option 2: Run locally with `uv` |
| 44 | + |
| 45 | +From the repository root: |
| 46 | + |
| 47 | +```bash |
| 48 | +uv sync |
| 49 | +uv run app |
| 50 | +``` |
| 51 | + |
| 52 | +Expected output: |
| 53 | + |
| 54 | +```text |
| 55 | +Hello World |
| 56 | +``` |
| 57 | + |
| 58 | +## Development Commands |
| 59 | + |
| 60 | +- Run app: `uv run app` |
| 61 | +- Run tests: `uv run pytest` |
| 62 | +- Lint/format check: `uv run ruff check .` |
| 63 | +- Type check: `uv run ty check` |
| 64 | +- Run all pre-commit hooks: `prek run --all-files` |
| 65 | + |
| 66 | +## Docker Build Targets |
| 67 | + |
| 68 | +The `Dockerfile` defines multiple targets: |
| 69 | + |
| 70 | +- `dev_image`: full development environment used by the Dev Container |
| 71 | +- `release`: runtime-oriented image for deployment |
| 72 | + |
| 73 | +Example build: |
| 74 | + |
| 75 | +```bash |
| 76 | +docker build --target dev_image -t python-devcontainer:dev . |
| 77 | +``` |
| 78 | + |
| 79 | +## Entry Point |
| 80 | + |
| 81 | +The script command `app` maps to: |
| 82 | + |
| 83 | +- module: `example.main` |
| 84 | +- function: `entrypoint` |
| 85 | + |
| 86 | +Defined in `pyproject.toml` under `[project.scripts]`. |
| 87 | + |
| 88 | +## License |
| 89 | + |
| 90 | +MIT (see `LICENSE`). |
0 commit comments