-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.web
More file actions
55 lines (44 loc) · 1.66 KB
/
Dockerfile.web
File metadata and controls
55 lines (44 loc) · 1.66 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
# syntax=docker/dockerfile:1
# ------------------------------
# Base image
# ------------------------------
FROM node:20-alpine AS base
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@10.18.0 --activate
# ------------------------------
# Dependencies stage
# ------------------------------
FROM base AS deps
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY app/package.json ./app/package.json
RUN pnpm install --filter app... --prod=false --frozen-lockfile
# ------------------------------
# Build stage
# ------------------------------
FROM deps AS build
COPY tsconfig.base.json ./
COPY app ./app
RUN pnpm --filter app build
# ------------------------------
# Runtime stage
# ------------------------------
FROM node:20-alpine AS runner
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@10.18.0 --activate
ENV NODE_ENV=production
ENV PORT=3000
# Copy minimal required files
COPY pnpm-workspace.yaml ./
COPY package.json ./
# Copy build output (Next.js standalone)
COPY --from=build /app/app/.next/standalone ./standalone
COPY --from=build /app/app/.next/static ./standalone/app/.next/static
COPY --from=build /app/app/public ./standalone/app/public
# Ensure runtime data directory exists and is writable
RUN mkdir -p /app/standalone/app/data && chown -R node:node /app/standalone
# Security best practices
USER node
# Expose and run from correct directory
EXPOSE 3000
WORKDIR /app/standalone
CMD ["node", "app/server.js", "--port", "3000", "--hostname", "0.0.0.0"]