-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (47 loc) · 1.55 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
FROM node:9-alpine as build-stage
WORKDIR /app
# install build dependencies
RUN apk add --no-cache \
git
# install application dependencies
COPY package.json yarn.lock ./
RUN JOBS=max yarn install --non-interactive --frozen-lockfile
# copy in application source
COPY . .
# run tests and compile sources
RUN yarn test
# set node env for webpack build
ENV NODE_ENV production
# build webpack bundle
RUN yarn build
# prune modules
RUN yarn install --non-interactive --frozen-lockfile --production
# build and test admin interface
FROM node:9-alpine as admin-stage
COPY admin /app/admin
WORKDIR /app/admin
ENV REACT_APP_SERVER_ADDRESS /admin
RUN JOBS=max yarn install --non-interactive --frozen-lockfile && \
CI=1 yarn test && \
yarn build
# copy built application to runtime image
FROM node:9-alpine
WORKDIR /app
COPY --from=build-stage /app/app.js app.js
COPY --from=build-stage /app/constants.js constants.js
COPY --from=build-stage /app/bad-domains.js bad-domains.js
COPY --from=build-stage /app/bin bin
COPY --from=build-stage /app/countries.json countries.json
COPY --from=build-stage /app/db db
COPY --from=build-stage /app/GeoIP2-Country.mmdb GeoIP2-Country.mmdb
COPY --from=build-stage /app/helpers helpers
COPY --from=build-stage /app/node_modules node_modules
COPY --from=build-stage /app/public public
COPY --from=build-stage /app/routes routes
COPY --from=build-stage /app/src src
COPY --from=build-stage /app/views views
COPY --from=admin-stage /app/admin/build public/admin
# run on port 3001
ENV NODE_ENV production
ENV PORT 3001
CMD [ "node", "bin/www" ]