-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (37 loc) · 1.28 KB
/
Dockerfile
File metadata and controls
51 lines (37 loc) · 1.28 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
# ---- Base Stage ----
# Install dependencies for the entire monorepo
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod=false
# ---- Builder Stage ----
# Build all applications and packages
FROM base AS builder
COPY . .
RUN pnpm build
# ---- Frontend Stage ----
# Creates a production-ready image for a Next.js frontend app
FROM base AS frontend
ARG APP_NAME
ENV APP_NAME=${APP_NAME}
WORKDIR /app
COPY --from=builder /app/apps/${APP_NAME}/.next/standalone ./
COPY --from=builder /app/apps/${APP_NAME}/.next/static ./apps/${APP_NAME}/.next/static
COPY --from=builder /app/apps/${APP_NAME}/public ./apps/${APP_NAME}/public
# Ensure the server can start
EXPOSE 3000
CMD node apps/${APP_NAME}/server.js
# ---- Backend Stage ----
# Creates a production-ready image for a Node.js backend service
FROM base AS backend
ARG APP_NAME
ENV APP_NAME=${APP_NAME}
WORKDIR /app
# Copy built code and necessary files from the builder stage
COPY --from=builder /app/apps/${APP_NAME}/dist ./dist
COPY --from=builder /app/apps/${APP_NAME}/package.json ./package.json
EXPOSE 3000
CMD ["node", "dist/index.js"]