- Compile src/db/migrate.ts to dist/migrate.js during build - Copy dist/migrate.js to Stage 2 (runner) inside Dockerfile - Run bun dist/migrate.js on db:migrate command - Modify schema.sql to use CREATE TABLE IF NOT EXISTS and ALTER TABLE to add file_hash to existing database instances on VPS Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
34 lines
686 B
Docker
34 lines
686 B
Docker
# Stage 1: Builder
|
|
FROM oven/bun:alpine AS builder
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
# Install dependencies (including devDependencies for build and lint)
|
|
COPY package.json tsconfig.json biome.json ./
|
|
RUN bun install
|
|
|
|
# Copy src and test directories
|
|
COPY src ./src
|
|
COPY test ./test
|
|
|
|
# Run lint and build
|
|
RUN bun run lint
|
|
RUN bun run build
|
|
|
|
# Stage 2: Runner
|
|
FROM oven/bun:slim AS runner
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
# Copy built files, schema, and package.json
|
|
COPY --from=builder /usr/src/app/dist/index.js ./dist/index.js
|
|
COPY --from=builder /usr/src/app/dist/migrate.js ./dist/migrate.js
|
|
COPY schema.sql ./
|
|
COPY package.json ./
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Start server
|
|
CMD ["bun", "dist/index.js"]
|