forked from SciCatProject/scicat-backend-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
51 lines (36 loc) · 1.04 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
FROM node:16-alpine AS dev
# Prepare app directory
WORKDIR /home/node/app
COPY . .
# Set up local user
RUN mkdir /home/node/app/dist
RUN chown -R node:node /home/node/app
USER node
# Install dependencies
RUN npm install glob rimraf
RUN npm install
FROM node:16-alpine AS builder
# Prepare app directory
WORKDIR /usr/src/app
# Set up local user
# Copy files from dev image
COPY --from=dev /home/node/app .
# Build app
RUN npm run build
# Remove development dependencies
RUN npm prune --production
FROM node:16-alpine
# Prepare app directory
WORKDIR /home/node/app
# Set up local user
RUN chown -R node:node /home/node/app
USER node
# Copy files from builder image
COPY --from=builder --chown=node:node /usr/src/app/dist ./dist
COPY --from=builder --chown=node:node /usr/src/app/node_modules ./node_modules
# Copy migration scripts so we can run them directly in the container if needed
COPY ./migrations ./migrations
COPY ./migrate-mongo-config.js ./migrate-mongo-config.js
COPY ./package.json ./package.json
EXPOSE 3000
CMD ["node", "dist/main"]