This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -1,33 +1,22 @@
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
# Install dependencies
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the app
|
||||
RUN yarn build
|
||||
|
||||
# Production stage - tiny Python server
|
||||
FROM python:3.11-alpine
|
||||
# Production stage - Caddy
|
||||
FROM caddy:2-alpine
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /usr/share/caddy
|
||||
|
||||
# Copy built static files
|
||||
COPY --from=builder /app/dist ./dist
|
||||
# Copy built static files from the builder stage
|
||||
COPY --from=builder /app/dist .
|
||||
|
||||
# Expose port
|
||||
# Expose the port Caddy will listen on
|
||||
EXPOSE 3000
|
||||
|
||||
# Set environment variable
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Start the server
|
||||
CMD ["python", "-m", "http.server", "3000", "--directory", "dist"]
|
||||
# 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"]
|
||||
|
||||
Reference in New Issue
Block a user