|
| 1 | +# Use a Python image with uv pre-installed |
| 2 | +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim |
| 3 | + |
| 4 | +# Install the project into `/app` |
| 5 | +WORKDIR /app |
| 6 | + |
| 7 | +# Enable bytecode compilation |
| 8 | +ENV UV_COMPILE_BYTECODE=1 |
| 9 | + |
| 10 | +# Copy from the cache instead of linking since it's a mounted volume |
| 11 | +ENV UV_LINK_MODE=copy |
| 12 | + |
| 13 | +# Install the project's dependencies using the lockfile and settings |
| 14 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 15 | + --mount=type=bind,source=uv.lock,target=uv.lock \ |
| 16 | + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
| 17 | + uv sync --frozen --no-install-project --extra frontend |
| 18 | + |
| 19 | +# Then, add the rest of the project source code and install it |
| 20 | +# Installing separately from its dependencies allows optimal layer caching |
| 21 | +ADD . /app |
| 22 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 23 | + uv sync --frozen --extra frontend |
| 24 | + |
| 25 | +# Place executables in the environment at the front of the path |
| 26 | +ENV PATH="/app/.venv/bin:$PATH" |
| 27 | + |
| 28 | +# Reset the entrypoint, don't invoke `uv` |
| 29 | +ENTRYPOINT [] |
| 30 | + |
| 31 | +EXPOSE 8501 |
| 32 | + |
| 33 | +# Run the FastAPI application by default |
| 34 | +# Uses `fastapi dev` to enable hot-reloading when the `watch` sync occurs |
| 35 | +# Uses `--host 0.0.0.0` to allow access from outside the container |
| 36 | +ENTRYPOINT ["streamlit", "run", "src/moin_moin/frontend/app.py", "--server.port=8501", "--server.address=0.0.0.0"] |
0 commit comments