-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
58 lines (40 loc) · 1.13 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
ARG NODE_VERSION=18-alpine
ARG PROJECT=ekorre
ARG WORKING_DIR=/srv/app
##
## Build
##
FROM node:${NODE_VERSION} as BUILD_IMAGE
# Make arg available
ARG WORKING_DIR
# Create app directory
WORKDIR $WORKING_DIR
RUN apk add --no-cache openssl
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm ci
# Bundle app source
COPY . .
RUN npm run prisma:generate
RUN npm run build
RUN npm prune --omit=dev
RUN mkdir public
##
## Create runtime image
##
FROM node:${NODE_VERSION}
ARG WORKING_DIR
ARG PROJECT
ENV NODE_ENV=production
WORKDIR $WORKING_DIR
# Best practices
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md
RUN apk add --no-cache tini bash openssl
ENTRYPOINT [ "/sbin/tini", "--" ]
RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh; chmod +x wait-for-it.sh
COPY --from=BUILD_IMAGE $WORKING_DIR/. .
EXPOSE 3000
# Run using tsconfig-paths to rewrite paths
CMD ["node", "-r", "ts-node/register/transpile-only", "-r", "tsconfig-paths/register", "build/src/index.js"]