forked from reactioncommerce/reaction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (36 loc) · 1.93 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
##############################################################################
# meteor-dev stage - builds image for dev and used with docker-compose.yml
##############################################################################
FROM reactioncommerce/base:v1.8-meteor as meteor-dev
LABEL maintainer="Reaction Commerce <[email protected]>"
ENV PATH $PATH:/home/node/.meteor
COPY --chown=node package-lock.json $APP_SOURCE_DIR/
COPY --chown=node package.json $APP_SOURCE_DIR/
# Because Docker Compose uses a named volume for node_modules and named volumes are owned
# by root by default, we have to initially create node_modules here with correct owner.
# Without this NPM cannot write packages into node_modules later, when running in a container.
RUN mkdir "$APP_SOURCE_DIR/node_modules" && chown node "$APP_SOURCE_DIR/node_modules"
RUN meteor npm install
COPY --chown=node . $APP_SOURCE_DIR
##############################################################################
# builder stage - builds the production bundle
##############################################################################
FROM meteor-dev as builder
RUN printf "\\n[-] Running Reaction plugin loader...\\n" \
&& reaction plugins load
RUN printf "\\n[-] Building Meteor application...\\n" \
&& meteor build --server-only --architecture os.linux.x86_64 --directory "$APP_BUNDLE_DIR"
WORKDIR $APP_BUNDLE_DIR/bundle/programs/server/
RUN meteor npm install --production
##############################################################################
# final build stage - create the final production image
##############################################################################
FROM node:8.11.4-slim
# Default environment variables
ENV ROOT_URL "http://localhost"
ENV PORT 3000
# grab the dependencies and built app from the previous builder image
COPY --chown=node --from=builder /opt/reaction/dist/bundle /app
WORKDIR /app
EXPOSE 3000
CMD ["node", "main.js"]