This repository was archived by the owner on Jan 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (65 loc) · 2.56 KB
/
Dockerfile
File metadata and controls
85 lines (65 loc) · 2.56 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
# Build stage
FROM node:24-alpine AS builder
# Install build dependencies
RUN apk add --no-cache bash
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY node/package*.json ./node/
COPY node/packages/webpods-test-utils/package*.json ./node/packages/webpods-test-utils/
COPY node/packages/webpods/package*.json ./node/packages/webpods/
# Copy build scripts from scripts directory
COPY scripts/ ./scripts/
# Copy TypeScript config
COPY tsconfig.base.json ./
# Copy source code
COPY knexfile.js ./
COPY node ./node
COPY database ./database
# Install dependencies and build
RUN chmod +x scripts/build.sh scripts/clean.sh scripts/format-all.sh && \
./scripts/build.sh --install --no-format
# Runtime stage - Ubuntu minimal
FROM ubuntu:24.04 AS runtime
# Install Node.js 24 and minimal dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
ca-certificates && \
curl -fsSL https://deb.nodesource.com/setup_24.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -r -u 1001 -g root -s /bin/bash webpods && \
mkdir -p /home/webpods && \
chown -R webpods:root /home/webpods
WORKDIR /app
# Copy built application from builder stage
COPY --from=builder --chown=webpods:root /app/node ./node
COPY --from=builder --chown=webpods:root /app/database ./database
COPY --from=builder --chown=webpods:root /app/package*.json ./
COPY --from=builder --chown=webpods:root /app/node_modules ./node_modules
COPY --from=builder --chown=webpods:root /app/knexfile.js ./
# Copy config files (example config for reference)
COPY --chown=webpods:root config.example.json ./
# Copy Docker-specific files from scripts/docker
COPY --chown=webpods:root scripts/docker/config.docker.json ./
COPY --chown=webpods:root scripts/docker/docker-start.sh ./
# Copy Docker entrypoint
COPY --chown=webpods:root scripts/docker-entrypoint.sh ./
RUN chmod +x docker-start.sh scripts/docker-entrypoint.sh
# Switch to non-root user
USER webpods
# Expose API server port
EXPOSE 3000
# Set default environment variables (non-sensitive only)
ENV NODE_ENV=production \
WEBPODS_PORT=3000 \
LOG_LEVEL=info
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:' + (process.env.WEBPODS_PORT || 3000) + '/health', (res) => process.exit(res.statusCode === 200 ? 0 : 1))"
# Use entrypoint for automatic setup
ENTRYPOINT ["./scripts/docker-entrypoint.sh"]
CMD ["./docker-start.sh"]