This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
production.Dockerfile
68 lines (54 loc) · 2.17 KB
/
production.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
FROM phusion/passenger-nodejs:2.3.1 as builder
# Install prerequisites
# https://docs.docker.com/engine/articles/dockerfile_best-practices/#apt-get
# Base image should also have these already installed: gcc, git, make, python
# - `build-essential` and `make` are required by some Node modules
# - `unzip` & `wget` are required by API docs generator
RUN apt-get -qq update && apt-get -q install -y \
build-essential \
graphicsmagick \
openssl \
unzip \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN npm install -g npm@latest-7
RUN mkdir -p /trustroots
WORKDIR /trustroots
# Copy `package.json` and `package-lock.json` into the container. Then use `npm`
# inside the container to install packages.
# This does several things:
# - Ensures that local changes to your `node_modules/` folder are not copied to
# the container
# - Allows docker to reuse previous build layers if these files do not change
COPY package*.json ./
# This takes FOREVER if it's run in the passenger container, that's why we
# created the multi stage build with a build container first.
RUN npm ci --quiet
# Copy code into the container
COPY .prettierrc.json .eslint* babel.config.* server.js worker.js ./
COPY bin bin
COPY config config
COPY migrations migrations
COPY modules modules
COPY public public
COPY testutils testutils
# Build the app
RUN npm run build
# ------------------------------------------------------------------------------
# Create the production container
# ------------------------------------------------------------------------------
FROM phusion/passenger-nodejs:2.3.1
# Enable nginx in the passenger container
RUN rm -f /etc/service/nginx/down
# Install the production dependencies into the production container
RUN apt-get -qq update && apt-get -q install -y \
graphicsmagick \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /home/app/trustroots
# TODO We should be able to just copy what we actually need from the builder
COPY --chown=app:app --from=builder /trustroots/ ./
COPY deploy/docker/nginx-confd.conf /etc/nginx/conf.d/nginx.conf
COPY deploy/docker/webapp.conf /etc/nginx/sites-enabled/default
CMD ["/sbin/my_init"]