my task is to build the Single-Page-Application (Stage 1) and then serve it with NGNIX (Stage 2)
FROM node:8.11.4-alpine AS build
COPY . .
RUN npm install
RUN npm run build
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/conf.d/default.conf /etc/nginx/conf.d/
COPY --from=build /usr/local/app/dist/MY-APP /usr/share/nginx/html
In Stage 1 I copy all the src files into the build container. To improve this process I created a .dockerignore (as it is suggested in the docs). For the build I obviously do not need the nginx files. Therefore they are part of the .dockerignore.
The problem - as soon as the Stage 2 begins, the ngnix entry in the .dockerignore file prevents that the ngnix files can be copied! So the only working solution so far is to remove ngnix from the .dockerignore and therefore copy it into without any need the build container (Stage 1). This is not how it should be!
Feature request - provide a better multi-stage .dockerignore support.
There are probably several solution designs possible.
My personal solution idea would be a “block definition” in .dockerignore similar to the one used in the Dockerfile (here it is separated by the ‘FROM’ keyword)
So, what is your opinion to this guys?
Any other solutions or thoughts?