forked from MapStory/mapstory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
194 lines (170 loc) · 6.65 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
194
FROM quay.io/mapstory/python-gdal:2.7.x-2.2.x
LABEL maintainer="Tyler Battle <tbattle@boundlessgeo.com>"
ENV MEDIA_ROOT /var/lib/mapstory/media
ENV STATIC_ROOT /var/lib/mapstory/static
ENV APP_PATH /srv/mapstory
ENV TMP /tmp
ENV DJANGO_PORT 8000
ENV PYTHONUNBUFFERED 0
ENV MISSING_THUMBNAIL /static/mapstory/img/missing_thumb.png
WORKDIR $TMP
# Add CA cert for self signing
COPY docker/nginx/ca.crt /usr/local/share/ca-certificates/
COPY docker/nginx/cacerts/Certificates_v5.3_DoD.pem.crt /usr/local/share/ca-certificates/
COPY docker/nginx/cacerts/comodorsacertificationauthority.crt /usr/local/share/ca-certificates/
COPY docker/nginx/cacerts/comodorsadomainvalidationsecureserverca.crt /usr/local/share/ca-certificates/
RUN set -ex \
&& update-ca-certificates
# Install tools
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install WSGI server and python tools
RUN set -ex \
&& pip install --no-cache-dir \
coveralls \
gunicorn \
paver
# Install misc libs
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
libgeos-dev \
libjpeg-dev \
libxml2-dev \
&& rm -rf /var/lib/apt/lists/*
# Install phantomjs
ENV QT_QPA_PLATFORM minimal
RUN set -ex \
&& echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
phantomjs \
&& rm -rf /var/lib/apt/lists/*
# Install Node and related tools
RUN set -ex \
&& curl -sL https://deb.nodesource.com/setup_6.x | /bin/bash - \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
nodejs \
yarn \
&& yarn global add \
bower \
grunt \
gulp-cli \
webpack@^3.10.0 \
&& yarn cache clean \
&& rm -rf /var/lib/apt/lists/*
#RUN mkdir -p $MEDIA_ROOT && chown www-data $MEDIA_ROOT
#RUN mkdir -p $STATIC_ROOT && chown www-data $STATIC_ROOT
# Setup user and paths
RUN set -ex \
&& adduser --disabled-password --gecos '' mapstory \
&& mkdir -p $APP_PATH/deps && chown -R mapstory $APP_PATH \
&& mkdir -p $MEDIA_ROOT && chown mapstory $MEDIA_ROOT \
&& mkdir -p $STATIC_ROOT && chown mapstory $STATIC_ROOT
WORKDIR $APP_PATH
RUN pip install celery==4.1.0
# Clone submodules temporarily. They're needed for the install.
# These will be overwrriten when we load the code volume.
# We don't use COPY because it will force rebuilds on any changes.
#USER mapstory
WORKDIR $APP_PATH/deps
RUN set -ex \
&& git clone -b mapstory-2.8.0 --depth 1 https://github.com/MapStory/geonode.git \
&& sed -i 's/Paver==1.2.1/Paver==1.2.4/' ./geonode/setup.py \
&& pip install -e ./geonode \
&& git clone -b feature/composer-wip --depth 1 https://github.com/MapStory/maploom.git \
&& git clone -b composer --depth 1 https://github.com/MapStory/django-maploom.git \
&& pip install -e ./django-maploom \
&& git clone -b master --depth 1 https://github.com/pinax/django-mailer.git \
&& pip install -e ./django-mailer \
&& git clone -b master --depth 1 https://github.com/MapStory/icon-commons.git \
&& pip install -e ./icon-commons \
&& git clone -b angular-1.6 --depth 1 https://github.com/GeoNode/django-osgeo-importer.git \
&& pip install -e ./django-osgeo-importer \
&& git clone -b master --depth 1 https://github.com/MapStory/story-tools.git \
&& git clone -b master --depth 1 https://github.com/MapStory/story-tools-composer.git \
&& chown -R mapstory:mapstory .
# Install dependencies from requirements.txt
WORKDIR $APP_PATH
COPY requirements.txt ./
#USER root
RUN pip install --no-cache-dir -r requirements.txt
COPY epsg_extra /usr/local/lib/python2.7/dist-packages/pyproj/data/
# The httplib2 python library uses its own CA certificates.
# Add the system and self-signed CAs.
RUN cat /etc/ssl/certs/ca-certificates.crt >> /usr/local/lib/python2.7/site-packages/httplib2/cacerts.txt
# Override the version of awesome-slugify
# Using HEAD as of 2018-01-09
# The version isn't changed, so it has trouble differentiation from the version in pypy. Thus this manual update.
RUN pip install --no-cache-dir -U git+git://github.com/dimka665/awesome-slugify@a6563949965bcddd976b7b3fb0babf76e3b490f7#egg=awesome-slugify
# Cache these. Hopefully it will speed up the later steps.
COPY --chown=mapstory:mapstory mapstory/static $APP_PATH/mapstory/static
WORKDIR $APP_PATH/mapstory/static
RUN chown -R mapstory:mapstory .
USER mapstory
RUN set -ex \
&& yarn install \
&& yarn cache clean \
&& bower install \
&& rm -rf ~/.cache/bower
WORKDIR $APP_PATH/deps/story-tools-composer
RUN set -ex \
&& yarn install \
&& webpack --output-public-path='/static/composer/' \
&& cp -r . $APP_PATH/mapstory/static/composer \
&& yarn cache clean \
&& rm -rf /tmp/phantomjs
USER root
WORKDIR $APP_PATH
# Copy in dependencies
COPY --chown=mapstory:mapstory deps ./deps
# Copy in the code
COPY --chown=mapstory:mapstory mapstory ./mapstory
COPY --chown=mapstory:mapstory ./*.py ./
RUN chown -R mapstory:mapstory $APP_PATH
USER mapstory
WORKDIR $APP_PATH/mapstory/static
RUN set -ex \
&& yarn install \
&& bower install \
&& grunt concat \
&& grunt less:development \
&& grunt copy:development \
&& yarn cache clean \
&& rm -rf ~/.cache/bower \
&& rm -rf /tmp/phantomjs
WORKDIR $APP_PATH/deps/story-tools-composer
RUN set -ex \
&& ./scripts/run.sh --bundle \
&& mkdir /tmp/story-tools-composer/ \
&& mv ./node_modules /tmp/story-tools-composer/ \
&& mkdir /tmp/story-tools/ \
&& mv ./deps/story-tools/node_modules /tmp/story-tools/ \
&& rm -rf $APP_PATH/mapstory/static/composer \
&& cp -r . $APP_PATH/mapstory/static/composer \
&& yarn cache clean \
&& rm -rf /tmp/phantomjs
USER root
RUN set -ex \
&& chown -R mapstory:mapstory $STATIC_ROOT \
&& chown -R mapstory:mapstory $MEDIA_ROOT \
&& mkdir -p $APP_PATH/cover \
&& chown -R mapstory:mapstory $APP_PATH/cover \
&& mkdir -p /usr/local/lib/python2.7/site-packages-copy \
&& chown -R mapstory:mapstory /usr/local/lib/python2.7/site-packages-copy
COPY --chown=mapstory:mapstory docker/django/run.sh $APP_PATH/docker/django/
RUN ln -s $APP_PATH/docker/django/run.sh /opt/run.sh
USER mapstory
VOLUME $STATIC_ROOT
VOLUME $MEDIA_ROOT
VOLUME $APP_PATH/cover
WORKDIR $APP_PATH
EXPOSE $DJANGO_PORT
ENTRYPOINT ["/opt/run.sh"]
CMD ["--collect-static", "--init-db", "--reindex", "--serve"]