personal_website/Dockerfile

29 lines
741 B
Docker

# Stage 1: Build the application
FROM oven/bun:1 as builder
WORKDIR /app
# Copy configuration files and install dependencies
# This layer is cached to speed up future builds
COPY package.json bun.lockb ./
COPY tsconfig.json tsconfig.node.json ./
COPY vite.config.ts postcss.config.js tailwind.config.ts ./
RUN bun install --frozen-lockfile
# Copy the rest of the source code
COPY . .
# Build the application
RUN bun run build
# Stage 2: Serve the application with Caddy
FROM caddy:2-alpine
# Copy the Caddyfile to the appropriate location
COPY Caddyfile /etc/caddy/Caddyfile
# Copy the built application from the builder stage to Caddy's serve directory
COPY --from=builder /app/dist /srv
# Expose the port Caddy listens on
EXPOSE 80