-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (69 loc) · 2.68 KB
/
Dockerfile
File metadata and controls
92 lines (69 loc) · 2.68 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# syntax=docker/dockerfile:1.6
# Build arguments
ARG NODE_VERSION=20.11.0
ARG ALPINE_VERSION=3.19
# =============================================================================
# Base stage
# =============================================================================
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS base
LABEL maintainer="Vibe-Coding-Apps Team"
LABEL description="Vibe Coding Apps - Production Image"
# Install security updates
RUN apk update && apk upgrade --no-cache
WORKDIR /app
# =============================================================================
# Dependencies stage
# =============================================================================
FROM base AS deps
RUN npm install -g pnpm@8
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
# =============================================================================
# Builder stage
# =============================================================================
FROM base AS builder
RUN npm install -g pnpm@8
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build arguments for metadata
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION=latest
ENV NODE_ENV=production
RUN pnpm build
# =============================================================================
# Production stage
# =============================================================================
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS runner
# Security: Run as non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 --ingroup nodejs appuser
WORKDIR /app
# Install only runtime dependencies
RUN apk add --no-cache curl dumb-init
# Copy built assets
COPY --from=builder --chown=appuser:nodejs /app/.next/standalone ./
COPY --from=builder --chown=appuser:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=appuser:nodejs /app/public ./public
# Security: Set proper permissions
RUN chmod -R 550 /app && \
chmod -R 770 /app/.next/cache 2>/dev/null || true
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT:-3000}/health || exit 1
# Switch to non-root user
USER appuser
# Environment
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
EXPOSE 3000
# Use dumb-init for proper signal handling
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "server.js"]
# Metadata labels
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.source="https://github.com/vibe-coding-apps"