-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.solo
51 lines (38 loc) · 1.42 KB
/
Dockerfile.solo
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
FROM node:21-alpine AS base
# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
COPY . .
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/ .
COPY --from=builder /app/yarn.lock ./yarn.lock
RUN yarn install
# Build the project
COPY --from=builder /app/ .
# set the deploy target to node
RUN DEPLOY_TARGET=node yarn build
# Create a new stage for the runner
FROM base AS runner
WORKDIR /app
# Don't run production as root - add a non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 svelte
USER svelte
# Copy the necessary files from the installer stage
COPY --from=installer /app/package.json .
COPY --from=installer /app/.env .
COPY --from=installer /app/build /app/build
EXPOSE 3000
# Modify this line to start your SvelteKit application, e.g., run your server.js or the appropriate script.
CMD [ "node", "build" ]