Skip to content

Commit 1d6f284

Browse files
committed
add Dockerfile to run backend
1 parent fcb2d5c commit 1d6f284

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

clerk_api_demo/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## https://github.com/astral-sh/uv-docker-example/blob/main/standalone.Dockerfile
2+
3+
# Using uv image with explicitly managed python
4+
FROM ghcr.io/astral-sh/uv:bookworm-slim AS builder
5+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
6+
7+
# Configure the Python directory so it is consistent
8+
ENV UV_PYTHON_INSTALL_DIR /python
9+
10+
# Only use the managed Python version
11+
ENV UV_PYTHON_PREFERENCE=only-managed
12+
13+
# Install Python before the project for caching
14+
RUN uv python install 3.13
15+
16+
WORKDIR /app
17+
RUN --mount=type=cache,target=/root/.cache/uv \
18+
--mount=type=bind,source=uv.lock,target=uv.lock \
19+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
20+
uv sync --frozen --no-install-project --no-dev
21+
22+
COPY clerk_api_demo clerk_api_demo
23+
COPY pyproject.toml .
24+
COPY uv.lock .
25+
COPY rxconfig.py .
26+
27+
RUN --mount=type=cache,target=/root/.cache/uv \
28+
uv sync --frozen --no-dev
29+
30+
# Then, use a final image without uv (note this also doesn't include python)
31+
FROM debian:bookworm-slim
32+
33+
# Copy the Python installed in the builder
34+
COPY --from=builder --chown=python:python /python /python
35+
36+
# Copy the application from the builder
37+
COPY --from=builder --chown=app:app /app /app
38+
39+
# Place executables in the environment at the front of the path
40+
ENV PATH="/app/.venv/bin:$PATH"
41+
42+
##########
43+
WORKDIR /app
44+
CMD ["reflex", "run", "--env", "prod", "--backend-only", "--loglevel", "info"]

0 commit comments

Comments
 (0)