I am new to Docker, I have a React.js app with the build forder (npm run build
), I want to dockerize my app to make a container.
I made a Dockerfile with
Yes, you can achieve this using multistage Dockerfile, I'm using this for VueJS and Angular.
Bonus: you can use NGINX for proxying your requests to your app.
NGINX config and .dockerignore files can be found here.
##### 01- Build app
FROM node:lts-alpine as node
LABEL author="Waqas Dilawar"
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build
##### 02- Run NGINX using build from step 01
FROM nginx:alpine
VOLUME /var/cache/nginx
COPY --from=node /app/dist /usr/share/nginx/html
COPY ./config/nginx.conf /etc/nginx/conf.d/default.conf