-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (39 loc) · 1.24 KB
/
Dockerfile
File metadata and controls
54 lines (39 loc) · 1.24 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
# Use Node.js v22.14.0 as the base image
FROM node:22.14.0-alpine AS builder
# Add this line
ARG PUBLIC_CHAT_ENDPOINT
# Then add env for build time
ENV PUBLIC_CHAT_ENDPOINT=${PUBLIC_CHAT_ENDPOINT}
# Set working directory
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy the entire project
COPY . .
# Install dependencies with legacy peer deps to handle version conflicts
# (Handles the Svelte 5 vs Svelte 4 dependency conflict)
RUN pnpm install --no-frozen-lockfile
# Build the application
RUN pnpm build
# Production stage
FROM node:22.14.0-alpine AS production
# Set working directory
WORKDIR /app
# Create a non-root user to run the application
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 sveltekit
# Install curl for healthchecks
RUN apk add --no-cache curl
# Copy built assets from builder stage
COPY --from=builder --chown=sveltekit:nodejs /app/build ./build
COPY --from=builder --chown=sveltekit:nodejs /app/package.json ./
COPY --from=builder --chown=sveltekit:nodejs /app/node_modules ./node_modules
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Expose the port the app will run on
EXPOSE 3000
# Switch to non-root user
USER sveltekit
# Start the application
CMD ["node", "build"]