34 lines
698 B
Docker
34 lines
698 B
Docker
# Stage 1: Build the application
|
|
FROM node:20-alpine as builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json yarn.lock ./
|
|
|
|
# Install dependencies
|
|
RUN yarn install
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
# Note: Vite embeds VITE_ env vars at build time.
|
|
# Ensure .env is present or args are passed if dynamic config is needed.
|
|
RUN yarn build
|
|
|
|
# Stage 2: Serve with Nginx
|
|
FROM nginx:alpine
|
|
|
|
# Remove default nginx static assets
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copy built assets from builder stage
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Copy custom nginx config
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"] |