-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (48 loc) · 1.32 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
59
60
61
62
63
64
65
ARG NODE_VERSION=20
ARG PROJECT=workers
# Alpine image
FROM node:${NODE_VERSION}-slim AS slim
RUN apt-get update
RUN apt-get install libssl-dev curl -y
# Setup npm on the alpine base
FROM slim as base
RUN npm install turbo --global
RUN npm install dotenv-cli --global
RUN npm install pnpm --global --force
# Prune projects
FROM base AS pruner
ARG PROJECT
WORKDIR /app
COPY . .
RUN turbo prune --scope=${PROJECT} --docker
# Build the Project
FROM base AS builder
ARG PROJECT
WORKDIR /app
# Copy lockfile and package.json's of isolated subworkspace
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=pruner /app/out/json/ .
# First install the dependencies (as they change less often)
RUN pnpm install --production=false
# Copy source code of isolated subworkspace
COPY --from=pruner /app/out/full/ .
#TODO: Uncomment the following line if you plan to use prisma
# RUN turbo run db:generate
RUN turbo run build --filter=${PROJECT}
RUN pnpm install --production
# RUN rm -rf ./**/*/src
# Final image
FROM base AS runner
ARG PROJECT
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs
WORKDIR /app
RUN pnpm i debug
COPY --from=builder --chown=nodejs:nodejs /app .
WORKDIR /app/apps/${PROJECT}
ARG PORT=3000
ENV PORT=${PORT}
ENV NODE_ENV=production
EXPOSE ${PORT}
CMD pnpm start