-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile-mapping-support
166 lines (115 loc) · 4.28 KB
/
Dockerfile-mapping-support
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
163
164
165
166
# Dockerfile for an image that has geospatial tools, i.e. GDAL.
# I was unable to get GDAL to work well in the same image with dvmdostem
# and it's associated python scripts. So here is a separate image that has
# GDAL and Python working well together.
ARG UNAME=develop
ARG UID=1000
ARG GID=1000
# need this for netCDF
FROM osgeo/gdal:ubuntu-full-3.2.2
# Might want this if workflow includes running interactive shell on
# the container resulting from this image...
#USER root
#RUN apt-get update
#RUN apt-get install bash-completion
# Make a developer user so as not to always be root
# In order for the resulting container to be able to mount host directories
# as volumes and have read/write access, we must be sure that the new user
# here has the same UID and GID as the user on the machine hosting the
# container. Here we have default values for the UNAME, UID and GID, but
# if you need to you can override them by passing --build-arg to the docker
# build command.
ARG UNAME
ARG UID
ARG GID
RUN groupadd -g $GID -o $UNAME
RUN useradd -m -u$UID -g$GID -s /bin/bash $UNAME
RUN echo "$UNAME ALL=(ALL:ALL) ALL" >> /etc/sudoers
USER $UNAME
# Pyenv dependencies
USER root
RUN apt-get update --fix-missing && apt-get install -y \
build-essential \
curl \
git \
libbz2-dev \
libffi-dev \
liblzma-dev \
libncurses5-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
llvm \
python-openssl \
tk-dev \
wget \
xz-utils \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Pyenv seems to work well for overall python versioning and packagemanagement.
# Not sure how to best manage pip requirements.txt yet between this mapping
# support image and the other dvmdostem images.
USER $UNAME
ENV HOME=/home/$UNAME
RUN git clone https://github.com/pyenv/pyenv.git $HOME/.pyenv
ENV PYENV_ROOT=$HOME/.pyenv
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
RUN pyenv install 3.8.6
RUN pyenv global 3.8.6
RUN pyenv rehash
RUN python --version
RUN pip install -U pip pipenv
RUN pip install setuptools==58
COPY requirements_mapping.txt .
RUN pip install -r requirements_mapping.txt
# Pickup some other general development tools...
USER root
# Various command line netcdf tools
RUN apt-get update -y --fix-missing && apt-get install -y \
nco \
netcdf-bin \
&& rm -rf /var/lib/apt/lists/*
USER $UNAME
# or use this if not wanting to use requirements.txt...
# Bug with ipython 7.19.0, so need to downgrade and pin jedi verison
# https://github.com/ipython/ipython/issues/12740
#RUN pip install matplotlib numpy pandas bokeh netCDF4 commentjson
#RUN pip install ipython
#RUN pip install jedi==0.17.2
# Set a few environemnt variables for ease of use...
ENV PATH="/work:$PATH"
ENV PATH="/work/scripts:$PATH"
ENV PATH="/work/scripts/util:$PATH"
WORKDIR /work
## EXAMPLES
# run bokeh server in scripts directory on container start:
#CMD bokeh serve scripts
# setup to run the container with input catalog attached a volume.
#INCATALOG=/some/path/to/your/catalog
# docker run -it --rm -p 5006:5006 --volume $(pwd):/work --volume $INCATALOG:/data/dvmdostem-input-catalog dvmdostem-mapping-support:0.0.1
## NOTES #
# Dockerfile words:
# RUN - is used to install stuff and setup environment
# CMD - only a single CMD per image, default command when starting container, easily overrridden by docker run
# ENTRYPOINT - the CMD is *always* appended to ENTRYPOINT
#-------------------
# FROM perrygeo/gdal-base:latest as builder
# # Python dependencies that require compilation
# COPY requirements.txt .
# RUN python -m pip install cython numpy -c requirements.txt
# RUN python -m pip install --no-binary fiona,rasterio,shapely -r requirements.txt
# RUN pip uninstall cython --yes
# # ------ Second stage
# # Start from a clean image
# FROM python:3.8-slim-buster as final
# # Install some required runtime libraries from apt
# RUN apt-get update \
# && apt-get install --yes --no-install-recommends \
# libfreexl1 libxml2 libffi-dev\
# && rm -rf /var/lib/apt/lists/*
# # Install the previously-built shared libaries from the builder image
# COPY --from=builder /usr/local/* /usr/local/
# RUN ldconfig -v
#FROM osgeo/gdal:ubuntu-small-latest