Skip to content

Commit 6c5cd19

Browse files
committed
Merge branch 'feat-dockerfile-pip' into 'master'
feat: build Dockerfile with python -m build and pip See merge request 3d/cars-park/cars!839
2 parents 5b7363a + 8c98552 commit 6c5cd19

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

Dockerfile

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,30 @@ LABEL maintainer="CNES"
44

55
# Dependencies packages
66
# hadolint ignore=DL3008
7-
RUN apt-get update && apt-get install --no-install-recommends software-properties-common -y && add-apt-repository ppa:deadsnakes/ppa && rm -rf /var/lib/apt/lists/*
7+
RUN apt-get update \
8+
&& apt-get install --no-install-recommends software-properties-common -y \
9+
&& add-apt-repository ppa:deadsnakes/ppa && rm -rf /var/lib/apt/lists/*
810

11+
# Python 3.10
912
# hadolint ignore=DL3008
10-
RUN apt-get update && apt-get install --no-install-recommends -y --quiet \
11-
git \
12-
libpython3.10 \
13-
python3.10-dev \
14-
python3.10-venv \
15-
python3.10 \
16-
python3-pip \
17-
python3-numpy \
18-
python3-virtualenv \
13+
RUN apt-get update && apt-get install --no-install-recommends -y --quiet git python3.10-dev \
1914
&& rm -rf /var/lib/apt/lists/*
20-
21-
# copy and install cars with mccnn plugin capabilities installed (but not configured by default)
22-
WORKDIR /app
23-
24-
# Create a virtual environment
25-
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && python3 -m venv /app/venv
26-
27-
# source venv/bin/activate in docker mode
28-
ENV VIRTUAL_ENV='/app/venv'
29-
30-
# Copy only necessary files for installation
31-
COPY . /app/cars
32-
33-
# Install fiona and rasterio with gdal / proj from otb
34-
WORKDIR /app/cars
35-
RUN echo "CARS installation" && CARS_VENV=$VIRTUAL_ENV make clean && CARS_VENV=$VIRTUAL_ENV make install/dev-gdal
36-
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
37-
38-
# hadolint ignore=DL3013,SC2102
39-
RUN python -m pip cache purge
40-
41-
# launch cars
15+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
16+
17+
# Install dependancies
18+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
19+
# hadolint ignore=DL3013
20+
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 \
21+
&& python3 -m pip install --no-cache-dir --upgrade requests \
22+
&& python3 -m pip install --no-cache-dir --no-binary fiona fiona \
23+
&& python3 -m pip install --no-cache-dir --no-binary rasterio rasterio
24+
25+
# Install cars: from source or from pypi if version
26+
ARG version
27+
# hadolint ignore=DL3003,DL3013
28+
RUN if [ -z "$version" ] ; then git clone --depth 1 https://github.com/CNES/cars.git && cd cars && python3 -m pip install --no-cache-dir build && python3 -m build && python3 -m pip install --no-cache-dir dist/*.whl && cd - && rm -rf cars; \
29+
else python3 -m pip install --no-cache-dir cars==$version; fi
30+
31+
# Launch cars
4232
ENTRYPOINT ["cars"]
4333
CMD ["-h"]

0 commit comments

Comments
 (0)