-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.pb
More file actions
82 lines (66 loc) · 3.1 KB
/
Copy pathDockerfile.pb
File metadata and controls
82 lines (66 loc) · 3.1 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Build instructions:
# CPU: docker build -f Dockerfile.pb --build-arg BUILD_TYPE=cpu -t ramp-fair:cpu .
# GPU: docker build -f Dockerfile.pb --build-arg BUILD_TYPE=gpu -t ramp-fair:gpu .
ARG PY_VER=3.10
ARG TF_VER=2.9.3
ARG BUILD_TYPE=gpu
ARG CUDA_TAG=11.8.0-cudnn8-runtime-ubuntu22.04
# ARG CUDA_DEVEL_TAG=11.8.0-cudnn8-devel-ubuntu22.04
# ==============================================================================
# === CPU base image (minimal) =================================================
FROM python:${PY_VER}-slim-bookworm AS cpu-base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential gcc g++ python3-dev python3-rtree \
gdal-bin libgdal-dev python3-gdal python3-opencv libspatialindex-dev \
&& rm -rf /var/lib/apt/lists/*
# ==============================================================================
# === GPU base image (CUDA + runtime-only Python & GDAL) =======================
FROM nvidia/cuda:${CUDA_TAG} AS gpu-base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 python3-pip build-essential gcc g++ python3-dev python3-rtree python-is-python3 \
gdal-bin libgdal-dev python3-gdal python3-opencv libspatialindex-dev \
&& rm -rf /var/lib/apt/lists/* && \
python3 -m pip install --upgrade pip
# FROM nvidia/cuda:${CUDA_DEVEL_TAG} AS cuda-dev
# ==============================================================================
# === Builder stage (installs everything) ======================================
FROM ${BUILD_TYPE}-base AS builder
ENV DEBIAN_FRONTEND=noninteractive
ARG TF_VER
ARG BUILD_TYPE
COPY docker/pipped-requirements.txt /tmp/pipped-requirements.txt
# Use pip cache and install Python packages (including building GDAL)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir --upgrade pip more-itertools && \
pip install --no-cache-dir tensorflow==${TF_VER} && \
pip install "GDAL==$(gdal-config --version)" && \
pip install --no-cache-dir -r /tmp/pipped-requirements.txt
# Install solaris (local)
COPY solaris /tmp/solaris
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir /tmp/solaris
# Install scikit-fmm
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir scikit-fmm
# Install ramp (local)
COPY setup.py README.md /tmp/ramp-code/
COPY ramp /tmp/ramp-code/ramp
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir /tmp/ramp-code
# ==============================================================================
# === Final minimal runtime image ==============================================
FROM ${BUILD_TYPE}-base AS final
ENV DEBIAN_FRONTEND=noninteractive
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal \
C_INCLUDE_PATH=/usr/include/gdal \
RAMP_HOME=/app
COPY --from=builder /usr/local /usr/local
COPY --from=builder /usr/lib/python*/ /usr/lib/python*/
COPY --from=builder /usr/include/gdal /usr/include/gdal
# COPY --from=cuda-dev /usr/local/cuda/nvvm/libdevice /usr/local/cuda/nvvm/libdevice
WORKDIR /app
CMD ["bash"]