-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (57 loc) · 2 KB
/
Dockerfile
File metadata and controls
78 lines (57 loc) · 2 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
# Multi-stage build for optimal image size
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files first for better layer caching
COPY package*.json ./
COPY tsconfig.json ./
# Install dependencies
RUN npm ci --only=production && npm cache clean --force
# Copy source code
COPY src/ ./src/
# Build the project
RUN npm run build
# Production image
FROM node:18-alpine AS production
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init
# Create non-root user for security
RUN addgroup -g 1001 -S zodkit && \
adduser -S zodkit -u 1001
# Set working directory
WORKDIR /app
# Copy built application from builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
# Copy additional files
COPY README.md LICENSE CHANGELOG.md ./
# Change ownership to non-root user
RUN chown -R zodkit:zodkit /app
# Switch to non-root user
USER zodkit
# Create volume for project files
VOLUME ["/workspace"]
# Set default working directory for commands
WORKDIR /workspace
# Add zodkit to PATH
ENV PATH="/app/dist/cli:$PATH"
# Expose potential ports (for future web UI)
EXPOSE 3000 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD node /app/dist/cli/index.js --version || exit 1
# Set default entrypoint
ENTRYPOINT ["dumb-init", "--", "node", "/app/dist/cli/index.js"]
# Default command
CMD ["--help"]
# Labels for metadata
LABEL maintainer="JSONbored" \
version="0.1.0" \
description="Modern CLI tool for static analysis and validation of Zod schemas" \
org.opencontainers.image.title="zodkit" \
org.opencontainers.image.description="Modern CLI tool for static analysis and validation of Zod schemas" \
org.opencontainers.image.vendor="JSONbored" \
org.opencontainers.image.version="0.1.0" \
org.opencontainers.image.source="https://github.com/JSONbored/zodkit" \
org.opencontainers.image.licenses="MIT"