Repository navigation
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
67 lines (48 loc) · 2.89 KB
/
Copy pathDockerfile.alpine
File metadata and controls
67 lines (48 loc) · 2.89 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
# ═══════════════════════════════════════════════════════════════════════════════
# ProxyCLI - Alpine-based Dockerfile (Smaller Image)
# ═══════════════════════════════════════════════════════════════════════════════
# This Dockerfile uses Alpine Linux for a smaller final image (~100MB vs ~200MB)
# Usage: docker build -f Dockerfile.alpine -t proxycli:alpine .
# ═══════════════════════════════════════════════════════════════════════════════
# ── Stage 1: Dependencies ─────────────────────────────────────────────────────
FROM node:22-alpine AS deps
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json* ./
RUN npm ci --only=production
# ── Stage 2: Builder ──────────────────────────────────────────────────────────
FROM node:22-alpine AS builder
WORKDIR /app
# Install build tools
RUN apk add --no-cache python3 make g++
# Copy dependencies
COPY --from=deps /app/node_modules ./node_modules
# Copy source and build
COPY package.json tsconfig.json ./
COPY src/ ./src/
RUN npm run build
# ── Stage 3: Production ───────────────────────────────────────────────────────
FROM node:22-alpine AS production
LABEL org.opencontainers.image.title="ProxyCLI (Alpine)"
LABEL org.opencontainers.image.description="Lightweight multi-provider AI reverse proxy"
LABEL org.opencontainers.image.source="https://github.com/yourusername/proxycli"
WORKDIR /app
# Install gosu for user switching
RUN apk add --no-cache gosu
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S app -u 1001 -G nodejs
# Copy production files
COPY --from=deps /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --chown=app:nodejs public/ ./public/
COPY package.json docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
# Create data directory
RUN mkdir -p /app/data && chown -R app:nodejs /app/data
USER app
EXPOSE 8488
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD node -e "fetch('http://localhost:8488/health').then(r=>r.ok?process.exit(0):process.exit(1)).catch(()=>process.exit(1))"
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["node", "dist/index.js"]