Commit ·
0469963
1
Parent(s): ff9549f
Add `Dockerfile`
Browse files- Dockerfile +41 -0
Dockerfile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# An example using multi-stage image builds to create a final image without uv.
|
| 2 |
+
|
| 3 |
+
# First, build the application in the `/app` directory.
|
| 4 |
+
# See `Dockerfile` for details.
|
| 5 |
+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
|
| 6 |
+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
|
| 7 |
+
|
| 8 |
+
# Disable Python downloads, because we want to use the system interpreter
|
| 9 |
+
# across both images. If using a managed Python version, it needs to be
|
| 10 |
+
# copied from the build image into the final image; see `standalone.Dockerfile`
|
| 11 |
+
# for an example.
|
| 12 |
+
ENV UV_PYTHON_DOWNLOADS=0
|
| 13 |
+
|
| 14 |
+
WORKDIR /app
|
| 15 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 16 |
+
--mount=type=bind,source=uv.lock,target=uv.lock \
|
| 17 |
+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
| 18 |
+
uv sync --frozen --no-install-project --no-dev
|
| 19 |
+
ADD . /app
|
| 20 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 21 |
+
uv sync --frozen --no-dev
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# Then, use a final image without uv
|
| 25 |
+
FROM python:3.13-slim-bookworm
|
| 26 |
+
# It is important to use the image that matches the builder, as the path to the
|
| 27 |
+
# Python executable must be the same, e.g., using `python:3.11-slim-bookworm`
|
| 28 |
+
# will fail.
|
| 29 |
+
|
| 30 |
+
WORKDIR /app
|
| 31 |
+
RUN useradd -m -u 1000 app
|
| 32 |
+
|
| 33 |
+
# Copy the application from the builder
|
| 34 |
+
COPY --from=builder --chown=app:app /app /app
|
| 35 |
+
|
| 36 |
+
# Place executables in the environment at the front of the path
|
| 37 |
+
ENV PATH="/app/.venv/bin:$PATH"
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
USER app
|
| 41 |
+
CMD ["marimo", "run", "app.py", "--include-code", "--host", "0.0.0.0", "--port", "7860"]
|