1
- FROM python:2.7-slim-stretch
2
-
3
- ENV GOSU_VERSION=1.10 \
4
- NODE_ENV=production \
5
- NODE_VERSION=8.6.0 \
6
- YARN_VERSION=1.1.0
7
-
8
- # Libraries such as matplotlib require a HOME directory for cache and configuration
9
- RUN set -ex \
10
- && mkdir -p /var/www \
11
- && chown www-data:www-data /var/www \
12
- && apt-get update \
13
- && apt-get install -y gnupg2 \
14
- && for key in \
15
- # GOSU
16
- B42F6819007F00F88E364FD4036A9C25BF357DD4 \
17
- # https://github.com/nodejs/docker-node/blob/9c25cbe93f9108fd1e506d14228afe4a3d04108f/8.2/Dockerfile
18
- # gpg keys listed at https://github.com/nodejs/node#release-team
19
- # Node
20
- 9554F04D7259F04124DE6B476D5A82AC7E37093B \
21
- 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
22
- FD3A5288F042B6850C66B31F09FE44734EB7990E \
23
- 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
24
- DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
25
- B9AE9905FFD7803F25714661B63B535A4C206CA9 \
26
- C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
27
- 56730D5401028683275BD23C23EFEFE93C4CFFFE \
28
- # Yarn
29
- 6A010C5166006599AA17F08146C2130DFD2497F5 \
30
- ; do \
31
- gpg --keyserver hkp://ipv4.pool.sks-keyservers.net:80 --recv-keys "$key" || \
32
- gpg --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys "$key" || \
33
- gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" || \
34
- gpg --keyserver hkp://keyserver.pgp.com:80 --recv-keys "$key" \
35
- ; done \
36
- # Install dependancies
37
- && apt-get install -y \
38
- git \
39
- libev4 \
40
- libev-dev \
41
- libevent-dev \
42
- libxml2-dev \
43
- libxslt1-dev \
44
- zlib1g-dev \
45
- curl \
46
- # cryptography
47
- build-essential \
48
- libssl-dev \
49
- libffi-dev \
50
- python-dev \
51
- # postgresql
52
- libpq-dev \
53
- # file audits
54
- par2 \
55
- && ARCH= \
56
- && dpkgArch="$(dpkg --print-architecture)" \
57
- && case "${dpkgArch##*-}" in \
58
- amd64) ARCH='x64' ;; \
59
- ppc64el) ARCH='ppc64le' ;; \
60
- *) echo "unsupported architecture" ; exit 1 ;; \
61
- esac \
62
- # grab gosu for easy step-down from root
63
- && curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
64
- && curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \
65
- && gpg --verify /usr/local/bin/gosu.asc \
66
- && rm /usr/local/bin/gosu.asc \
67
- && chmod +x /usr/local/bin/gosu \
68
- # Node
69
- && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
70
- && curl -SLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
71
- && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
72
- && grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$ " SHASUMS256.txt | sha256sum -c - \
73
- && tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 \
74
- && rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
75
- && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
76
- # Yarn
77
- && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
78
- && curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
79
- && gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
80
- && mkdir -p /opt/yarn \
81
- && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn --strip-components=1 \
82
- && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
83
- && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarnpkg \
84
- && yarn global add bower \
85
- && yarn cache clean \
86
- && rm -rf \
87
- yarn-v$YARN_VERSION.tar.gz.asc \
88
- yarn-v$YARN_VERSION.tar.gz \
89
- $HOME/.gnupg \
90
- $HOME/.cache \
91
- && apt-get remove -y \
92
- curl \
93
- && apt-get clean \
94
- && apt-get autoremove -y \
95
- && rm -rf /var/lib/apt/lists/* \
96
- && mkdir -p /code
1
+ FROM node:8-alpine
2
+
3
+ # Source: https://github.com/docker-library/httpd/blob/7976cabe162268bd5ad2d233d61e340447bfc371/2.4/alpine/Dockerfile#L3
4
+ RUN set -x \
5
+ && addgroup -g 82 -S www-data \
6
+ && adduser -h /var/www -u 82 -D -S -G www-data www-data
7
+
8
+ RUN apk add --no-cache --virtual .run-deps \
9
+ su-exec \
10
+ bash \
11
+ python \
12
+ py-pip \
13
+ git \
14
+ # lxml2
15
+ libxml2 \
16
+ libxslt \
17
+ # psycopg2
18
+ postgresql-libs \
19
+ # cryptography
20
+ libffi \
21
+ # gevent
22
+ libev \
23
+ libevent \
24
+ && yarn global add bower
97
25
98
26
WORKDIR /code
99
27
@@ -118,7 +46,22 @@ COPY ./addons/twofactor/requirements.txt ./addons/twofactor/
118
46
# COPY ./addons/wiki/requirements.txt ./addons/wiki/
119
47
COPY ./addons/zotero/requirements.txt ./addons/zotero/
120
48
121
- RUN for reqs_file in \
49
+ RUN set -ex \
50
+ && mkdir -p /var/www \
51
+ && chown www-data:www-data /var/www \
52
+ && apk add --no-cache --virtual .build-deps \
53
+ build-base \
54
+ linux-headers \
55
+ python-dev \
56
+ # lxml2
57
+ musl-dev \
58
+ libxml2-dev \
59
+ libxslt-dev \
60
+ # psycopg2
61
+ postgresql-dev \
62
+ # cryptography
63
+ libffi-dev \
64
+ && for reqs_file in \
122
65
/code/requirements.txt \
123
66
/code/requirements/release.txt \
124
67
/code/addons/*/requirements.txt \
@@ -128,17 +71,10 @@ RUN for reqs_file in \
128
71
&& (pip uninstall uritemplate.py --yes || true) \
129
72
&& pip install --no-cache-dir uritemplate.py==0.3.0 \
130
73
# Fix: https://github.com/CenterForOpenScience/osf.io/pull/6783
131
- && python -m compileall /usr/local/lib/python2.7 || true
132
-
133
- # OSF: Assets
134
- COPY ./.bowerrc ./bower.json ./
135
- RUN bower install --production --allow-root \
136
- && bower cache clean --allow-root
137
-
138
- COPY ./package.json ./.yarnrc ./yarn.lock ./
139
- RUN yarn install --frozen-lockfile \
140
- && yarn cache clean
74
+ && python -m compileall /usr/lib/python2.7 || true \
75
+ && apk del .build-deps
141
76
77
+ # Settings
142
78
COPY ./tasks/ ./tasks/
143
79
COPY ./website/settings/ ./website/settings/
144
80
COPY ./api/base/settings/ ./api/base/settings/
@@ -148,8 +84,29 @@ RUN mv ./website/settings/local-dist.py ./website/settings/local.py \
148
84
&& mv ./api/base/settings/local-dist.py ./api/base/settings/local.py \
149
85
&& sed 's/DEBUG_MODE = True/DEBUG_MODE = False/' -i ./website/settings/local.py
150
86
87
+ # Bower Assets
88
+ COPY ./.bowerrc ./bower.json ./
89
+ COPY ./admin/.bowerrc ./admin/bower.json ./admin/
90
+ RUN \
91
+ # OSF
92
+ bower install --production --allow-root \
93
+ && bower cache clean --allow-root \
94
+ # Admin
95
+ && cd ./admin \
96
+ && bower install --production --allow-root \
97
+ && bower cache clean --allow-root
98
+
99
+ # Webpack Assets
100
+ #
101
+ # # OSF
102
+ COPY ./package.json ./.yarnrc ./yarn.lock ./
151
103
COPY ./webpack* ./
152
104
COPY ./website/static/ ./website/static/
105
+ # # Admin
106
+ COPY ./admin/package.json ./admin/yarn.lock ./admin/
107
+ COPY ./admin/webpack* ./admin/
108
+ COPY ./admin/static/ ./admin/static/
109
+ # # Addons
153
110
COPY ./addons/bitbucket/static/ ./addons/bitbucket/static/
154
111
COPY ./addons/box/static/ ./addons/box/static/
155
112
COPY ./addons/citations/static/ ./addons/citations/static/
@@ -168,34 +125,29 @@ COPY ./addons/s3/static/ ./addons/s3/static/
168
125
COPY ./addons/twofactor/static/ ./addons/twofactor/static/
169
126
COPY ./addons/wiki/static/ ./addons/wiki/static/
170
127
COPY ./addons/zotero/static/ ./addons/zotero/static/
171
- RUN mkdir -p ./website/static/built/ \
128
+ RUN \
129
+ # OSF
130
+ yarn install --frozen-lockfile \
131
+ && mkdir -p ./website/static/built/ \
172
132
&& invoke build_js_config_files \
173
- && yarn run webpack-prod
174
- # /OSF: Assets
175
-
176
- # Admin: Assets
177
- COPY ./admin/.bowerrc ./admin/bower.json ./admin/
178
- RUN cd ./admin \
179
- && bower install --production --allow-root \
180
- && bower cache clean --allow-root
181
-
182
- COPY ./admin/package.json ./admin/yarn.lock ./admin/
183
- RUN cd ./admin \
133
+ && yarn run webpack-prod \
134
+ # Admin
135
+ && cd ./admin \
184
136
&& yarn install --frozen-lockfile \
185
- && yarn cache clean
186
-
187
- COPY ./admin/webpack* ./admin/
188
- COPY ./admin/static/ ./admin/static/
189
- RUN cd ./admin \
190
- && yarn run webpack-prod
191
- # /Admin: Assets
137
+ && yarn run webpack-prod \
138
+ && cd ../ \
139
+ # Cleanup
140
+ && yarn cache clean \
141
+ && npm cache clean --force
192
142
193
143
# Copy the rest of the code over
194
144
COPY ./ ./
195
145
196
146
ARG GIT_COMMIT=
197
147
ENV GIT_COMMIT ${GIT_COMMIT}
198
148
149
+ # TODO: Admin/API should fully specify their bower static deps, and not include ./website/static in their defaults.py.
150
+ # (this adds an additional 300+mb to the build image)
199
151
RUN for module in \
200
152
api.base.settings \
201
153
admin.base.settings \
@@ -211,4 +163,4 @@ RUN for module in \
211
163
; done \
212
164
&& rm ./website/settings/local.py ./api/base/settings/local.py
213
165
214
- CMD ["gosu " , "nobody" , "invoke" , "--list" ]
166
+ CMD ["su-exec " , "nobody" , "invoke" , "--list" ]
0 commit comments