Repository navigation
Expand file tree
/
Copy pathDockerfile.vercel
More file actions
35 lines (31 loc) · 2.18 KB
/
Copy pathDockerfile.vercel
File metadata and controls
35 lines (31 loc) · 2.18 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
# Vercel Docker deployment (Dockerfile.vercel)
# Vercel detects this file at the repo root and uses it as the image blueprint, then
# runs the image on Fluid compute, which injects $PORT for the container to listen on.
#
# This deployment does NOT build the app. It reuses the prebuilt Docker Hub image
# `dastyaresocial/ds-cs` — the same image the self-host compose stack runs. The Next.js
# build output (.next), node_modules, public assets, config, scripts, and sources are
# already baked in, so there is no build stage here.
#
# The only change is the runtime command: the self-host image defaults to
# `next start -p 8729` (and Vercel needs the injected PORT). We override the CMD to bind
# to 0.0.0.0 on the port Vercel injects ($PORT, default 80) so the health check passes.
FROM dastyaresocial/ds-cs:latest
# Vercel injects PORT (default 80); the base image is built for the self-host port 8729.
EXPOSE 80
WORKDIR /app
# Overlay the repo's config/ and public/ on top of the base image. Without this,
# changes to about.config.yml, app.config.yml, and profile-image.png pushed to the
# repo are silently ignored because the base image bakes the OLD versions at build
# time. (Self-host compose uses bind-mounts for the same purpose.)
COPY config/ /app/config/
COPY public/ /app/brand/
# Run schema migrations + admin bootstrap + icon generation (idempotent), then
# seed animated emojis in the BACKGROUND so `next start` boots immediately —
# Vercel Fluid health-checks the serving port and recycles idle containers, so
# a foreground upload would block the health check and get killed mid-seed.
# - { [ -f ... ] || cp ... } seeds the default avatar when the user file is missing
# - CI=true forces upload-emojis.ts past its CI guard
# - --skip-if-exists uploads only when some emojis are missing, keeping cold starts cheap
# - `|| true` means a missing S3 config never blocks the app
CMD ["sh", "-c", "npm run db:migrate && npm run bootstrap:admin && { [ -f /app/brand/profile-image.png ] || cp /app/defaults/profile-image.png /app/brand/profile-image.png; } && npm run generate:icons && (CI=true npm run upload:emojis -- --skip-if-exists || true &) && node_modules/.bin/next start -H 0.0.0.0 -p ${PORT:-80}"]