44 lines
721 B
Docker
44 lines
721 B
Docker
# syntax=docker/dockerfile:1.4
|
|
|
|
FROM node:18-alpine AS development
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN 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;"] |