forked from SciCatProject/scicat-backend-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
50 lines (34 loc) · 1014 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM node:20-alpine AS dev
# Prepare app directory
WORKDIR /home/node/app
COPY . .
# Set up local user
RUN mkdir /home/node/app/dist
# Install dependencies
RUN npm install glob rimraf
RUN npm install
FROM node:20-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:20-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"]