Reputation: 121
I'm building an Azure DevOps pipeline for a dotnet core project. After the dotnet publish command executes the artifacts get saved in $(artifactStagingDirectory). How do I copy these artifacts from the staging directory to the docker image?
I am not building project in dockerfile. I am executing dotnet publish in pipeline.
I have tried to save artifacts to another folder by using:
dotnet publish --configuration $(BuildConfiguration) --output out
Upvotes: 10
Views: 9935
Reputation: 1
When downloading a secureFile (via the DownloadSecureFile
task), the buildContext needs to be $(Agent.TempDirectory)
. Be aware that with this
certain buildcontext, you only need to pass the filename of the securefile,
not the entire path.
Example:
- task: Docker@2
displayName: 'Build image that relies on a SecureFile'
inputs:
command: 'build'
# Explicit path reference due to the buildContext
Dockerfile: '$(Build.Repository.LocalPath)/Docker/Dockerfile'
tags: |
<your tag here>
arguments: |
--build-arg DOCKERFILE_ARG=<secure_file_name>
buildContext: $(Agent.TempDirectory)
Upvotes: 0
Reputation: 2172
Publishing to $(Build.ArtifactStagingDirectory) is fine. There are several ways to do it, so here's one:
Set up the Dockerfile like this (I'm assuming .NET Core 2.2 here):
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "myAppNameHere.dll"]
Because you've set the Docker Build Context to $(Build.ArtifactStagingDirectory), where your app has been published, the COPY command will use that as a "current working directory." The translation of the COPY is "copy everything in $(Build.ArtifactStagingDirectory) to the /app folder inside the container."
That'll get you a basic Docker container that simply contains your pre-built and published app files.
Upvotes: 16