I have a Blazor webassembly project which I have dockerized and I'm trying to read environment variables set in the container on startup. If I do the following I am able to run a shell in the container and echo the variable.
docker run -e DEBUG=false --name blazortest dockerizedclientsideblazor
However if I try to read the environment variable in the application using this command.
Environment.GetEnvironmentVariable("DEBUG")
It returns as null and it's the same for trying to read mounted files. Can explain to me why I'm experiencing this?
My Dockerfile looks like this.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
COPY . ./
RUN ls -la ./
RUN dotnet publish -c Release -o output
FROM nginx:alpine
WORKDIR /var/www/web
COPY --from=build-env /app/output/wwwroot .
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80 443