forked from beedemo/jenkins-dind-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mesosphere-backup#11 from mesosphere/ubuntu-dind
Add Ubuntu Based DIND Agent
- Loading branch information
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scripts/* |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM ubuntu:16.04 | ||
|
||
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 | ||
|
||
RUN apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y \ | ||
apt-transport-https \ | ||
build-essential \ | ||
bzip2 \ | ||
ca-certificates \ | ||
ca-certificates-java \ | ||
curl \ | ||
git \ | ||
iptables \ | ||
jq \ | ||
lvm2 \ | ||
lxc \ | ||
openjdk-8-jre-headless \ | ||
unzip \ | ||
zip | ||
|
||
ENV DIND_COMMIT 3b5fac462d21ca164b3778647420016315289034 | ||
# docker | ||
RUN curl -sSL https://get.docker.com | sh | ||
# fetch DIND script | ||
RUN curl -sSL https://raw.githubusercontent.com/docker/docker/${DIND_COMMIT}/hack/dind -o /usr/local/bin/dind \ | ||
&& chmod a+x /usr/local/bin/dind | ||
|
||
COPY ./wrapper.sh /usr/local/bin/wrapper.sh | ||
RUN chmod a+x /usr/local/bin/wrapper.sh | ||
|
||
VOLUME /var/lib/docker | ||
ENTRYPOINT [] | ||
CMD [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
TAG=${GIT_BRANCH#*/} | ||
|
||
function usage() { | ||
echo "$0 <image name> [yes] [tag prefix]" | ||
echo "build Jenkins DIND Agent docker images." | ||
echo "" | ||
echo "<image name> is the image name, with prefix." | ||
echo "[yes] is optional; include to also push images to docker hub." | ||
echo "[tag prefix] is optional; include to overwrite using the git branch." | ||
echo "" | ||
exit -1 | ||
} | ||
|
||
function preflight { | ||
if [ ! -d ".git" ] | ||
then | ||
echo "This directory does not contain a .git directory." | ||
echo "Please run this script from the jenkins-dind-agent root directory." | ||
echo "" | ||
exit -2 | ||
fi | ||
} | ||
|
||
function dock_build { | ||
local image=$1 | ||
local tag=$2 | ||
local file=$3 | ||
|
||
echo "Building $image:$tag ..." | ||
docker build -t $image:$tag -f $file . | ||
} | ||
|
||
function dock_push { | ||
local image=$1 | ||
local tag=$2 | ||
|
||
echo "Pushing $image:$tag ..." | ||
docker push $image:$tag | ||
} | ||
|
||
function build_images() { | ||
if [ "x$1" == "x" ] | ||
then | ||
usage | ||
else | ||
image_name="$1" | ||
fi | ||
|
||
if [ "x$3" != "x" ] | ||
then | ||
TAG=$3 | ||
fi | ||
|
||
preflight | ||
|
||
for i in Dockerfile* | ||
do | ||
local possible_tag=${i#*.} | ||
local tag_suffix="" | ||
if [ "$possible_tag" != "Dockerfile" ] | ||
then | ||
tag_suffix="-${possible_tag}" | ||
fi | ||
|
||
final_tag="$TAG${tag_suffix}" | ||
|
||
dock_build "$image_name" "$final_tag" "$i" | ||
|
||
if [ "x$2" == "xyes" ] | ||
then | ||
dock_push "$image_name" "$final_tag" | ||
fi | ||
done | ||
} | ||
|
||
build_images $1 $2 $3 |