Skip to content

Commit de02daa

Browse files
committed
Optimize Dockerfile and initContainer
1 parent 9517701 commit de02daa

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

.diploi/helm/app.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ spec:
5252
echo "No dependency definition found" >&2
5353
exit 1
5454
fi && \
55-
echo "Installing uvicorn with uv and linking it to the app's virtual environment" && \
56-
uv pip show --python .venv/bin/python uvicorn >/dev/null 2>&1 || \
57-
uv pip install --python .venv/bin/python uvicorn --link-mode=copy && \
5855
cp --remove-destination "$(readlink /app{{ .Values.folder }}/.venv/bin/python)" /app{{ .Values.folder }}/.venv/bin/python 2>/dev/null || :
5956
workingDir: /app{{ .Values.folder }}
6057
volumeMounts:

Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ ENV UV_LINK_MODE=copy
1616
ENV UV_TOOL_BIN_DIR=/usr/local/bin
1717

1818
COPY . /app
19-
RUN sh -c 'if [ -f requirements.txt ]; then \
19+
20+
RUN if [ -f requirements.txt ]; then \
2021
echo "requirements.txt found, installing dependencies with uv pip" && \
2122
uv venv .venv --clear && \
22-
uv pip install -r requirements.txt && \
23-
uv pip install uvicorn; \
23+
uv pip install -r requirements.txt; \
2424
else \
2525
echo "Using uv sync for dependency installation" && \
26-
uv sync --locked --no-dev && \
27-
uv pip install uvicorn; \
28-
fi'
26+
uv sync --locked --no-dev; \
27+
fi
28+
29+
RUN uv pip show --python .venv/bin/python uvicorn >/dev/null 2>&1 || \
30+
uv pip install --python .venv/bin/python uvicorn --link-mode=copy
2931

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

0 commit comments

Comments
 (0)