add containerFiles

This commit is contained in:
2026-05-11 13:17:52 +02:00
parent 434c5b2792
commit a281d9cce9
2 changed files with 74 additions and 0 deletions

53
Containerfile Normal file
View File

@@ -0,0 +1,53 @@
# Stage 1: Install dependencies
FROM docker.io/oven/bun:1.3.3-alpine AS deps
WORKDIR /app
COPY package.json bun.lock ./
RUN apk add --no-cache python3 make g++
RUN bun i --frozen-lockfile
# Stage 2: Build the SvelteKit application
FROM docker.io/oven/bun:1.3.3-alpine AS builder
WORKDIR /app
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the application with the Node.js adapter
RUN bun run build
# Prune dev dependencies after build
# We will have to wait for bun support big sad
# RUN bun prune --omit=dev
# Stage 3: Production runtime
FROM docker.io/oven/bun:1.3.3-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Create non-root user
RUN addgroup --system --gid 1001 sveltekit
RUN adduser --system --uid 1001 sveltekit
# Copy the built application
COPY --from=builder --chown=sveltekit:sveltekit /app/build ./build
# Copy production dependencies
COPY --from=builder --chown=sveltekit:sveltekit /app/node_modules ./node_modules
# Copy package.json for module resolution
COPY --chown=sveltekit:sveltekit package.json .
USER sveltekit
EXPOSE 3000
ENV PORT=3000
ENV HOST=0.0.0.0
# Start the SvelteKit server
CMD ["bun", "--bun", "build/index.js"]

21
Containerfile.migrator Normal file
View File

@@ -0,0 +1,21 @@
# Stage 1: Install dependencies
FROM docker.io/oven/bun:1.3.3-alpine AS deps
WORKDIR /app
COPY package.json bun.lock ./
RUN apk add --no-cache python3 make g++
RUN bun i --frozen-lockfile
# Stage 2: Build the SvelteKit application
FROM docker.io/oven/bun:1.3.3-alpine AS builder
WORKDIR /app
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
COPY --from=deps /app/node_modules ./node_modules
COPY . .
CMD ["bun", "--bun", "run", "db:migrate"]