forked from openclimatefix/solar-consumer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (30 loc) · 984 Bytes
/
Dockerfile
File metadata and controls
40 lines (30 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# --- Dependency builder image --- #
FROM python:3.12-slim-bookworm AS build-deps
# Install build tools
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN apt-get update && apt-get install -y git
# Project configuration
WORKDIR /app
COPY pyproject.toml /app/pyproject.toml
# UV settings
ENV UV_COMPILE_BYTECODE=1 \
UV_NO_CACHE=1 \
UV_LINK_MODE=copy
# Pre-install dependencies
RUN mkdir src && \
uv sync --no-dev --no-install-project --no-editable
# Optional: clean up large test dirs (e.g., pandas)
RUN rm -rf /app/.venv/lib/python3.12/site-packages/**/tests
# --- App builder image --- #
FROM build-deps AS build-app
# Install full project
COPY .git /app/.git
COPY . /app
RUN uv sync --no-dev --no-editable
# --- Final runtime image --- #
FROM python:3.12-slim-bookworm
WORKDIR /app
COPY --from=build-app --chown=app:app /app/.venv /app/.venv
COPY --from=build-app /app /app
# Entrypoint
ENTRYPOINT ["/app/.venv/bin/python", "-m", "solar_consumer.app"]