Reputation: 1145
my docker file is as below
FROM node:16.16.0 as ui
WORKDIR /app
COPY ./ui/package.json .
RUN npm install
COPY ./ui/ .
WORKDIR /admin
COPY ./admin/package.json .
RUN npm install
COPY ./admin/ .
FROM ui as ui1
WORKDIR /app
RUN npm run build
WORKDIR /admin
RUN npm run build
FROM nginx
EXPOSE 3000 5001
COPY ./nginx/prod.conf /etc/nginx/conf.d/default.conf
COPY --from=ui1 /app/build /usr/share/nginx/html
COPY --from=ui1 /admin/build /usr/share/nginx/admin
Everything working fine as expected , but each time the eb deploy
is taking more than 4 minutes.Its a simple app with react hello world page.
First time its fine since it installs node , packages etc.. but second time if i just change some content in app and redeploy , again its taking 4 to 5 minutes.
I have tried eb deploy --staged
, it still takes same time.
Below is my docker compose
version: "3"
services:
backend:
build:
context: ./backend
volumes:
- /app/node_modules
- ./backend:/app
nginx:
volumes:
- ./nginx/prod.conf:/etc/nginx/conf.d/default.conf
restart: always
build:
context: ./
ports:
- "80:80"
Upvotes: 3
Views: 573
Reputation: 753
From amazon docs: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.rolling-version-deploy.html
The updates use an immutable deployment mechanism. This ensures that Elastic Beanstalk provisions a parallel fleet of Amazon EC2 instances with the updates installed before swapping out and terminating the existing instances.
I had a similar case with ECS (Elastic Container Service). The 101 is to not terminate old version of the application until a new one proves itself to be stable, meaning it will remain in a HEALTHY state for X seconds. You should be able to adjust this by reconfiguring targets of attached load balancer.
Now, for the part of Docker, please review your dockerfile and see if you can benefit from multistage build. It appears to me that any change triggers almost all the steps of your Dockerfile. 4 minutes for multiple npm run build doesn't seem like a lot. That being said, if you introduce multistage build, you can build them separately, and copy the results in the final stage. You should benefit from Docker caching by doing so.
Upvotes: 3