Skip to content

Commit 269ca08

Browse files
committed
fix: Make the image smaller
1 parent 0194bbd commit 269ca08

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

Dockerfile

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
1-
# Use Node.js 18 Alpine for smaller image size
2-
FROM node:22-alpine
1+
# Multi-stage Docker build for Tolgee CLI
2+
# Stage 1: Build stage with dev dependencies
3+
FROM node:18-alpine AS builder
34

45
# Set working directory
56
WORKDIR /app
67

7-
# Copy package.json and package-lock.json first for better Docker layer caching
8+
# Copy package files first for better Docker layer caching
89
COPY package*.json ./
910

10-
# Install all dependencies (including dev dependencies needed by the built code)
11+
# Install ALL dependencies (including dev dependencies needed for building)
1112
RUN npm ci && npm cache clean --force
1213

13-
# Copy built application files (as specified in package.json "files" section)
14-
COPY dist/ ./dist/
14+
# Copy source files
15+
COPY src/ ./src/
16+
COPY scripts/ ./scripts/
17+
COPY tsconfig*.json ./
18+
COPY eslint.config.js ./
19+
20+
# Copy additional files needed for build
1521
COPY textmate/ ./textmate/
1622
COPY extractor.d.ts ./
1723
COPY schema.json ./
24+
25+
# Build the CLI
26+
RUN npm run build
27+
28+
# Stage 2: Production stage with only runtime dependencies
29+
FROM node:18-alpine AS production
30+
31+
# Set working directory
32+
WORKDIR /app
33+
34+
# Copy package files first for better Docker layer caching
35+
COPY package*.json ./
36+
37+
# Install ONLY production dependencies
38+
RUN npm ci --only=production && npm cache clean --force
39+
40+
# Copy built application files from builder stage
41+
COPY --from=builder /app/dist/ ./dist/
42+
COPY --from=builder /app/textmate/ ./textmate/
43+
COPY --from=builder /app/extractor.d.ts ./
44+
COPY --from=builder /app/schema.json ./
45+
46+
# Copy documentation files
1847
COPY README.md ./
1948
COPY LICENSE ./
2049

21-
# Copy node_modules for runtime dependencies
22-
COPY node_modules/ ./node_modules/
23-
2450
# Make the CLI binary executable
2551
RUN chmod +x ./dist/cli.js
2652

0 commit comments

Comments
 (0)