+36
Containerfile-alpine
+36
Containerfile-alpine
···
1
+
FROM python:3.12-alpine
2
+
COPY --from=ghcr.io/astral-sh/uv:0.7.12 /uv /uvx /bin/
3
+
4
+
WORKDIR /app
5
+
6
+
# Install build tools & runtime dependencies
7
+
RUN apk add --no-cache \
8
+
ffmpeg \
9
+
file \
10
+
libmagic
11
+
12
+
# Enable bytecode compilation
13
+
ENV UV_COMPILE_BYTECODE=1
14
+
15
+
# Copy from the cache instead of linking since it's a mounted volume
16
+
ENV UV_LINK_MODE=copy
17
+
18
+
# Install the project's dependencies using the lockfile and settings
19
+
RUN --mount=type=cache,target=/root/.cache/uv \
20
+
--mount=type=bind,source=uv.lock,target=uv.lock \
21
+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
22
+
uv sync --locked --no-install-project --no-dev
23
+
24
+
# Define app data volume
25
+
VOLUME /app/data
26
+
27
+
# Then, add the rest of the project source code and install it
28
+
COPY . /app
29
+
RUN --mount=type=cache,target=/root/.cache/uv \
30
+
uv sync --locked --no-dev
31
+
32
+
# Place executables in the environment at the front of the path
33
+
ENV PATH="/app/.venv/bin:$PATH"
34
+
35
+
# Set entrypoint to run the app using uv
36
+
ENTRYPOINT ["uv", "run", "main.py"]