1- # Use a Python image with uv pre-installed
2- FROM ghcr.io/astral-sh/uv:python3.11-bookworm
1+ FROM ghcr.io/astral-sh/uv:bookworm-slim
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
97
10- # Enable bytecode compilation
11- ENV UV_COMPILE_BYTECODE=1
8+ RUN mkdir -p /.cache/uv && chown -R 1000:1000 /.cache
9+ RUN mkdir -p /.local/share/uv/python && chown -R 1000:1000 /.local/share/uv
10+ RUN mkdir -p /.local/bin && chown -R 1000:1000 /.local/bin
1211
13- # Ensure installed tools can be executed out of the box
14- ENV UV_TOOL_BIN_DIR=/usr/local/bin
12+ WORKDIR /app
1513
16- # Place executables in the environment at the front of the path
14+ ENV UV_LINK_MODE=copy
15+ ENV UV_PYTHON_INSTALL_DIR=$FOLDER/.python
1716ENV PATH="$FOLDER/.venv/bin:$PATH"
1817
19- # Fix uv + non-root environment
20- ENV HOME=/tmp
21- ENV XDG_DATA_HOME=/tmp/.local/share
22- ENV XDG_CACHE_HOME=/tmp/.cache
23-
24- USER root
25- RUN apt-get update && apt-get install -y nodejs npm \
26- && npm install -g nodemon \
27- && rm -rf /var/lib/apt/lists/*
28-
29- # Allow uv to use cache
30- RUN mkdir -p /.cache/uv && chown 1000:1000 /.cache /.cache/uv
31-
3218USER 1000:1000
3319
34- EXPOSE 8000
35- ENV PORT=8000
36- ENV HOST="0.0.0.0"
37-
38- ENTRYPOINT ["/usr/local/bin/nodemon"]
39-
40- CMD ["--delay", "1", \
41- "--watch", "pyproject.toml", \
42- "--watch", "requirements.txt", \
43- "--watch", ".venv/lib/*", \
44- "--watch", ".venv/lib64/*", \
45- "--watch", "src", \
46- "--ext", "py", \
47- "--exec", "sh -c 'if [ -f pyproject.toml ]; then uv run --isolated --with . python src/main.py; elif [ -f requirements.txt ]; then uv run --isolated --with-requirements requirements.txt python src/main.py; else uv run --isolated python src/main.py; fi'"]
20+ CMD ["uv", "run", "python", "src/main.py"]
0 commit comments