Skip to content

Feature/docker #1215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM gittools/libgit2sharp-mono

MAINTAINER GitTools Maintainers <[email protected]>
ARG GitVersionZip

# Add GitVersion

ADD ./releaseArtifacts/$GitVersionZip .
RUN unzip -d /usr/lib/GitVersion/ $GitVersionZip
RUN rm $GitVersionZip
WORKDIR /usr/lib/GitVersion/

# Libgit2 can't resolve relative paths, patch to absolute path
RUN sed -i 's|lib/linux/x86_64|/usr/lib/GitVersion/lib/linux/x86_64|g' /usr/lib/GitVersion/LibGit2Sharp.dll.config

RUN mkdir /repo
VOLUME /repo

ENTRYPOINT ["mono", "./GitVersion.exe", "/repo"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ works out the [semantic version][semver] of the commit being built.
| **GitVersion.CommandLine** | [![NuGet][gvc-badge]][gvc] | [![NuGet][gvc-pre-badge]][gvc] |
| **Gem** | [![Gem][gem-badge]][gem] | - |
| **Homebrew** | [![homebrew][brew-badge]][brew] | - |
| **Docker** | [gittools/gitversion][dockerhub] | - |

## Compatibility
GitVersion works on Mac, Linux with Mono and Windows.
Expand Down Expand Up @@ -84,3 +85,4 @@ from The Noun Project
[faq]: http://gitversion.readthedocs.org/en/latest/faq/
[who]: http://gitversion.readthedocs.org/en/latest/who/
[gv-in-action]: https://raw.github.com/GitTools/GitVersion/master/docs/img/README.png
[dockerhub]: https://hub.docker.com/r/gittools/gitversion/
3 changes: 2 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ Task("Create-Release-Notes")
var releaseNotesExitCode = StartProcess(
@"tools\GitReleaseNotes\tools\gitreleasenotes.exe",
new ProcessSettings { Arguments = ". /o build/releasenotes.md /repoToken " + githubToken });
if (string.IsNullOrEmpty(System.IO.File.ReadAllText("./build/releasenotes.md")))
if (!System.IO.File.Exists("./build/releasenotes.md") || string.IsNullOrEmpty(System.IO.File.ReadAllText("./build/releasenotes.md"))) {
System.IO.File.WriteAllText("./build/releasenotes.md", "No issues closed since last release");
}

if (releaseNotesExitCode != 0) throw new Exception("Failed to generate release notes");
}
Expand Down
47 changes: 47 additions & 0 deletions deploy.cake
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Task("DownloadGitHubReleaseArtifacts")
if (!artifactLookup.ContainsKey("NuGetExeBuild")) { throw new Exception("NuGetExeBuild artifact missing"); }
if (!artifactLookup.ContainsKey("GemBuild")) { throw new Exception("GemBuild artifact missing"); }
if (!artifactLookup.ContainsKey("GitVersionTfsTaskBuild")) { throw new Exception("GitVersionTfsTaskBuild artifact missing"); }
if (!artifactLookup.ContainsKey("zip")) { throw new Exception("zip artifact missing"); }
});

Task("Publish-NuGetPackage")
Expand Down Expand Up @@ -174,13 +175,59 @@ Task("Publish-VstsTask")
}
});


Task("Publish-DockerImage")
.IsDependentOn("DownloadGitHubReleaseArtifacts")
.Does(() =>
{
var returnCode = StartProcess("docker", new ProcessSettings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using the Cake.Docker addin for this?

https://github.com/MihaMarkic/Cake.Docker

{
Arguments = "build . --build-arg GitVersionZip=" + artifactLookup["zip"] + " --tag gittools/gitversion"
});
if (returnCode != 0) {
Information("Publish-DockerImage Task failed to build image, but continuing with next Task...");
publishingError = true;
}

// Login to dockerhub
returnCode = StartProcess("docker", new ProcessSettings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using the Cake.Docker addin for this?

https://github.com/MihaMarkic/Cake.Docker

{
Arguments = "login -u=\"" + EnvironmentVariable("DOCKER_USERNAME") +"\" -p=\"" + EnvironmentVariable("DOCKER_PASSWORD") +"\""
});
if (returnCode != 0) {
Information("Publish-DockerImage Task failed to login, but continuing with next Task...");
publishingError = true;
}

// Publish Tag
returnCode = StartProcess("docker", new ProcessSettings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using the Cake.Docker addin for this?

https://github.com/MihaMarkic/Cake.Docker

{
Arguments = "push gittools/gitversion:" + tag
});
if (returnCode != 0) {
Information("Publish-DockerImage Task failed push version tag, but continuing with next Task...");
publishingError = true;
}

// Publish latest
returnCode = StartProcess("docker", new ProcessSettings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using the Cake.Docker addin for this?

https://github.com/MihaMarkic/Cake.Docker

{
Arguments = "push gittools/gitversion:latest"
});
if (returnCode != 0) {
Information("Publish-DockerImage Task failed latest tag, but continuing with next Task...");
publishingError = true;
}
});

Task("Deploy")
.IsDependentOn("Publish-NuGetPackage")
.IsDependentOn("Publish-NuGetCommandLine")
.IsDependentOn("Publish-MsBuildTask")
.IsDependentOn("Publish-Chocolatey")
// .IsDependentOn("Publish-Gem")
.IsDependentOn("Publish-VstsTask")
.IsDependentOn("Publish-DockerImage")
.Finally(() =>
{
if(publishingError)
Expand Down
13 changes: 13 additions & 0 deletions src/DockerBase/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu

MAINTAINER GitTools Maintainers <[email protected]>

# Wheezy doesn't support glibc 2.15 which libgit2sharp requires
# So we are going to install mono on ubuntu instead
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN apt-get update
RUN apt-get install libcurl3 tzdata unzip curl git-all -y
RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list
RUN apt-get update
RUN apt-get install mono-complete -y
RUN cp /usr/share/zoneinfo/GMT /etc/localtime
6 changes: 6 additions & 0 deletions src/DockerBase/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Docker Base
We need a custom docker base image because mono is too old to support libgit2sharp

## To build/publish
docker build . --tag gittools/libgit2sharp-mono
docker push gittools/libgit2sharp-mono