I am attemting to replace my secret variables inside appsetting.json file by FileTransform task in Azure pipeline and afterwards use the result of that task to build a container.
- task: FileTransform@1
displayName: FileTransform
inputs:
folderPath: '$(Build.SourcesDirectory)/MyApp'
fileType: 'json'
targetFiles: 'appsettings.json'
- task: Docker@2
displayName: Build an image
inputs:
containerRegistry: digital-ocean-docker
repository: $(imageRepository)
buildContext: $(Build.SourcesDirectory)
command: build
dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
tags: $(Build.BuildId)
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 5000
FROM node:lts-buster-slim AS node_base
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
COPY --from=node_base . .
WORKDIR /src
COPY . .
WORKDIR /src/MyApp
RUN dotnet build "MyApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]
I cant exactly figure out why when i run COPY . . in docker file old appsettings.json is used? or is it because FileTransform place transformed file somewhere else?