Commit 5579a51
committed
refactor(docker): slim multi-stage build, drop image size by ~58%
Rework the Dockerfile into a real two-stage build:
- builder stage: python:3.13-slim + build toolchain, installs all
requirements into an isolated venv at /opt/venv
- dev stage: python:3.13-slim with only runtime packages (postgresql-client)
and the interactive tooling the dev shell needs (fish, neovim, less, ack,
iputils-ping), copying the venv from the builder
The build toolchain (build-essential, gcc) no longer ships in the final
image, cutting it from ~1.69GB to ~715MB.
Other fixes:
- drop the stray `aws` package from the install line (junk PyPI package;
boto3 already provides the AWS SDK)
- stop reinstalling ruff via pip -U (it is already pinned in dev.txt)
- switch ADD to COPY for the requirements files
- add apt cache mounts for /var/lib/apt/lists with sharing=locked
- add a .dockerignore to shrink the build context and keep .env/secrets out
Add a .dockerignore covering VCS, Python caches, local databases, env files
and tooling output.1 parent 087dac5 commit 5579a51
2 files changed
Lines changed: 86 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
12 | 27 | | |
13 | | - | |
14 | | - | |
| 28 | + | |
| 29 | + | |
15 | 30 | | |
16 | 31 | | |
17 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
18 | 49 | | |
19 | | - | |
| 50 | + | |
20 | 51 | | |
| 52 | + | |
0 commit comments