In runtime-deps images, we set the environment variables after we install dependencies and other instructions. Since the environment variables basically never change, we should be able to put the ENV instruction before the dependency installation to take advantage of layer caching.
Also, in some runtime-deps Dockerfiles with a non-root user defined, it is defined after the deps install. We should be able to make the same optimization with these instructions too.
Example Dockerfile with potential for both optimizations: https://github.com/dotnet/dotnet-docker/blob/nightly/src/runtime-deps/7.0/cbl-mariner2.0-distroless/amd64/Dockerfile
In runtime-deps images, we set the environment variables after we install dependencies and other instructions. Since the environment variables basically never change, we should be able to put the
ENVinstruction before the dependency installation to take advantage of layer caching.Also, in some runtime-deps Dockerfiles with a non-root user defined, it is defined after the deps install. We should be able to make the same optimization with these instructions too.
Example Dockerfile with potential for both optimizations: https://github.com/dotnet/dotnet-docker/blob/nightly/src/runtime-deps/7.0/cbl-mariner2.0-distroless/amd64/Dockerfile