-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (45 loc) · 1.96 KB
/
Dockerfile
File metadata and controls
63 lines (45 loc) · 1.96 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
# Stage 1: Build the application
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package.json and configuration files
COPY package.json package-lock.json* svelte.config.js vite.config.ts* tsconfig.json* ./
# Install all dependencies
RUN npm ci --ignore-scripts
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build
# Prune dev dependencies to reduce image size for the next stage
RUN npm prune --production
# Stage 2: Create the production image
FROM node:20-alpine
WORKDIR /app
# Install runtime dependencies (if any specific syste libraries needed, typically none for pure node)
# Copy the built application from the builder stage
COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/package-lock.json ./package-lock.json
# Copy drizzle config and schema for drizzle-kit push
COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts
COPY --from=builder /app/src/lib/server/db/schema.ts ./src/lib/server/db/schema.ts
COPY --from=builder /app/tsconfig.json ./tsconfig.json
# Install drizzle-kit locally so we don't rely on npx fetching it at runtime
RUN npm install --no-save drizzle-kit
# Copy drizzle files needed for push
COPY --from=builder /app/drizzle ./drizzle
COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts
COPY --from=builder /app/src/lib/server/db/schema.ts ./src/lib/server/db/schema.ts
# Install drizzle-kit for runtime schema push (pruned as devDependency)
RUN npm install drizzle-kit@0.31.8
# Copy entrypoint script
COPY entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh
# Expose the port the app runs on (SvelteKit node adapter starts on 3000 by default)
EXPOSE 3000
# Set Node environment to production
ENV NODE_ENV=production
# Increase body size limit for image uploads (default 512K is too small)
ENV BODY_SIZE_LIMIT=10M
# Start the application with migrations
CMD ["./entrypoint.sh"]