sumarsono.com
Take it with a grain of salt


Dockerized Reactjs

Posted on

Dockerfile reactjs

FROM node:14-alpine AS builder
#ENV NODE_ENV production

WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:stable-alpine as production
#ENV NODE_ENV production

COPY --from=builder /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

docker-compose reactjs

version: '3.8'

services:
  myapp:
    deploy:
      mode: replicated
      replicas: 2 
    image: registry.domain.tld/sumar/myapp:latest
    restart: always
    networks:
      - proxy-network

networks:
  proxy-network:
    external: true