From 3bc67da34f133cd1d09a753b8cd824e4108d5371 Mon Sep 17 00:00:00 2001 From: Steux Yoann Date: Fri, 3 Jan 2025 08:47:14 +0000 Subject: [PATCH] Fix docker --- Dockerfile | 12 +++++------- Makefile | 8 ++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index adc54b8b..9932b9e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ FROM orfeotoolbox/otb:latest LABEL maintainer="CNES" # Dependencies packages -RUN apt-get update && apt install software-properties-common -y && add-apt-repository ppa:deadsnakes/ppa +# hadolint ignore=DL3008 +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/* # hadolint ignore=DL3008 RUN apt-get update && apt-get install --no-install-recommends -y --quiet \ @@ -20,22 +21,19 @@ RUN apt-get update && apt-get install --no-install-recommends -y --quiet \ # copy and install cars with mccnn plugin capabilities installed (but not configured by default) WORKDIR /app -RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 # Create a virtual environment -RUN python3 -m venv /app/venv +RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 && python3 -m venv /app/venv # source venv/bin/activate in docker mode ENV VIRTUAL_ENV='/app/venv' -ENV PATH="$VIRTUAL_ENV/bin:$PATH" - # Copy only necessary files for installation COPY . /app/cars # Install fiona and rasterio with gdal / proj from otb WORKDIR /app/cars -RUN CARS_VENV=$VIRTUAL_ENV make clean && CARS_VENV=$VIRTUAL_ENV make install-gdal-dev - +RUN echo "CARS installation" && CARS_VENV=$VIRTUAL_ENV make clean && CARS_VENV=$VIRTUAL_ENV make install-gdal-dev +ENV PATH="$VIRTUAL_ENV/bin:$PATH" # hadolint ignore=DL3013,SC2102 RUN python -m pip cache purge diff --git a/Makefile b/Makefile index 178e9258..7da9f173 100644 --- a/Makefile +++ b/Makefile @@ -215,15 +215,15 @@ docker-deps: ## Check and build docker image cnes/cars-deps @docker pull hadolint/hadolint @echo "Check Dockerfile with hadolint" @docker run --rm -i hadolint/hadolint < Dockerfile + @echo "Hadolint ok" .PHONY: docker -docker: docker-deps ## Check and build docker image cnes/cars - @echo "Build Docker main image CARS ${CARS_VERSION_MIN}" +docker: docker-deps ## Check and build docker image cnes/cars # Set docker options like --build-arg ifndef DOCKER_OPTIONS - @docker build -t cnes/cars:${CARS_VERSION_MIN} -t cnes/cars:latest . -f Dockerfile + @docker build -t cnes/cars -t cnes/cars:latest . -f Dockerfile else - @docker build ${DOCKER_OPTIONS} -t cnes/cars:${CARS_VERSION_MIN} -t cnes/cars:latest . -f Dockerfile + @docker build ${DOCKER_OPTIONS} -t cnes/cars -t cnes/cars:latest . -f Dockerfile endif