cmziuk/Dockerfile
2025-08-08 17:09:31 +01:00

37 lines
934 B
Docker

# Build stage
FROM oven/bun:latest as builder
WORKDIR /app
# Copy package files
COPY package.json bun.lock* ./
# Install all dependencies (including devDependencies for building)
RUN bun install --frozen-lockfile
# Copy source code and configuration files
COPY . .
# Build the frontend with Vite and compile the server to executable
RUN bun run build
# Minimal production stage using Google's distroless image (glibc-based)
FROM gcr.io/distroless/cc-debian12
WORKDIR /app
# Copy the compiled executable from the build stage
COPY --from=builder /app/dist/server /app/server
# Copy the built frontend assets (but ensure we don't overwrite the server executable)
COPY --from=builder /app/dist/*.html /app/dist/
COPY --from=builder /app/dist/assets /app/dist/assets
# Expose the port
EXPOSE 3000
# Set environment to production
ENV NODE_ENV=production
# Start the application using the compiled executable
CMD ["/app/server"]