Dockerize Nginx with Nodejs

ref. https://dev.to/subhransu/nevertheless-subhransu-maharana-coded-5eam

Example Dockerfile

FROM node:12.8.1 as builder

COPY package*.json ./
RUN npm install  && mkdir -pv /opt/app && mv ./node_modules /opt/app/.

WORKDIR /opt/app

COPY . .

RUN npm run build
#EXPOSE 8080
# For Development ENV
#CMD [ "npm", "run", "serve" ]
FROM nginx:1.16.0-alpine
COPY --from=builder /opt/app/dist /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]

Leave a Reply

Your email address will not be published. Required fields are marked *