forked from Automattic/wp-calypso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (53 loc) · 1.85 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
FROM node:8.9.4
LABEL maintainer="Automattic"
WORKDIR /calypso
ENV CONTAINER 'docker'
ENV NODE_PATH=/calypso/server:/calypso/client
# Build a "base" layer
#
# This layer should never change unless env-config.sh
# changes. For local development this should always
# be an empty file and therefore this layer should
# cache well.
#
# env-config.sh
# used by systems to overwrite some defaults
# such as the apt and npm mirrors
COPY ./env-config.sh /tmp/env-config.sh
RUN bash /tmp/env-config.sh
# Build a "dependencies" layer
#
# This layer should include all required npm modules
# and should only change as often as the dependencies
# change. This layer should allow for final build times
# to be limited only by the Calypso build speed.
COPY ./package.json ./npm-shrinkwrap.json /calypso/
RUN true \
&& npm install --production \
&& rm -rf /root/.npm \
&& true
# Build a "source" layer
#
# This layer is populated with up-to-date files from
# Calypso development.
#
# If package.json and npm-shrinkwrap are unchanged,
# `install-if-deps-outdated` should require no action.
# However, time is being spent in the build step on
# `install-if-deps-outdated`. This is because in the
# following COPY, the npm-shrinkwrap mtime is being
# updated, which is confusing `install-if-deps-outdated`.
# Touch after copy to ensure that this layer will
# not trigger additional install as part of the build
# in the following step.
COPY . /calypso/
RUN touch node_modules
# Build the final layer
#
# This contains built environments of Calypso. It will
# change any time any of the Calypso source-code changes.
ARG commit_sha="(unknown)"
ENV COMMIT_SHA $commit_sha
RUN CALYPSO_ENV=production npm run build
USER nobody
CMD NODE_ENV=production node build/bundle.js