-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
99 lines (75 loc) · 3.26 KB
/
Copy pathDockerfile
File metadata and controls
99 lines (75 loc) · 3.26 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Dockerfile for owlcms-tracker SvelteKit application
# Multi-stage production build using adapter-node
# Plugins are statically bundled via Vite import.meta.glob at build time
# Stage 1: Builder
FROM node:22-alpine AS builder
WORKDIR /build
# Copy package files
COPY package*.json ./
# Install dependencies (including dev deps for build)
RUN npm ci
# Copy source code (plugins included via static import.meta.glob)
# Note: experiments/ removed by workflow before Docker build
# Note: books/ included only if --submodules flag used in release workflow
COPY . .
# Optional plugin pruning for slim deployments (e.g. Fly single-tenant deploy).
# KEEP_PLUGINS is a comma- or space-separated list of plugin folder paths,
# relative to src/plugins, to KEEP (e.g. "scoreboards/start-order,scoreboards/lifting-order").
# Every other plugin (any folder containing a config.js) plus extensions/ and
# experiments/ is removed BEFORE the build, so Vite's import.meta.glob bundles
# only the kept plugins. Empty (the default) keeps everything, so official
# releases are unaffected because the release workflow never passes this arg.
ARG KEEP_PLUGINS=""
ARG TRACKER_VERSION_OVERRIDE=""
ARG TRACKER_COMMIT=""
RUN if [ -n "$KEEP_PLUGINS" ]; then \
keep=" $(echo "$KEEP_PLUGINS" | tr ',' ' ') " && \
echo "Pruning plugins, keeping:$keep" && \
find src/plugins -name config.js | while read -r cfg; do \
dir=$(dirname "$cfg"); \
rel=${dir#src/plugins/}; \
case "$keep" in \
*" $rel "*) echo " keep $rel" ;; \
*) echo " remove $rel" && rm -rf "$dir" ;; \
esac; \
done && \
rm -rf src/plugins/experiments extensions ; \
fi
# Build the application (will include all plugins in source)
# Increase Node.js heap size to prevent OOM during build
ENV NODE_OPTIONS="--max-old-space-size=4096"
ENV TRACKER_VERSION_OVERRIDE="$TRACKER_VERSION_OVERRIDE"
ENV TRACKER_COMMIT="$TRACKER_COMMIT"
RUN node scripts/generate-version.js && npm run build:bundle
# Remove pre-compressed static files (server-side only, not needed)
RUN find build/client -name '*.gz' -delete && find build/client -name '*.br' -delete
# Stage 2: Runtime
FROM node:22-alpine
WORKDIR /app
# Install dumb-init for signal handling
RUN apk add --no-cache dumb-init
# Copy package files from builder
COPY --from=builder /build/package*.json ./
# Copy built application (includes build/lib/server with transformed imports from copy-runtime-server-files.js)
COPY --from=builder /build/build ./build
# Copy startup script that attaches WebSocket server
COPY --from=builder /build/start-with-ws.js ./start-with-ws.js
# Install production dependencies only
RUN npm ci --omit=dev
# Create non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001 \
&& chown -R nodejs:nodejs /app
USER nodejs
# Set port for Node.js adapter
ENV PORT=8096
# Disable browser auto-open in container
ENV DOCKER=1
# Increase Node.js heap size for runtime (flag/logo ZIP extraction can be large)
ENV NODE_OPTIONS="--max-old-space-size=4096"
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:8096/ || exit 1
EXPOSE 8096
ENTRYPOINT ["dumb-init", "--"]
# Run the built Node.js server
CMD ["node", "start-with-ws.js"]