In a multistage Docker build, should the WORKDIR be deleted? My Dockerfile contains this:
### STAGE 1: Build Angular app ###
FROM node:14.15 AS build
WORKDIR /usr/src/app
COPY src/hub/package.json ./
RUN npm cache verify
RUN npm install
COPY src/hub/ .
RUN npm run-script build-azdev
RUN npm prune --production

### STAGE 2: Run Angular app in nginx ###
FROM nginx:1.19-alpine
COPY /scripts/nginx/nginx.conf /etc/nginx/nginx.conf
RUN rm -rf /usr/share/nginx/html/*
COPY --from=build /usr/src/app/dist/* /usr/share/nginx/html/
EXPOSE 80
CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]

Once COPY --from=build /usr/src/app/dist/* /usr/share/nginx/html/ is done, should the contents of WORKDIR (/usr/src/app) be deleted once Stage 2 is done building?
When creating an image using a Dockerfile, docker layers are created for each step. The description of layers can be found on the official docker page.
Accordingly, when using Multistage to create an image, it introduces a new build step that can be named using an alias in the FROM statement, and all layers except the image layer created via the last FROM statement are deleted.
After build your image, check if the layer that contains WORKDIR whether exists or not using docker image inspect. I think you probably know the unique layer value for each step.
You can see the image consists with which layers.
e.g.,
$docker image inspect [OPTIONS] 464503b73bfe # IMAGE
[
    {
        &quot;Id&quot;: &quot;sha256:464bf1...46c&quot;,
        ...

        &quot;RootFS&quot;: {
            &quot;Type&quot;: &quot;layers&quot;,
            &quot;Layers&quot;: [
                &quot;sha256:26711...8fcf&quot;,
                &quot;sha256:6c5a51...56e0&quot;
            ]
        },
        ...