perf(docker): slim api image from 1.44GB to 657MB
The api image shipped every build artifact pnpm produced: - pnpm store + caches 769 MB - ffprobe-static (5 platforms) 335 MB - devDependencies (jest et al.) included - pm2, npm cache ~38 MB Split the build into a deps stage that installs with --prod and drops the pnpm store/caches in the same layer (node_modules entries are hardlinks, so they survive), then copy only node_modules into a clean runtime stage. ffprobe-static ships ffprobe for darwin/linux/win32 + ia32/x64 but both services already prefer a system ffprobe via `which ffprobe`, so its binaries are stripped and apk ffmpeg provides ffprobe instead. That also adds the ffmpeg binary services/ffmpeg.service.js needs for the mov/mkv fast-start remux, which the old image never had. Drop pm2: docker's restart policy covers crashes, and node now receives SIGTERM directly (~17 MB image, ~40 MB RSS saved on a 1.9 GB droplet). Verified on the QAS droplet: clean build 98s (was ~3m54s deploy step), code-only rebuild 8s, all runtime deps + sharp + typst + ffprobe resolve, container boots to the DB handshake. Also prune superseded layers in the deploy workflow.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
exec pm2-runtime start server.js --name "${APP_NAME:-app}"
|
||||
# Docker's `restart: unless-stopped` policy handles crash recovery, so the
|
||||
# process supervisor (pm2) is not shipped — it costs image size and ~40 MB RSS
|
||||
# on a 2 GB droplet. node runs as PID 1 and receives SIGTERM directly.
|
||||
exec node server.js
|
||||
|
||||
Reference in New Issue
Block a user