First off, let me start by saying I am fairly new to docker and trying to understand the dockerfile setup.
We are currently trying to convert our existing WepApi services to support containerization and orchestration. The plan is to use Docker with Kubernetes. We currently utilize multiple publish profiles with then drive the WebConfig based on the selected publish profile.
Looking through the dockerfile, I see stuff such as:
RUN dotnet restore
"Aeros.Services.Kubernetes/Aeros.Services.Kubernetes.csproj"
COPY . .
WORKDIR "/src/Aeros.Services.Kubernetes"
RUN dotnet build "Aeros.Services.Kubernetes.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "Aeros.Services.Kubernetes.csproj" -c Release -o /app
Where the -c supplies the configuration. Is there any way to get it to run this command based on the publishing profile the user has selected?
You could use an ARG
statement in your Dockerfile.
ARG publishingProfile
RUN dotnet publish "Aeros.Services.Kubernetes.csproj" -c $publishingProfile -o /app
Use it like this from the command line:docker build --build-arg publishingProfile=Release