-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.dev
More file actions
45 lines (34 loc) · 1.56 KB
/
Dockerfile.dev
File metadata and controls
45 lines (34 loc) · 1.56 KB
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
41
42
43
44
45
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.11-bookworm
# This will be set by the GitHub action to the folder containing this component.
ARG FOLDER=/app
COPY --chown=1000:1000 . /app
WORKDIR ${FOLDER}
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Ensure installed tools can be executed out of the box
ENV UV_TOOL_BIN_DIR=/usr/local/bin
# Fix uv + non-root environment
ENV HOME=/tmp
ENV XDG_DATA_HOME=/tmp/.local/share
ENV XDG_CACHE_HOME=/tmp/.cache
USER root
RUN apt-get update && apt-get install -y nodejs npm \
&& npm install -g nodemon \
&& rm -rf /var/lib/apt/lists/*
# Allow uv to use cache
RUN mkdir -p /.cache/uv && chown 1000:1000 /.cache /.cache/uv
USER 1000:1000
# Reset the entrypoint, don't invoke `uv`
ENTRYPOINT []
EXPOSE 8000
ENV PORT=8000
ENV HOST="0.0.0.0"
CMD ["/usr/local/bin/nodemon", \
"--delay", "1", \
"--watch", "pyproject.toml", \
"--watch", "requirements.txt", \
"--watch", ".venv/lib/*", \
"--watch", ".venv/lib64/*", \
"--exec", "sh -c 'if [ -f pyproject.toml ]; then uv run --isolated --with . --with uvicorn uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload --reload-dir src --reload-exclude \".venv/**\"; elif [ -f requirements.txt ]; then uv run --isolated --with-requirements requirements.txt --with uvicorn uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload --reload-dir src --reload-exclude \".venv/**\"; else uv run --isolated --with uvicorn uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload --reload-dir src --reload-exclude \".venv/**\"; fi'", \
"--"]