Skip to content

Commit

Permalink
feat: adapt Dockerfile to use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-twhite committed Dec 2, 2024
1 parent 0bec5a8 commit 5c33596
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
26 changes: 14 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
FROM python:3.9-slim
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim

WORKDIR /app

RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*
ENV UV_COMPILE_BYTECODE=1

RUN git clone https://github.com/streamlit/streamlit-example.git .
ENV UV_LINK_MODE=copy

RUN pip3 install -e ".[streamlit]"
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --extra streamlit

EXPOSE 8501
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --extra streamlit

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
ENV PATH="/app/.venv/bin:$PATH"

ENTRYPOINT ["streamlit", "run", "demo_app/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
ENTRYPOINT []

CMD ["python", "-m", "streamlit", "run", "demo_app/demo_app.py", "--server.port=8510", "--server.address=0.0.0.0"]

0 comments on commit 5c33596

Please sign in to comment.