Skip to content

Commit

Permalink
(build) use global tool for docker image artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Mar 7, 2020
1 parent ce54012 commit ff09583
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions build/docker-build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Task("Docker-Build")
.IsDependentOnWhen("Pack-Prepare", singleStageRun)
.Does<BuildParameters>((parameters) =>
{
var workDir = DirectoryPath.FromString($"./src/Docker");

var tool = parameters.Paths.Directories.NugetRoot.CombineWithFilePath("GitVersion.Tool*");
CopyFiles(tool.FullPath, workDir.Combine("content"));

foreach(var dockerImage in parameters.Docker.Images)
{
DockerBuild(dockerImage, parameters);
Expand Down
6 changes: 0 additions & 6 deletions build/utils/docker.cake
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ void DockerBuild(DockerImage dockerImage, BuildParameters parameters)
{
var (os, distro, targetframework) = dockerImage;
var workDir = DirectoryPath.FromString($"./src/Docker");

var sourceDir = parameters.Paths.Directories.ArtifactsBin.Combine(targetframework);

CopyDirectory(sourceDir, workDir.Combine("content"));

var tags = GetDockerTags(dockerImage, parameters);

var buildSettings = new DockerImageBuildSettings
Expand All @@ -42,7 +37,6 @@ void DockerBuild(DockerImage dockerImage, BuildParameters parameters)
BuildArg = new []
{
$"contentFolder=/content",
"DOTNET_VARIANT=runtime",
$"DOTNET_VERSION={targetframework.Replace("netcoreapp", "")}",
$"DISTRO={distro}"
},
Expand Down
11 changes: 8 additions & 3 deletions src/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
ARG DISTRO='debian-9'
ARG DOTNET_VERSION='2.1'
ARG DOTNET_VARIANT='runtime'

FROM gittools/build-images:$DISTRO-$DOTNET_VARIANT-$DOTNET_VERSION
FROM gittools/build-images:$DISTRO-sdk-$DOTNET_VERSION as installer
ARG contentFolder

WORKDIR /app
COPY $contentFolder/ ./
RUN dotnet tool install GitVersion.Tool --tool-path /tools --add-source .

ENTRYPOINT ["dotnet", "/app/gitversion.dll"]
FROM gittools/build-images:$DISTRO-runtime-$DOTNET_VERSION

WORKDIR /tools
COPY --from=installer /tools .

ENTRYPOINT ["/tools/dotnet-gitversion"]

0 comments on commit ff09583

Please sign in to comment.