generated from NodeFactoryIo/node-ts-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
34 lines (20 loc) · 827 Bytes
/
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
FROM node:14.15-alpine as dev
RUN apk update && apk add --no-cache libpq postgresql-dev g++ make python && rm -rf /var/cache/apk/*
WORKDIR /usr/app
# Install node dependencies - done in a separate step so Docker can cache it.
COPY yarn.lock .
COPY package.json .
COPY .env.sample .
RUN yarn install --ignore-scripts --non-interactive --frozen-lockfile && yarn cache clean
COPY . .
RUN yarn run build
FROM node:14.15-alpine as production
RUN apk update && apk add --no-cache libpq postgresql-dev g++ make python && rm -rf /var/cache/apk/*
WORKDIR /app
COPY --from=dev /usr/app/dist /app
COPY --from=dev /usr/app/package.json /app/
COPY --from=dev /usr/app/yarn.lock /app/
RUN chown -R node: .
USER node
RUN yarn install --non-interactive --frozen-lockfile --production && yarn cache clean
CMD ["node", "index.js"]