-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (51 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
67 lines (51 loc) · 1.27 KB
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
59
60
61
62
63
64
65
66
67
FROM node:24.13.1-alpine AS base
# ---------------
# Install Dependencies
# ---------------
FROM base AS deps
WORKDIR /app
# Install dependencies necessary for node-gyp on node alpine
RUN apk add --update --no-cache \
libc6-compat \
python3 \
make \
g++
# Install app dependencies
COPY package.json package-lock.json ./
COPY patches/ ./patches/
RUN --mount=type=cache,target=/root/.npm npm ci
# ---------------
# Build App
# ---------------
FROM deps AS build
WORKDIR /app
# Set env variables
ARG BASE_PATH=""
ENV BASE_PATH=${BASE_PATH}
ARG NODE_ENV="production"
ENV NODE_ENV=${NODE_ENV}
# Build the NestJS and Vite application
COPY . .
RUN npm run build:nest & npm run build:client & wait
# Remove non production necessary modules
RUN npm prune --omit=dev
# ---------------
# Release App
# ---------------
FROM base AS final
WORKDIR /app
# Set env variables
ARG BASE_PATH=""
ENV BASE_PATH=${BASE_PATH}
ENV NODE_ENV="production"
# Copy build artifacts
COPY --from=build /app/package.json ./
COPY --from=build /app/node_modules/ ./node_modules
COPY --from=build /app/src/client/dist/ ./src/client/dist
COPY --from=build /app/dist/ ./dist
COPY --from=build /app/drizzle/ ./drizzle
# Run as non-root user
USER node
ENV PORT=3000
EXPOSE 3000
CMD [ "npm", "run", "start:prod" ]