37 lines
741 B
Docker
37 lines
741 B
Docker
# Stage 1: Build client
|
|
FROM node:18-alpine AS client-builder
|
|
WORKDIR /client
|
|
COPY client/package*.json ./
|
|
RUN npm ci
|
|
COPY client/ .
|
|
RUN npm run build
|
|
|
|
# Stage 2: Production image
|
|
FROM nginx:alpine
|
|
|
|
# Install Node.js for the server
|
|
RUN apk add --no-cache nodejs npm
|
|
|
|
# Remove default nginx config
|
|
RUN rm /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy custom nginx config
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy client build
|
|
COPY --from=client-builder /client/dist /usr/share/nginx/html
|
|
|
|
# Copy server
|
|
WORKDIR /server
|
|
COPY server/package*.json ./
|
|
RUN npm ci --omit=dev
|
|
COPY server/ .
|
|
|
|
# Copy entrypoint
|
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
|
RUN chmod +x /docker-entrypoint.sh
|
|
|
|
EXPOSE 80
|
|
|
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|