forked from ckan/ckan
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
193 lines (147 loc) · 8.44 KB
/
Dockerfile
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#------------------------------------------------------------------------------#
FROM ckan/ckan-base:2.9 as base
#------------------------------------------------------------------------------#
ARG PROJ_VERSION=9.0.0
RUN --mount=type=cache,target=/root/.cache/pip apk add --no-cache .build-deps libc-dev geos geos-dev gdal gdal-dev \
proj proj-util proj-dev gcc g++ libffi-dev musl-dev py3-gdal python3-dev\
libstdc++ build-base \
# Setup build env for PROJ
wget curl unzip make libtool autoconf automake pkgconfig g++ sqlite sqlite-dev \
# For PROJ and GDAL
linux-headers curl-dev tiff-dev zlib-dev zstd-dev lz4-dev libarchive-dev \
libjpeg-turbo-dev libpng-dev libwebp-dev expat-dev postgresql-dev openjpeg-dev \
# For cryptography
gcc musl-dev python3-dev libffi-dev openssl-dev cargo pkgconfig py3-urllib3 py3-cryptography \
&& pip install cryptography \
# Build PROJ
&& mkdir proj \
&& apk add --no-cache cmake \
&& wget -q https://github.com/OSGeo/PROJ/archive/${PROJ_VERSION}.tar.gz -O - \
| tar xz -C proj --strip-components=1 \
&& cd proj \
&& cmake . \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DENABLE_IPO=ON \
-DBUILD_TESTING=OFF \
&& make -j$(nproc) \
&& make install \
&& make install DESTDIR="/build_proj" \
&& cd .. \
&& rm -rf proj \
&& for i in /build_proj/usr/lib/*; do strip -s $i 2>/dev/null || /bin/true; done \
&& for i in /build_proj/usr/bin/*; do strip -s $i 2>/dev/null || /bin/true; done \
&& apk del cmake \
&& pip3 install pyproj==3.6.1 --no-cache-dir \
&& pip3 install gdal==3.4.3 --no-cache-dir \
&& pip3 install ckanapi --no-cache-dir \
&& pip3 install -U requests[security] --no-cache-dir \
# for debugging
&& pip3 install 'flask_debugtoolbar==0.14.1' --no-cache-dir \
# clean up
&& apk del .build-deps
# Define environment variables
ENV APP_DIR=/srv/app
ENV SRC_DIR=/srv/app/src
ENV CKAN_INI=${APP_DIR}/ckan.ini
ENV PIP_SRC=${SRC_DIR}
ENV CKAN_STORAGE_PATH=/var/lib/ckan
# Setup virtual environment for CKAN
RUN ln -s SRC_DIR/ckan/bin/ckan /usr/local/bin/ckan
# Setup CKAN
ADD ./contrib/docker/who.ini $APP_DIR/who.ini
# Copy files to container
ADD ./contrib/docker/production.ini $CKAN_INI
ADD ./contrib/docker/crontab $SRC_DIR/ckan/contrib/docker/crontab
ADD ./contrib/docker/wait-for-postgres.sh /wait-for-postgres.sh
# Set file permissions
RUN chmod +x /wait-for-postgres.sh
# Copy extensions into container and Install
RUN chown -R ckan:ckan $APP_DIR $CKAN_STORAGE_PATH
COPY ./contrib/docker/src/ckanext-dcat/requirements.txt $SRC_DIR/ckanext-dcat/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip cd $SRC_DIR && pip3 install -r ckanext-dcat/requirements.txt
COPY ./contrib/docker/src/ckanext-harvest/requirements.txt $SRC_DIR/ckanext-harvest/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip cd $SRC_DIR && pip3 install -r ckanext-harvest/requirements.txt
COPY ./contrib/docker/src/ckanext-spatial/requirements.txt $SRC_DIR/ckanext-spatial/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip cd $SRC_DIR && pip3 install -r ckanext-spatial/requirements.txt
COPY ./contrib/docker/src/ckanext-cioos_harvest/requirements.txt $SRC_DIR/ckanext-cioos_harvest/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip cd $SRC_DIR && pip3 install -r ckanext-cioos_harvest/requirements.txt
COPY ./contrib/docker/src/ckanext-cioos_theme/requirements.txt $SRC_DIR/ckanext-cioos_theme/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip cd $SRC_DIR && pip3 install -r ckanext-cioos_theme/requirements.txt
#------------------------------------------------------------------------------#
FROM base as extensions1
#------------------------------------------------------------------------------#
WORKDIR $SRC_DIR
COPY ./contrib/docker/src/ckanext-geoview $SRC_DIR/ckanext-geoview
RUN cd $SRC_DIR/ckanext-geoview && python3 setup.py install && python3 setup.py develop
COPY ./contrib/docker/src/ckanext-dcat $SRC_DIR/ckanext-dcat
RUN cd $SRC_DIR/ckanext-dcat && python3 setup.py install && python3 setup.py develop
# included in base image
RUN cd $SRC_DIR/ckanext-envvars && python3 setup.py install && python3 setup.py develop
WORKDIR $SRC_DIR
RUN rm -R ./ckan
WORKDIR /usr/lib/python3.9/site-packages/
RUN find . -maxdepth 1 ! -name 'ckanext*' ! -name '..' ! -name '.' ! -name 'easy-install.pth' | xargs rm -R; mv easy-install.pth easy-install-A.pth
#------------------------------------------------------------------------------#
FROM base as extensions2
#------------------------------------------------------------------------------#
WORKDIR $SRC_DIR
COPY ./contrib/docker/src/ckanext-scheming $SRC_DIR/ckanext-scheming
RUN cd $SRC_DIR/ckanext-scheming && python3 setup.py install && python3 setup.py develop
COPY ./contrib/docker/src/ckanext-fluent $SRC_DIR/ckanext-fluent
RUN cd $SRC_DIR/ckanext-fluent && python3 setup.py install && python3 setup.py develop
COPY ./contrib/docker/src/cioos-siooc-schema/cioos-siooc_schema.json $SRC_DIR/ckanext-scheming/ckanext/scheming/cioos_siooc_schema.json
COPY ./contrib/docker/src/cioos-siooc-schema/organization.json $SRC_DIR/ckanext-scheming/ckanext/scheming/
COPY ./contrib/docker/src/cioos-siooc-schema/ckan_license.json $SRC_DIR/ckanext-scheming/ckanext/scheming/
COPY ./contrib/docker/src/cioos-siooc-schema/group.json $SRC_DIR/ckanext-scheming/ckanext/scheming/
WORKDIR $SRC_DIR
RUN rm -R ./ckan
WORKDIR /usr/lib/python3.9/site-packages/
RUN find . -maxdepth 1 ! -name 'ckanext*' ! -name '..' ! -name '.' ! -name 'easy-install.pth' | xargs rm -R; mv easy-install.pth easy-install-B.pth
#------------------------------------------------------------------------------#
FROM base as harvest_extensions
#------------------------------------------------------------------------------#
WORKDIR $SRC_DIR
COPY ./contrib/docker/src/ckanext-harvest $SRC_DIR/ckanext-harvest
RUN cd $SRC_DIR/ckanext-harvest && python3 setup.py install && python3 setup.py develop
COPY ./contrib/docker/src/ckanext-spatial $SRC_DIR/ckanext-spatial
RUN cd $SRC_DIR/ckanext-spatial && python3 setup.py install && python3 setup.py develop
WORKDIR $SRC_DIR
RUN rm -R ./ckan
WORKDIR /usr/lib/python3.9/site-packages/
RUN find . -maxdepth 1 ! -name 'ckanext*' ! -name '..' ! -name '.' ! -name 'easy-install.pth' | xargs rm -R; mv easy-install.pth easy-install-C.pth
#------------------------------------------------------------------------------#
FROM base as cioos_extensions
#------------------------------------------------------------------------------#
WORKDIR $SRC_DIR
COPY ./contrib/docker/src/ckanext-cioos_harvest $SRC_DIR/ckanext-cioos_harvest
RUN cd $SRC_DIR/ckanext-cioos_harvest && python3 setup.py install && python3 setup.py develop
COPY ./contrib/docker/src/ckanext-cioos_theme $SRC_DIR/ckanext-cioos_theme
RUN cd $SRC_DIR/ckanext-cioos_theme && python3 setup.py --help-commands && python3 setup.py compile_catalog --locale fr && python3 setup.py install && python3 setup.py develop
WORKDIR $SRC_DIR
RUN rm -R ./ckan
WORKDIR /usr/lib/python3.9/site-packages/
RUN find . -maxdepth 1 ! -name 'ckanext*' ! -name '..' ! -name '.' ! -name 'easy-install.pth' | xargs rm -R; mv easy-install.pth easy-install-D.pth
#------------------------------------------------------------------------------#
FROM base
#------------------------------------------------------------------------------#
COPY --from=extensions1 $SRC_DIR/ $SRC_DIR/
COPY --from=extensions1 /usr/lib/python3.9/site-packages/ /usr/lib/python3.9/site-packages/
COPY --from=extensions2 $SRC_DIR/ $SRC_DIR/
COPY --from=extensions2 /usr/lib/python3.9/site-packages/ /usr/lib/python3.9/site-packages/
COPY --from=harvest_extensions $SRC_DIR/ $SRC_DIR/
COPY --from=harvest_extensions /usr/lib/python3.9/site-packages/ /usr/lib/python3.9/site-packages/
COPY --from=cioos_extensions $SRC_DIR/ $SRC_DIR/
COPY --from=cioos_extensions /usr/lib/python3.9/site-packages/ /usr/lib/python3.9/site-packages/
RUN sort -u /usr/lib/python3.9/site-packages/easy-install-[ABCD].pth > /usr/lib/python3.9/site-packages/easy-install.pth
RUN mkdir -p $APP_DIR/logs
RUN touch "$APP_DIR/logs/ckan_access.log"
RUN touch "$APP_DIR/logs/ckan_default.log"
RUN chown -R 92:92 $APP_DIR $CKAN_STORAGE_PATH
WORKDIR $APP_DIR
# ENTRYPOINT ["/ckan-entrypoint.sh"]
USER ckan
EXPOSE 5000
#CMD ["bash", "/wait-for-postgres.sh", "db", "ckan", "-c", "/srv/app/ckan.ini", "run", "--host", "0.0.0.0"]
CMD ["bash", "/wait-for-postgres.sh", "db", "/srv/app/start_ckan.sh"]