-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.chainguard
More file actions
62 lines (43 loc) · 1.7 KB
/
Dockerfile.chainguard
File metadata and controls
62 lines (43 loc) · 1.7 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
# Multi-stage build for TMI-UX using Chainguard base images
# Uses the container configuration (environment.container.ts)
# Runtime environment can be overridden via TMI_* env vars
# Stage 1: Build the Angular application
FROM cgr.dev/chainguard/node:latest-dev AS builder
# Run as root to install pnpm via corepack
USER root
WORKDIR /app
# Enable corepack and activate pnpm
RUN corepack enable && corepack prepare pnpm@10.24.0 --activate
# Copy package files first for layer caching
COPY package.json pnpm-lock.yaml ./
# Install all dependencies (including devDependencies for build)
RUN pnpm install --frozen-lockfile
# Copy application source
COPY . .
# Build the application with container configuration
RUN pnpm run build:container
# Stage 2: Install runtime dependencies in a separate stage
FROM cgr.dev/chainguard/node:latest-dev AS runtime-deps
USER root
WORKDIR /app
# Create minimal package.json with only runtime server dependencies
RUN echo '{"name":"tmi-ux-server","version":"1.0.0","type":"module","dependencies":{"express":"^5.1.0","express-rate-limit":"^8.1.0"}}' > package.json
# Install only production dependencies
RUN npm install --omit=dev --production
# Stage 3: Production runtime
FROM cgr.dev/chainguard/node:latest
ARG APP_VERSION=unknown
LABEL org.opencontainers.image.version=$APP_VERSION
WORKDIR /app
# Copy runtime node_modules from the deps stage
COPY --from=runtime-deps /app/node_modules ./node_modules
# Copy built Angular application from builder stage
COPY --from=builder /app/dist ./dist
# Copy server file
COPY server.js ./
EXPOSE 8080
ENV PORT=8080
ENV NODE_ENV=production
# Chainguard node:latest has ENTRYPOINT ["/usr/bin/node"]
# so CMD only needs the script path
CMD ["server.js"]