1- # Use a Python image with uv pre-installed
21FROM ghcr.io/astral-sh/uv:python3.11-bookworm
32
43# This will be set by the GitHub action to the folder containing this component.
54ARG FOLDER=/app
65
7- COPY -- chown= 1000:1000 . /app
8- WORKDIR ${FOLDER}
6+ RUN mkdir /app && chown 1000:1000 /app
7+ WORKDIR /app
98
10- # Enable bytecode compilation
11- ENV UV_COMPILE_BYTECODE=1
12-
13- # Ensure installed tools can be executed out of the box
14- ENV UV_TOOL_BIN_DIR=/usr/local/bin
15-
16- # Fix uv + non-root environment
17- ENV HOME=/tmp
18- ENV XDG_DATA_HOME=/tmp/.local/share
19- ENV XDG_CACHE_HOME=/tmp/.cache
20-
21- USER root
22- RUN apt-get update && apt-get install -y nodejs npm \
23- && npm install -g nodemon \
24- && rm -rf /var/lib/apt/lists/*
25-
26- # Allow uv to use cache
27- RUN mkdir -p /.cache/uv && chown 1000:1000 /.cache /.cache/uv
9+ ENV PATH="$FOLDER/.venv/bin:$PATH"
10+ ENV PORT=8000
11+ ENV HOST="0.0.0.0"
2812
2913USER 1000:1000
30-
31- # Reset the entrypoint, don't invoke `uv`
32- ENTRYPOINT []
33-
3414EXPOSE 8000
35- ENV PORT=8000
36- ENV HOST="0.0.0.0"
3715
38- CMD ["/usr/local/bin/nodemon", \
39- "--delay", "1", \
40- "--watch", "pyproject.toml", \
41- "--watch", "requirements.txt", \
42- "--watch", ".venv/lib/*", \
43- "--watch", ".venv/lib64/*", \
44- "--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'", \
45- "--"]
16+ CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload", "--reload-dir", "src"]
0 commit comments