-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
67 lines (52 loc) · 1.84 KB
/
dockerfile
File metadata and controls
67 lines (52 loc) · 1.84 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
# ===== DEPENDENCIES STAGE =====
FROM oven/bun:1-alpine AS deps
WORKDIR /app
# Copy dependency files
COPY package.json bun.lock* ./
# Install all dependencies (including dev dependencies for build)
RUN bun install --frozen-lockfile
# ===== BUILDER STAGE =====
FROM oven/bun:1-alpine AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY package.json bun.lock* ./
# Copy source code (excluding unnecessary files via .dockerignore)
COPY app ./app
COPY components ./components
COPY contexts ./contexts
COPY hooks ./hooks
COPY lib ./lib
COPY public ./public
COPY next.config.ts ./
COPY tsconfig.json ./
COPY postcss.config.mjs ./
COPY components.json ./
# Build application with optimizations
RUN NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 bun run build
# ===== PRODUCTION STAGE =====
FROM oven/bun:1-alpine AS runner
WORKDIR /app
# Install runtime dependencies and security updates
RUN apk add --no-cache \
curl \
ca-certificates \
&& apk upgrade --no-cache \
&& rm -rf /var/cache/apk/*
# Create non-root user for security
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# No environment variables - all hardcoded for consistency
# Copy built application with proper ownership
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
# Switch to non-root user
USER nextjs
# Expose port
EXPOSE 3000
# Add health check using one of your API endpoints
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -f http://localhost:3000/api/login || exit 1
# Start application with hardcoded settings
CMD ["sh", "-c", "NODE_ENV=production PORT=3000 HOSTNAME=0.0.0.0 node server.js"]