Optimize Docker Build
In the previous Odd-e Boring Gathering at Hangzhou, I spent time pair programming with other Odd-e nerds. That was fun! I have learned a few things and I would like to share one of them today regarding writing `Dockerfile`. I learn that writing `Dockerfile` like below is going to slow the whole team down a lot as everyone would be spending a lot of time downloading packages. ``` FROM maven:slim as build-stage COPY ./ ./ RUN mvn install CMD mvn spring-boot:run ``` The problem is every time we run `docker build` after changing a source file, the docker will know that the image is dirty since the 2nd line (`COPY ./ ./`) ref: