-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (32 loc) · 1023 Bytes
/
Dockerfile
File metadata and controls
47 lines (32 loc) · 1023 Bytes
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
ARG NODE_VERSION=22
FROM node:${NODE_VERSION}-slim AS slim
# 1. Setup pnpm on the slim base
FROM slim AS base
RUN corepack enable
RUN npm install -g corepack@latest
RUN pnpm config set store-dir ~/.pnpm-store
# 2. Build the project
FROM base AS builder
ENV CI=true
WORKDIR /app
COPY ./ /app
# Install dependencies
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile
# Build the specified project
RUN pnpm build
# 3. Final image - runner stage to run the application
FROM base AS runner
ARG APP_DIRNAME
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 svelte-kit
USER svelte-kit
WORKDIR /app
# Copy built artifacts from builder stage
COPY --from=builder --chown=svelte-kit:nodejs /app/build ./build
COPY --from=builder --chown=svelte-kit:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=svelte-kit:nodejs /app/package.json ./package.json
ARG PORT=5173
ENV PORT=${PORT}
EXPOSE ${PORT}
CMD ["node", "build"]