Files
sim/docker/db.Dockerfile
Waleed 323e03520d feat(releases): tag releases to main with version numbers, speed up docker builds (#2337)
* feat(releases): tag releases to main with version numbers, speed up docker builds

* resize runners
2025-12-12 15:57:10 -08:00

43 lines
1.4 KiB
Docker

# ========================================
# Base Stage: Alpine Linux with Bun
# ========================================
FROM oven/bun:1.3.3-alpine AS base
# ========================================
# Dependencies Stage: Install Dependencies
# ========================================
FROM base AS deps
WORKDIR /app
# Copy only package files needed for migrations (these change less frequently)
COPY package.json bun.lock turbo.json ./
RUN mkdir -p packages/db
COPY packages/db/package.json ./packages/db/package.json
# Install dependencies with cache mount for faster builds
RUN --mount=type=cache,id=bun-cache,target=/root/.bun/install/cache \
bun install --frozen-lockfile --ignore-scripts
# ========================================
# Runner Stage: Production Environment
# ========================================
FROM base AS runner
WORKDIR /app
# Create non-root user and group (cached separately)
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Copy only the necessary files from deps (cached if dependencies don't change)
COPY --from=deps --chown=nextjs:nodejs /app/node_modules ./node_modules
# Copy package configuration files (needed for migrations)
COPY --chown=nextjs:nodejs packages/db/drizzle.config.ts ./packages/db/drizzle.config.ts
# Copy database package source code (changes most frequently - placed last)
COPY --chown=nextjs:nodejs packages/db ./packages/db
# Switch to non-root user
USER nextjs
WORKDIR /app/packages/db