2026-02-09 10:17:48 +03:00
|
|
|
# Build stage
|
|
|
|
|
FROM node:20-alpine AS builder
|
|
|
|
|
WORKDIR /app
|
2026-02-09 14:21:33 +03:00
|
|
|
# Enable Corepack so we can use Yarn v4
|
|
|
|
|
RUN corepack enable && corepack prepare yarn@stable --activate
|
2026-02-09 10:17:48 +03:00
|
|
|
COPY package.json yarn.lock ./
|
2026-02-09 14:21:33 +03:00
|
|
|
RUN yarn install --immutable
|
2026-02-09 10:17:48 +03:00
|
|
|
COPY . .
|
|
|
|
|
RUN yarn build
|
|
|
|
|
|
2026-02-09 11:37:47 +03:00
|
|
|
# Production stage - Caddy
|
|
|
|
|
FROM caddy:2-alpine
|
2026-02-09 10:17:48 +03:00
|
|
|
|
2026-02-09 11:37:47 +03:00
|
|
|
WORKDIR /usr/share/caddy
|
2026-02-09 10:17:48 +03:00
|
|
|
|
2026-02-09 11:37:47 +03:00
|
|
|
# Copy built static files from the builder stage
|
|
|
|
|
COPY --from=builder /app/dist .
|
2026-02-09 10:44:51 +03:00
|
|
|
|
2026-02-09 11:37:47 +03:00
|
|
|
# Expose the port Caddy will listen on
|
2026-02-09 10:44:51 +03:00
|
|
|
EXPOSE 3000
|
|
|
|
|
|
2026-02-09 11:37:47 +03:00
|
|
|
# Start Caddy as a file server with SPA support
|
|
|
|
|
# It serves files from the current dir and redirects unknown paths to index.html
|
|
|
|
|
CMD ["caddy", "file-server", "--listen", ":3000", "--try-files", "index.html"]
|