-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (47 loc) · 2.42 KB
/
Copy pathDockerfile
File metadata and controls
67 lines (47 loc) · 2.42 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
# ── Stage 1: Install dependencies ─────────────────────────────────────────────
FROM node:22-slim AS deps
RUN corepack enable && corepack prepare [email protected] --activate
WORKDIR /app
COPY . .
RUN pnpm install --frozen-lockfile --prod=false
# ── Stage 2: Build ────────────────────────────────────────────────────────────
FROM node:22-slim AS build
RUN corepack enable && corepack prepare [email protected] --activate
WORKDIR /app
COPY --from=deps /app ./
RUN pnpm build
# ── Stage 3: Production runtime ───────────────────────────────────────────────
FROM node:22-slim AS runtime
# git is required for content operations (clone, branch, commit, push)
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Non-root user for security
RUN groupadd -r studio && useradd -r -g studio -m studio
WORKDIR /app
# Copy built output
COPY --from=build /app/.output ./.output
# Contentrain content (needed for UI strings via @contentrain/query)
COPY --from=build /app/.contentrain ./.contentrain
# Database migration runner + SQL lineage. The managed pair does NOT migrate
# at app start; the Railway pre-deploy command (`node scripts/migrate-postgres.mjs`)
# runs this before the new image serves, so the schema is always applied ahead
# of the release. The app bundles its own pg inside .output; this standalone
# runner lives outside that tree, so it gets a self-contained pg (its only
# non-builtin import, matched to the app's resolved 8.22.0).
COPY --from=build /app/scripts/migrate-postgres.mjs /app/scripts/verify-managed-schema.mjs ./scripts/
COPY --from=build /app/postgres/migrations ./postgres/migrations
COPY --from=build /app/supabase/migrations ./supabase/migrations
RUN printf '{"name":"studio-migrations","private":true,"type":"module"}\n' > package.json \
&& npm install --no-fund --no-audit [email protected] \
&& npm cache clean --force
# Git needs a writable home for config
ENV HOME=/home/studio
ENV NODE_ENV=production
ENV NITRO_PORT=3000
ENV NITRO_HOST=0.0.0.0
RUN chown -R studio:studio /app
USER studio
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]