-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (49 loc) · 1.64 KB
/
Dockerfile
File metadata and controls
70 lines (49 loc) · 1.64 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Web Application Dockerfile
FROM node:20-alpine AS base
# Dependencies stage - install all dependencies
FROM base AS deps
# libc6-compat may be needed for some native dependencies
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install pnpm
RUN corepack enable pnpm
# Copy package.json files
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/shared/package.json ./packages/shared/package.json
COPY packages/better-auth-near/package.json ./packages/better-auth-near/package.json
COPY apps/web/package.json ./apps/web/package.json
# Install dependencies
RUN pnpm install --frozen-lockfile
# Build stage - compile the application
FROM base AS builder
WORKDIR /app
RUN corepack enable pnpm
# Copy the prepared pnpm workspace, including package-local node_modules links.
COPY --from=deps /app/ ./
# Copy source code
COPY . .
# Skip type generation during build (types should be committed)
# Build shared packages first
RUN pnpm build:shared
RUN pnpm build:better-auth-near
# Build the web app
RUN pnpm build:web
# Runtime stage - production image
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Install pnpm
RUN corepack enable pnpm
# Create non-root user for security
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy built application from standalone output
COPY --from=builder /app/apps/web/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
WORKDIR /app/apps/web
CMD ["node", "server.js"]