# syntax=docker/dockerfile:1.4 FROM node:18-alpine AS development WORKDIR /app # Fix Alpine repo and install build dependencies RUN sed -i -e 's|http://dl-cdn.alpinelinux.org|https://dl-cdn.alpinelinux.org|' /etc/apk/repositories \ && apk update \ && apk add --no-cache python3 make g++ # Copy package files COPY package.json package-lock.json ./ # Install dependencies RUN npm ci --legacy-peer-deps # Copy source code COPY . . ENV CI=true ENV PORT=3000 CMD ["npm", "start"] # Build stage FROM development AS build RUN npm run build # Production stage FROM nginx:alpine AS production WORKDIR /usr/share/nginx/html # Remove default nginx files RUN rm -rf ./* # Copy built app COPY --from=build /app/build . # Copy nginx config if it exists COPY .nginx/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 ENTRYPOINT ["nginx", "-g", "daemon off;"]