Introduce Dockerfile with production build using Bun, .dockerignore for efficient builds, and docker-compose.yml for easy local and prod deployment on port 3000.
32 lines
626 B
Docker
32 lines
626 B
Docker
# Use the official Bun base image
|
|
FROM oven/bun:latest AS base
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json bun.lock* ./
|
|
|
|
# Install dependencies
|
|
RUN bun install --frozen-lockfile
|
|
|
|
# Copy source code
|
|
COPY src ./src
|
|
COPY tsconfig.json ./
|
|
|
|
# Build the application for production
|
|
RUN bun build ./src/index.ts --outdir ./dist --minify
|
|
|
|
# Multi-stage build - runtime stage
|
|
FROM oven/bun:latest AS runtime
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the built application from the base stage
|
|
COPY --from=base /app/dist/ ./
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["bun", "index.js"] |