-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (44 loc) · 1.93 KB
/
Dockerfile
File metadata and controls
57 lines (44 loc) · 1.93 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
FROM node:24-bookworm AS installer
WORKDIR /app
# Install bun and enable corepack for yarn
RUN corepack enable \
&& npm install -g bun
ARG VERSION
ENV VERSION="${VERSION}" \
CI=true
# Copy dependency files first for better caching (includes all workspaces)
COPY package.json yarn.lock .yarnrc.yml ./
COPY apps/web/package.json ./apps/web/
COPY apps/electron/package.json ./apps/electron/
COPY apps/admin/package.json ./apps/admin/
COPY packages/auth-core/package.json ./packages/auth-core/
# Install dependencies (this layer is cached unless dependency files change)
RUN yarn install --immutable
# Copy source code
COPY . .
# Build application and bootstrap script
RUN yarn run build \
&& mkdir -p apps/web/dist-scripts \
&& bun build apps/web/scripts/bootstrap.ts --target=node --format=esm --outfile=apps/web/dist-scripts/bootstrap.mjs \
&& cp -rn node_modules/@electric-sql/pglite/dist/. apps/web/dist-scripts/ \
&& cp node_modules/@electric-sql/pglite-legacy/dist/postgres.data apps/web/dist-scripts/ \
&& cp node_modules/@electric-sql/pglite-legacy/dist/postgres.wasm apps/web/dist-scripts/ \
&& rm -f apps/web/.next/standalone/.env apps/web/.next/standalone/.env.local
FROM node:24-bookworm-slim AS runner
ENV NODE_ENV=production \
HOSTNAME=0.0.0.0 \
PORT=3000 \
DORY_RUNTIME=docker \
NEXT_PUBLIC_DORY_RUNTIME=docker
# tzdata
RUN apt-get update && apt-get install -y --no-install-recommends tzdata ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Use built-in node user for security
USER node
WORKDIR /app
COPY --from=installer --chown=node:node /app/apps/web/.next/standalone ./
COPY --from=installer --chown=node:node /app/apps/web/public ./apps/web/public
COPY --from=installer --chown=node:node /app/apps/web/dist-scripts ./dist-scripts
COPY --from=installer --chown=node:node /app/apps/web/.next/static ./apps/web/.next/static
EXPOSE 3000
CMD ["sh", "-c", "node dist-scripts/bootstrap.mjs && exec node apps/web/server.js"]