I deploying Vue app, and use method multi-stage ( with Nginx as server ) . Structure files :
- docker-compose.yml
- client ( folder code )
- Dockerfile
This is files config :
docker-compose.yml
version: '3.4'
services:
client:
build:./client
ports:
- "8080:80"
volumes:
- "./client:/app"
- "/app/node_modules"
Dockerfile
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
This run so smooth. But, when i changed content of source code and rebuild image with
docker-compose build client
docker-compose up --build
( or some arguments --no-cache, --force-recreate ... event set name for it )
It always will create new 2 image : 23.6MB and 333MB as below
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
root_ad latest 236945fbfbb5 7 minutes ago 23.6MB
<none> <none> fbdc81e7983c 7 minutes ago 333MB
<none> <none> 7969e4ba9ecf 18 minutes ago 23.6MB
<none> <none> e31655da8c88 18 minutes ago 333MB
<none> <none> 4d5cae08a889 20 minutes ago 23.6MB
<none> <none> ee369d2602a9 20 minutes ago 333MB
nginx alpine 513f9a9d8748 3 weeks ago 22.9MB
node 15.0-alpine 1e8b781248bb 11 months ago 115MB
How can i rebuild image without duplicate its ?