Skip to content

Commit 86c630f

Browse files
committed
Set up custom startup command and support requirements.txt
1 parent 39a4220 commit 86c630f

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

.diploi/helm/app.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,19 @@ spec:
4040
imagePullPolicy: Always
4141
command: ["/bin/sh", "-c"]
4242
args:
43-
- |
44-
uv sync --frozen --no-cache --link-mode=copy && \
45-
cp --remove-destination "$(readlink /app{{ .Values.folder }}/.venv/bin/python)" /app{{ .Values.folder }}/.venv/bin/python 2>/dev/null || :
43+
- |
44+
if [ -f pyproject.toml ]; then
45+
echo "Pyproject.toml found, installing dependencies with uv" && \
46+
uv sync --frozen --no-cache --link-mode=copy
47+
elif [ -f requirements.txt ]; then
48+
echo "requirements.txt found, installing dependencies with pip" && \
49+
uv venv .venv --clear && \
50+
uv pip install --python .venv/bin/python -r requirements.txt --link-mode=copy
51+
else
52+
echo "No dependency definition found" >&2
53+
exit 1
54+
fi && \
55+
cp --remove-destination "$(readlink /app{{ .Values.folder }}/.venv/bin/python)" /app{{ .Values.folder }}/.venv/bin/python 2>/dev/null || :
4656
workingDir: /app{{ .Values.folder }}
4757
volumeMounts:
4858
- name: app-mount
@@ -55,7 +65,21 @@ spec:
5565
ports:
5666
- containerPort: 8000
5767
{{- if eq .Values.stage "development" }}
58-
workingDir: /app{{ .Values.folder }}
68+
{{- with .Values.containerCommands.developmentStart }}
69+
command:
70+
- /bin/sh
71+
- -c
72+
- |
73+
{{ . | nindent 14 }}
74+
{{- end }}
75+
{{- else }}
76+
{{- with .Values.containerCommands.productionStart }}
77+
command:
78+
- /bin/sh
79+
- -c
80+
- |
81+
{{ . | nindent 14 }}
82+
{{- end }}
5983
{{- end }}
6084
env:
6185
{{- range .Values.env }}

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ ENV UV_LINK_MODE=copy
1616
ENV UV_TOOL_BIN_DIR=/usr/local/bin
1717

1818
COPY . /app
19-
RUN uv sync --locked --no-dev
19+
20+
RUN if [ -f requirements.txt ]; then \
21+
echo "requirements.txt found, installing dependencies with uv pip" && \
22+
uv venv .venv --clear && \
23+
uv pip install -r requirements.txt; \
24+
else \
25+
echo "Using uv sync for dependency installation" && \
26+
uv sync --locked --no-dev; \
27+
fi
2028

2129
# Place executables in the environment at the front of the path
2230
ENV PATH="$FOLDER/.venv/bin:$PATH"

0 commit comments

Comments
 (0)