generated from openclimatefix/ocf-template
-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathDockerfile
43 lines (30 loc) · 1.31 KB
/
Dockerfile
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
41
42
43
# --- Use conda to install required binaries into venv --- #
FROM quay.io/condaforge/miniforge3:latest AS build-venv
RUN apt-get update && \
echo "Creating virtualenv at /app/.venv" && \
conda create --quiet --yes -p /app/.venv python=3.12 esmpy gdal hdf5=1.14.4
# --- Build dependencies --- #
FROM python:3.12 AS build-deps
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
COPY --from=build-venv /app/.venv /app/.venv
WORKDIR /app
COPY pyproject.toml /app/pyproject.toml
# Install only requirements
RUN mkdir src && uv sync --no-dev --no-install-project --compile-bytecode --inexact
# --- Build the package --- #
FROM build-deps AS build-app
# Install the app
# * The .git folder is needed here for setuptools-git-versioning
COPY src /app/src
COPY .git /app/.git
RUN uv sync --no-editable --no-dev --compile-bytecode --inexact
# --- Runtime image --- #
FROM python:3.12-slim
# Copy required elements of the builder image
# * This app uses the git binary within the source code, hence coopying it over
COPY --from=build-app /app/.venv /app/.venv
COPY --from=build-app /usr/bin/git /usr/bin/git
# This is just a check to make sure it works, we've had problems with this in the past
ENV PATH="/app/.venv/bin:${PATH}"
RUN /app/.venv/bin/python -c "import torchvision"
ENTRYPOINT ["/app/.venv/bin/pvnet-app"]