-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (30 loc) · 1.39 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (30 loc) · 1.39 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
FROM node:20-alpine
WORKDIR /app
ARG BUNDLE_STATS_BASELINE=false
ENV BUNDLE_STATS_BASELINE=${BUNDLE_STATS_BASELINE}
# Install pnpm
RUN npm install -g pnpm
# Copy root files required by pnpm
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
# Copy environment variables file (needed for build and runtime)
COPY .env ./
# Copy TypeScript configuration files needed for build
COPY tsconfig.base.json tsconfig.base.composite.json tsconfig.json ./
# Copy package.json files of all workspace packages for proper dependency resolution
# Using find to preserve directory structure
COPY packages packages/
COPY apps apps/
# Install dependencies (this will install all workspace dependencies)
# We copy everything first, then install - this allows pnpm to resolve workspace dependencies correctly
RUN pnpm install --frozen-lockfile
RUN echo "BUNDLE_STATS_BASELINE is $BUNDLE_STATS_BASELINE"
RUN pnpm --filter app-web run build
RUN pnpm --filter app-backend run build
EXPOSE 8080
ENV PORT=8080
ENV BACKEND_PORT=3001
ENV NODE_ENV=production
# Start both backend and frontend servers (backend on 3001, frontend on 8080).
# `wait -n` returns as soon as either process exits, and `exit 1` tears the
# container down so the platform replaces it instead of keeping a half-dead one.
CMD ["sh", "-c", "PORT=3001 pnpm --filter app-backend run start:prod & PORT=8080 pnpm --filter app-web run start:prod & wait -n; exit 1"]