-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.api
49 lines (31 loc) · 1.13 KB
/
Dockerfile.api
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
FROM node:20.18.0-alpine3.19@sha256:fa1223fe38c80d7eba9a513930eaaa85107aa5ac700b35c146738b7e1e7b00cd AS base
FROM base AS deps
WORKDIR /app
# Copy root worksplace level package.json
COPY package.json package-lock.json ./
# Copy relevant packages for the api workspace
COPY ./packages/api ./packages/api
COPY ./packages/models ./packages/models
RUN npm ci --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
#COPY --from=deps /app/packages/api/node_modules ./node_modules
# Copy in packages/models as this is simlinked in package.json. npm workspaces...sigh
COPY --from=deps /app/packages/models ./packages/models
COPY ./packages/api/src ./src
COPY ./packages/api/tsconfig.json ./
COPY ./packages/api/package.json ./
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 express
COPY --from=builder --chown=express:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=express:nodejs /app/dist ./
USER express
EXPOSE 1994
ENV PORT 1994
ENV HOSTNAME "0.0.0.0"
CMD ["node", "index.js"]