smartclass-ops / frontend /Dockerfile
balaji958685's picture
Add frontend Dockerfile
cf295d6 verified
Raw
History Blame Contribute Delete
1.02 kB
# ─── SmartClass Frontend ─────────────────────────────────────────────
# Stage 1: Build React app
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci
# Build argument for API URL (baked into build)
ARG VITE_API_URL=http://localhost:8000
ENV VITE_API_URL=${VITE_API_URL}
# Copy source and build
COPY . .
RUN npm run build
# Stage 2: Serve with nginx
FROM nginx:alpine AS production
LABEL maintainer="SmartClass Team"
LABEL description="SmartClass Frontend - React + Nginx"
# Custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built app from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Health check
HEALTHCHECK --interval=15s --timeout=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:80/ || exit 1
CMD ["nginx", "-g", "daemon off;"]