Reputation: 5
I am creating react app and want to build and deploy the build to new container?
I am trying stages in dockerfile.
FROM node:alpine as builder
WORKDIR /app/
COPY package.json .
RUN npm install
COPY . .
RUN npm run build
FROM nginx:alpine
EXPOSE 80
Upvotes: 0
Views: 40
Reputation: 654
well the steps you followed is all correct,You just missed the part from where to copy the build folder and paste it in the nginx image. by default nginx takes files to serve from
usr/share/nginx/html
try the bellow code.
FROM node:alpine as builder
WORKDIR /app/
COPY package.json .
RUN npm install
COPY . .
RUN npm run build
FROM nginx:alpine
EXPOSE 80
COPY --from=builder /app/build /usr/share/nginx/html
if it doesnt work do comment.
Upvotes: 1