-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.website
More file actions
55 lines (42 loc) · 1.88 KB
/
Dockerfile.website
File metadata and controls
55 lines (42 loc) · 1.88 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
FROM node:20-alpine AS base
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
FROM base AS deps
WORKDIR /app
# Copy workspace config and lockfile
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
# Copy all package.json files for workspace resolution
COPY packages/better-form/package.json ./packages/better-form/
COPY packages/plugin-google-places/package.json ./packages/plugin-google-places/
COPY website/nextjs/package.json ./website/nextjs/
RUN pnpm install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/packages/better-form/node_modules ./packages/better-form/node_modules
COPY --from=deps /app/packages/plugin-google-places/node_modules ./packages/plugin-google-places/node_modules
COPY --from=deps /app/website/nextjs/node_modules ./website/nextjs/node_modules
# Copy source files
COPY packages ./packages
COPY website/nextjs ./website/nextjs
COPY pnpm-workspace.yaml package.json turbo.json tsconfig.base.json ./
# Build packages first, then website
RUN pnpm --filter @better_form/core build && \
pnpm --filter @better_form/plugin-google-places build && \
pnpm --filter @better_form/website build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy standalone output (preserves monorepo structure)
COPY --from=builder --chown=nextjs:nodejs /app/website/nextjs/.next/standalone ./
# Copy static files to the correct nested location
COPY --from=builder --chown=nextjs:nodejs /app/website/nextjs/.next/static ./website/nextjs/.next/static
# Copy public folder to the correct nested location
COPY --from=builder /app/website/nextjs/public ./website/nextjs/public
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# server.js is at the nested monorepo path
CMD ["node", "website/nextjs/server.js"]