52 lines
998 B
Docker
52 lines
998 B
Docker
FROM oven/bun:1.3.10-alpine AS base
|
|
|
|
# Add metadata labels
|
|
LABEL maintainer="jugger@srjuggernaut.dev"
|
|
LABEL description="Blog application built with TanStack Start"
|
|
|
|
FROM base AS builder
|
|
|
|
WORKDIR /app
|
|
COPY . .
|
|
|
|
# Set proper environment
|
|
ENV BUILD=true
|
|
|
|
# Install all dependencies for build (dev + prod)
|
|
RUN bun install --frozen-lockfile
|
|
RUN bun run build
|
|
|
|
|
|
FROM base AS installer
|
|
|
|
WORKDIR /app
|
|
COPY . .
|
|
|
|
# Set proper environment
|
|
ENV NODE_ENV=production
|
|
|
|
# Install all dependencies for production
|
|
RUN bun install --frozen-lockfile --production
|
|
|
|
|
|
FROM base AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Install curl for health checks
|
|
RUN apk add --no-cache curl
|
|
|
|
COPY --from=installer /app/node_modules /app/node_modules
|
|
COPY --from=builder /app/dist /app/dist
|
|
COPY --from=builder /app/server.ts /app/server.ts
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
EXPOSE 3000/tcp
|
|
|
|
# Add health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:3000/ || exit 1
|
|
|
|
CMD ["bun", "server.ts"]
|