Hello, maybe someone could explain me:
I am building my Angular app where in Dockerfile I:
FROM node:22.1.0 AS build
<...>
# install npm dependencies, build application
<...>
FROM nginx:1.25.5 AS runtime
COPY --from=build /usr/src/root/dist/apps/browser /usr/share/nginx/html
And for the docker-compose.yml:
services:
frontend:
image: frontend
restart: unless-stopped
depends_on:
- backend
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
<...>
Now when redeploying the backend, everything is understandable - I run new backend image (via --scale and --no-recreate, so both current and new images are running), then kill the current container to only serve from new one.
What I do not understand is how exactly to perform the frontend redeploy? Do I need to create two services frontend and nginx? Or how exactly to achieve this? As I understand now the files are under /usr/share/nginx/html
directory in the frontend image? I cannot start a new frontend image (as compared to backend), since I specified a port.
I though about creating nginx and frontend different images, then the frontend image contains the files its serving and I can redeploy that? But then how to tell nginx service to take frontend files from that service? Please, someone enlighten me on this, I am lost with this. Maybe someone has a working example on this? Cheers.