-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.prod
44 lines (37 loc) · 1.23 KB
/
Dockerfile.prod
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
# Creating multi-stage build for production
FROM node:16-alpine as build
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY package.json package-lock.json ./
RUN npm install -g node-gyp
RUN npm config set fetch-retry-maxtimeout 600000 -g && npm install --only=production
ENV PATH /opt/node_modules/.bin:$PATH
WORKDIR /opt/app/src/plugins/lookup
COPY src/plugins/lookup/package.json src/plugins/lookup/package-lock.json ./
RUN npm install
ENV PATH /opt/app/src/plugins/lookup/node_modules/.bin:$PATH
WORKDIR /opt/app
COPY . .
RUN npm run build
# Creating final production image
FROM node:16-alpine
RUN apk add --no-cache vips-dev bash
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY --from=build /opt/node_modules ./node_modules
WORKDIR /opt/app
COPY --from=build /opt/app ./
ENV PATH /opt/node_modules/.bin:$PATH
# change uid of user node inside container
# to the same uid on the host
# RUN usermod --uid 1076 node
# we don't use a bind mount for security reasons
# instead copy into container
COPY ./.env /opt/app
RUN chown -R node:node /opt/app
USER node
EXPOSE 1337
CMD ["npm", "run", "start"]