-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathDockerfile.dev
More file actions
executable file
·163 lines (137 loc) · 5.8 KB
/
Dockerfile.dev
File metadata and controls
executable file
·163 lines (137 loc) · 5.8 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
## Temporary image to build the libraries and only save the needed artifacts
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.8.4 AS builder
WORKDIR /opt/builder
ARG dataDir=/data
ARG projectDir=/foss_fim
ARG depDir=/dependencies
ARG taudemVersion=98137bb6541a0d0077a9c95becfed4e56d0aa0ac
ARG taudemVersion2=81f7a07cdd3721617a30ee4e087804fddbcffa88
ENV taudemDir=$depDir/taudem/bin
ENV taudemDir2=$depDir/taudem_accelerated_flowDirections/taudem/build/bin
## ============================
## Fix APT permission issue
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends apt-utils && \
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
## ============================
## Install dependencies for compilation
RUN apt-get update --fix-missing && \
apt-get install -y --no-install-recommends \
git cmake mpich libmpich-dev libgtest-dev libboost-test-dev libnetcdf-dev make gcc g++ && \
apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
## ============================
## Clone repositories
RUN git clone https://github.com/dtarb/taudem.git
RUN git clone https://github.com/fernandoa123/cybergis-toolkit.git taudem_accelerated_flowDirections
## ============================
## Compile Main taudem repo ##
RUN mkdir -p taudem/bin
RUN cd taudem \
&& git checkout $taudemVersion \
&& cd src \
&& make
## ============================
## Compile taudem repo with accelerated flow directions ##
RUN cd taudem_accelerated_flowDirections/taudem \
&& git checkout $taudemVersion2 \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make
## ============================
## Move needed binaries to the next stage of the image
RUN mkdir -p $taudemDir
RUN mkdir -p $taudemDir2
RUN cd taudem/bin \
&& mv -t $taudemDir flowdircond streamnet gagewatershed catchhydrogeo dinfdistdown
RUN cd taudem_accelerated_flowDirections/taudem/build/bin \
&& mv -t $taudemDir2 d8flowdir dinfflowdir
## ============================
## Fix permissions before copying to final stage
RUN chown -R root:root $depDir && chmod -R 777 $depDir
###############################################################################################
# Base Image that has GDAL, PROJ, etc
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.8.4
ARG dataDir=/data
ENV projectDir=/foss_fim
ARG depDir=/dependencies
ENV inputsDir=$dataDir/inputs
ENV outputsDir=/outputs
ENV srcDir=$projectDir/src
ENV toolsDir=$projectDir/tools
ENV workDir=/fim_temp
ENV taudemDir=$depDir/taudem/bin
ENV taudemDir2=$depDir/taudem_accelerated_flowDirections/taudem/build/bin
## ADDING FIM GROUP ##
ARG GroupID=1370800235
ARG GroupName=fim
RUN addgroup --gid $GroupID $GroupName
ENV GID=$GroupID
ENV GN=$GroupName
## ============================
## Create working directories
RUN mkdir -p $workDir
RUN mkdir -p $depDir
## ============================
## Fix COPY issue
COPY --from=builder $depDir $depDir
RUN chown -R root:root $depDir && chmod -R 777 $depDir
## adding environment variables for numba and python ##
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV PYTHONUNBUFFERED=TRUE
# Set environment variables for stability
ENV PIP_NO_CACHE_DIR=1
ENV PIPENV_VENV_IN_PROJECT=1
ENV PIPENV_NOSPIN=1
## ============================
## Install necessary packages
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update --fix-missing && \
apt-get install -y --no-install-recommends \
p7zip-full python3.10 python3-pip python3-dev time parallel \
mpich libmpich-dev libgeos-dev libgeos-dev \
make gcc g++ expect rsync tzdata wget
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN apt auto-remove
ENV TZ=UTC
# Ensure Python and Pipenv are installed (pipenv version not managed)
RUN python3 -m pip install --no-cache-dir pipenv
# These currently through errors as they are not yet installed
# by this point, but continues with the fresh install. Leaving upgrade error
# in place in case this order of installing changes later.
RUN python3 -m pip install --upgrade pip setuptools wheel
# adding AWS CLI (for bash) ##
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm awscliv2.zip
# ----------------------------------
# Mar 2023 / Sep 2024
# There are some nuances in the whitebox python downloads in that the first time it loads
# it goes to the internet and downloads the latest/greatest WBT (whiteboxtools) engine which is
# required for the whitebox python library to work. We don't want to have FIM attempting a download
# each time a container is opened and the whitebox engine is called.
# Instead we will setup the WBT engine at time of docker build (same as Taudem and AWS).
# Whitebox code detects that the engine it there and makes no attempt to update it.
# We download and unzip it to the same file folder that pip deployed the whitebox library.
# Whitebox also attempts to always download a folder called testdata regardless of use.
# We added an empty folder to fake out whitebox_tools.py so it doesn't try to download the folder
ENV WBT_PATH=/usr/local/lib/python3.10/dist-packages/whitebox/WBT
RUN wget -P $WBT_PATH https://www.whiteboxgeo.com/WBT_Linux/WhiteboxTools_linux_musl.zip && \
unzip -o $WBT_PATH/WhiteboxTools_linux_musl.zip -d $WBT_PATH && \
cp $WBT_PATH/WhiteboxTools_linux_amd64/WBT/whitebox_tools $WBT_PATH
# ----------------------------------
## ADD TO PATHS ##
ENV PATH="$projectDir:${PATH}"
ENV PYTHONPATH="${projectDir}:${srcDir}:${srcDir}/utils:${projectDir}/data:${toolsDir}"
## install python 3 modules ##
COPY Pipfile .
COPY Pipfile.lock .
# Install dependencies into the system path, using the lock file for deterministic builds
RUN pipenv install --deploy --system --ignore-pipfile
# Creates a virtual enviro
# RUN pipenv update --outdated
ADD ./src/entrypoint.sh /
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]