Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Script recalcul calque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ERASME
Script recalcul calque
Commits
6886c716
Commit
6886c716
authored
2 years ago
by
Pierre-Gilles Levallois
Browse files
Options
Downloads
Patches
Plain Diff
Refacto dockerfile
parent
5869b5c7
No related branches found
No related tags found
1 merge request
!6
Fully functional version that calculate layer with all stages
Pipeline
#53987
failed
2 years ago
Stage: Build Calqul
Stage: Deploy Calqul
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Dockerfiles/python/Dockerfile
+44
-78
44 additions, 78 deletions
Dockerfiles/python/Dockerfile
with
44 additions
and
78 deletions
Dockerfiles/python/Dockerfile
+
44
−
78
View file @
6886c716
##################################################################################
# Use an official Python runtime as a parent image
# Taken from https://github.com/Toblerity/Fiona/issues/1063
FROM
python:3.9-slim-buster
##################################################################################
FROM
python:3.8.16-slim-bullseye
# Arguments
ARG
NAMESPACE_ENV
ARG
DB_HOST_ENV
ARG
DB_PORT_ENV
ARG
DB_NAME_ENV
ARG
DB_USER_ENV
# Injecting ARGS in Environnement
ENV
NS_ENV=$NAMESPACE_ENV
ENV
DB_HOST="$DB_HOST_ENV-$NAMESPACE_ENV"
ENV
DB_PORT=$DB_PORT_ENV
ENV
DB_NAME=$DB_NAME_ENV
ENV
DB_USER=$DB_USER_ENV
# Basic libs and install python3.7
RUN
apt-get update
\
&& apt-get install -y apt-utils \
&& apt-get upgrade -y \
&& apt-get install -y procps wget python3-pip gdal-bin libgdal-dev apt-utils git \
&& apt-get clean \
# https://stackoverflow.com/questions/65921476/cant-import-geopandas-to-python-when-running-in-docker-container
# && apt-get -y install proj proj-dev \
&& apt-get -y install gcc python3-dev python3-geopandas \
# https://stackoverflow.com/questions/70508775/error-could-not-build-wheels-for-pycairo-which-is-required-to-install-pyprojec
&& apt-get install -y libcairo2 libcairo2-dev \
# https://stackoverflow.com/questions/18025730/pygobject-2-28-6-wont-configure-no-package-gobject-introspection-1-0-found
&& apt-get install -y libgirepository1.0-dev \
################################# Debug and diagnose tools
#################################
&& apt-get install -qy apt-utils vim iputils-ping net-tools telnet curl \
&& apt-get install -qy postgresql-client \
############################################################################################
&& rm -rf /var/lib/apt/lists/*
# # Install conda
# COPY ./resources/*.sh .
# RUN chmod 755 ./Miniconda3-py38_22.11.1-1-Linux-x86_64.sh \
# # https://github.com/ContinuumIO/anaconda-issues/issues/13110
# && bash ./Miniconda3-py38_22.11.1-1-Linux-x86_64.sh -b
# RUN locate conda
COPY
./scripts/requirements.txt requirements.txt
# Pip
RUN
python3
-m
pip
install
--no-cache-dir
--upgrade
pip
\
# https://github.com/Toblerity/Fiona/issues/1063
&& pip install --no-binary fiona,rasterio fiona rasterio \
# && pip install --no-cache-dir --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version` \
&& pip install --no-cache-dir --ignore-installed PyYAML \
# https://stackoverflow.com/questions/70508775/error-could-not-build-wheels-for-pycairo-which-is-required-to-install-pyprojec
&& pip install --no-cache-dir manimlib \
&& pip install --no-cache-dir manimce \
&& pip install rtree requests python-dotenv numpy pycrypto OWSLib psycopg2-binary \
&& pip install --upgrade shapely geopandas pandas pathos PyGObject pygeos pyproj \
&& pip install --no-cache-dir --upgrade -r requirements.txt
# Add a non root user (OpenShift Requirements)
RUN
addgroup calquluser
&&
\
useradd calquluser -g calquluser --home /app && \
mkdir -p /app && \
mkdir -p /app/logs && \
mkdir -p /app/tmp && \
chown -R calquluser:calquluser /app && \
chmod 777 /app/logs /app/tmp /app
# Set the working directory to /app
WORKDIR
/app
WORKDIR
/app
# Add a non-root user to run the application
RUN
groupadd
-r
calquluser
&&
useradd
--no-log-init
-r
-g
calquluser calquluser
# Copy the current directory contents into the container at /app
COPY
. /app
# Install any needed packages specified in requirements.txt
RUN
apt-get update
&&
\
apt-get
install
-y
--no-install-recommends
\
libgdal-dev
\
pkg-config
\
python3-gi
\
python3-gi-cairo
&&
\
apt-get clean
&&
\
rm
-rf
/var/lib/apt/lists/
*
&&
\
pip
install
--no-cache-dir
--upgrade
pip
&&
\
pip
install
--no-cache-dir
--no-deps
--disable-pip-version-check
-r
requirements.txt
&&
\
rm
-rf
/root/.cache
# Change ownership of the application to the non-root user
RUN
chown
-R
calquluser:calquluser /app
# Switch to the non-root user
USER
calquluser
USER
calquluser
# Add app
# Define the arguments for the Dockerfile
COPY
--chown=calquluser:calquluser ./scripts/*.py ./
ARG
NAMESPACE_ENV
COPY
--chown=calquluser:calquluser ./scripts/*.sh ./
ARG
DB_HOST
COPY
--chown=calquluser:calquluser ./sql ./
ARG
DB_PORT
COPY
--chown=calquluser:calquluser .env ./
ARG
DB_NAME
ARG
DB_USER
# Set the environment variables for the arguments
ENV
NS_ENV=$NS_ENV
ENV
DB_HOST="$DB_HOST_ENV-$NAMESPACE_ENV"
ENV
DB_PORT=$DB_PORT
ENV
DB_NAME=$DB_NAME
ENV
DB_USER=$DB_USER
RUN
chmod
755 ./
*
.sh
# Set the environment variable for PROJ_LIB
ENV
PROJ_LIB=/usr/share/proj/
# Launch calculation
# Run the command to start the Python script
# Documentation : https://stackoverflow.com/questions/40454470/how-can-i-use-a-variable-inside-a-dockerfile-cmd
CMD
["/bin/bash", "-c", "/app/launch.sh $NS_ENV $DB_HOST $DB_PORT $DB_NAME $DB_USER"]
CMD
[ "/bin/sh", "-c", "/app/launch.sh $NS_ENV $DB_HOST $DB_PORT $DB_NAME $DB_USER" ]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment