FROM node:12.19.0-alpine as build-stage WORKDIR /app RUN apk add --update \ python \ python-dev \ py-pip \ build-base \ git \ openssh-client \ && pip install virtualenv \ && rm -rf /var/cache/apk/* # Copy only package files first COPY package*.json ./ # Install deps RUN npm install # Copy the rest of the source code but NOT node_modules COPY . . # Make sure scripts are executable RUN chmod +x node_modules/.bin/* # Build the production assets RUN npm run dev FROM nginx:stable-alpine as production-stage COPY --from=build-stage /app/public /usr/share/nginx/html COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]