Skip to content

Commit 03285a9

Browse files
committed
✨ feat: modify Dockerfile and split compose.yaml into compose.yaml and compose.override.yaml
1 parent 00854e4 commit 03285a9

File tree

3 files changed

+60
-46
lines changed

3 files changed

+60
-46
lines changed

template/{% if dockerfile %}Dockerfile{% endif %}.jinja

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ RUN --mount=type=cache,target=/root/.cache/uv \
3737
# ---------- production image ----------
3838
FROM python:{{ python_version }}-slim-bookworm AS prod
3939

40+
RUN apt-get update && \
41+
apt-get install -y --no-install-recommends \
42+
build-essential \
43+
curl \
44+
libpq-dev \
45+
gcc && \
46+
rm -rf /var/lib/apt/lists/*
47+
4048
{% if not privileged_container -%}
4149
RUN groupadd -r {{ project_name }} && useradd -r -g {{ project_name }} -M -s /usr/sbin/nologin {{ project_name }}
4250

@@ -48,18 +56,35 @@ WORKDIR /workspaces/{{ project_name }}
4856
# Pull in just the venv (with project code baked into site‑packages)
4957
COPY --from=builder {% if not privileged_container %}--chown={{ project_name }}:{{ project_name }} {% endif %}/workspaces/{{ project_name }}/.venv .venv
5058

59+
COPY {% if not privileged_container %}--chown={{ project_name }}:{{ project_name }} {% endif %}scripts scripts
60+
5161
ENV PATH="/workspaces/{{ project_name }}/.venv/bin:$PATH"
5262

5363
{% if not privileged_container -%}
5464
USER {{ project_name }}
5565
{%- endif %}
5666

57-
# CMD ["uvicorn", "{{ project_slug }}.main:app", "--host", "0.0.0.0", "--port", "8000"]
67+
# HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
68+
# CMD curl -f http://localhost:8085/health || exit 1
69+
70+
# EXPOSE 8085
71+
72+
# CMD ["uvicorn", "{{ project_slug }}.main:app", "--host", "0.0.0.0", "--port", "8085"]
5873
# CMD ["sleep", "1000"]
5974

6075
# ---------- development image ----------
6176
FROM python:{{ python_version }}-slim-bookworm AS dev
6277

78+
RUN apt-get update && \
79+
apt-get install -y --no-install-recommends \
80+
build-essential \
81+
curl \
82+
libpq-dev \
83+
gcc \
84+
git \
85+
vim && \
86+
rm -rf /var/lib/apt/lists/*
87+
6388
{% if not privileged_container -%}
6489
RUN groupadd -g {{ gid }} {{ project_name }} && useradd -m -u {{ uid }} -g {{ gid }} -r {{ project_name }}
6590

@@ -79,4 +104,9 @@ ENV PATH="/workspaces/{{ project_name }}/.venv/bin:$PATH"
79104
USER {{ project_name }}
80105
{%- endif %}
81106

82-
# CMD ["uvicorn", "{{ project_slug }}.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
107+
# HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
108+
# CMD curl -f http://localhost:8085/health || exit 1
109+
110+
# EXPOSE 8085
111+
112+
# CMD ["uvicorn", "{{ project_slug }}.main:app", "--host", "0.0.0.0", "--port", "8085", "--reload"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
services:
2+
{{ project_name }}:
3+
image: {{ project_name }}:0.0.1-devel
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
target: dev
8+
args:
9+
- ENVIRONMENT=dev
10+
ports:
11+
- "8001:8000"
12+
- "8085:8085"
13+
stdin_open: true
14+
tty: true
15+
command: ["sh"]
16+
develop:
17+
watch:
18+
- action: sync
19+
path: .
20+
target: /workspaces/{{ project_name }}
21+
ignore:
22+
- .venv/
23+
{%- if tox %}
24+
- .tox/
25+
{%- endif %}
26+
27+
- action: rebuild
28+
path: ./pyproject.toml

template/{% if dockerfile %}compose.yaml{% endif %}.jinja

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ services:
77
target: prod
88
args:
99
- ENVIRONMENT=prod
10-
ports:
11-
- "8000:8000"
1210
{%- if gpus %}
1311
deploy:
1412
resources:
@@ -18,46 +16,4 @@ services:
1816
count: all
1917
capabilities: [gpu]
2018
{%- endif %}
21-
profiles:
22-
- prod
23-
restart: unless-stopped
24-
25-
{{ project_name }}-dev:
26-
image: {{ project_name }}:0.0.1-devel
27-
build:
28-
context: .
29-
dockerfile: Dockerfile
30-
target: dev
31-
args:
32-
- ENVIRONMENT=dev
33-
ports:
34-
- "8001:8000"
35-
- "8080:8080"
36-
stdin_open: true
37-
tty: true
38-
command: ["sh"]
39-
{%- if gpus %}
40-
deploy:
41-
resources:
42-
reservations:
43-
devices:
44-
- driver: nvidia
45-
count: all
46-
capabilities: [gpu]
47-
{%- endif %}
48-
profiles:
49-
- dev
50-
develop:
51-
watch:
52-
- action: sync
53-
path: .
54-
target: /workspaces/{{ project_name }}
55-
ignore:
56-
- .venv/
57-
{%- if tox %}
58-
- .tox/
59-
{%- endif %}
60-
61-
- action: rebuild
62-
path: ./pyproject.toml
6319
restart: unless-stopped

0 commit comments

Comments
 (0)