plano/demos/getting_started/weather_forecast/Dockerfile

41 lines
893 B
Text
Raw Normal View History

2025-12-26 11:21:42 -08:00
# Blazing fast Python Docker builds with uv
2024-11-07 22:11:00 -06:00
# The builder image, used to build the virtual environment
FROM python:3.14 as builder
2024-11-07 22:11:00 -06:00
2025-12-26 11:21:42 -08:00
# Install uv
RUN pip install --no-cache-dir uv
2024-11-07 22:11:00 -06:00
2025-12-26 11:21:42 -08:00
# Set working directory
2024-11-07 22:11:00 -06:00
WORKDIR /code
2025-12-26 11:21:42 -08:00
# Copy dependency files
COPY pyproject.toml uv.lock ./
2024-11-07 22:11:00 -06:00
RUN touch README.md
2025-12-26 11:21:42 -08:00
# Install dependencies using uv
RUN uv sync --frozen --no-dev
2024-11-07 22:11:00 -06:00
# The runtime image, used to just run the code provided its virtual environment
FROM python:3.14-slim as runtime
2024-11-07 22:11:00 -06:00
RUN apt-get update && apt-get install -y curl
WORKDIR /code
ENV VIRTUAL_ENV=/code/.venv \
PATH="/code/.venv/bin:$PATH"
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY main.py ./
HEALTHCHECK \
--interval=5s \
--timeout=1s \
--start-period=1s \
--retries=3 \
CMD curl http://localhost:80/healthz
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80", "--log-level", "debug"]