Skip to content

Commit

Permalink
Adding some documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
klakegg committed Jul 15, 2018
1 parent 8159134 commit a553b84
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Dockerfile-base
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ RUN tar -zxvf hugo.tar.gz



FROM scratch
FROM scratch AS files

COPY --from=fetch-standard /hugo /bin/hugo
COPY --from=fetch-extended /hugo /bin/hugo-extended



FROM scratch

COPY --from=files / /
31 changes: 28 additions & 3 deletions hooks/post_push
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# This is the file triggered by Docker Hub after building the initial image.

DPWD=$(pwd)

# Listing some useful commands
Expand All @@ -13,24 +15,37 @@ if [ "$SOURCE_BRANCH" = "master" ]; then
exit
fi

# tag [intial tag] [extra tag]
function tag {
# Perform tagging
echo "Tag: $1 => $(real $2)"
docker tag $DOCKER_REPO:$1 $DOCKER_REPO:$(real $2)

# Push tag
push $2
}

# build [inital tag] [Dockerfile extension] [extra tags...]
function build {
# Perform build
build_only $1 $2

# Perform verification
echo -n " Verification: "
docker run --rm $DOCKER_REPO:$1 version

# Push build
push $1

# Add extra tags
for t in ${@:3}; do
tag $1 "$t"
done
}

# build_only [initial tag] [Dockerfile extension]
function build_only {
# Detect Dockerfile extension if not set.
name=$2
if [ "$2" = "" ] || [ "$2" = "-" ]; then
if [ -e "Dockerfile-gen-$1" ]; then
Expand All @@ -40,31 +55,41 @@ function build_only {
fi
fi

# Perform build
echo "Build: $1 (Dockerfile-$name)"
docker build -t $DOCKER_REPO:$1 -f Dockerfile-$name . > /dev/null
}

# push [tag]
function push {
# Figure out full image identififer.
img=$DOCKER_REPO:$(real $1)

if [ "$CI" != "true" ]; then
# Acually push when not in a CI environment.
echo " Push: $img"
docker push $img > /dev/null
else
# Simple logging in CI environment with debug enabled.
if [ "$DEBUG" = "true" ]; then
echo " Push: $img (skipped)"
fi
fi
}

# real [tag]
function real {
echo $1 | sed -e "s/\[version\]/${SOURCE_BRANCH}/g"
}

# template [tp] [target] [from]
function template {
cat $DPWD/lib/template/Dockerfile-$1 | sed -e "s|\[from\]|${DOCKER_REPO}:${3}|g" > Dockerfile-gen-$2
cat $DPWD/lib/template/Dockerfile-$1 \
| sed -e "s|\[from\]|${DOCKER_REPO}:${3}|g" \
> Dockerfile-gen-$2
}

# trigger [dir]
function trigger {
# Go to folder
cd $DPWD/$1
Expand All @@ -78,6 +103,6 @@ function trigger {
if [ -e lib/base ]; then trigger "lib/base"; fi

# Build distributions provided
for VARIANT in $(ls $DPWD/dist); do
trigger "dist/$VARIANT"
for dist in $(ls $DPWD/dist); do
trigger "dist/$dist"
done
2 changes: 2 additions & 0 deletions hooks/travis
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# This is the file triggered by Travis.

# Setting variables for build
export DOCKER_REPO="klakegg/hugo"
export SOURCE_BRANCH="0.xx"
Expand Down

0 comments on commit a553b84

Please sign in to comment.