diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c77232 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Use Alpine Linux as our base image so that we minimize the overall size our final container, and minimize the surface area of packages that could be out of date. +FROM alpine:3.9@sha256:b3dbf31b77fd99d9c08f780ce6f5282aba076d70a513a8be859d8d3a4d0c92b8 + +LABEL description="Docker container for building static sites with the Hugo static site generator." +LABEL maintainer="Johannes Mitlmeier " +LABEL maintainer="Drew Short " + +# config +ARG HUGO_VERSION=0.61 +ENV HUGO_TYPE=_extended +ENV HUGO_ID=hugo${HUGO_TYPE}_${HUGO_VERSION} + +VOLUME /src +VOLUME /output + +WORKDIR /src +CMD ["/run.sh"] + +EXPOSE 1313 + +COPY ./run.sh /run.sh +ADD https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_ID}_Linux-64bit.tar.gz /tmp +RUN tar -xf /tmp/${HUGO_ID}_Linux-64bit.tar.gz -C /tmp \ + && mkdir -p /usr/local/sbin \ + && mv /tmp/hugo /usr/local/sbin/hugo \ + && rm -rf /tmp/${HUGO_ID}_linux_amd64 \ + && rm -rf /tmp/${HUGO_ID}_Linux-64bit.tar.gz \ + && rm -rf /tmp/LICENSE.md \ + && rm -rf /tmp/README.md + +RUN apk add --update git asciidoctor libc6-compat libstdc++ tar \ + && apk upgrade \ + && apk add --no-cache ca-certificates \ + && chmod 0777 /run.sh diff --git a/pipeline.yml b/pipeline.yml new file mode 100644 index 0000000..2014d47 --- /dev/null +++ b/pipeline.yml @@ -0,0 +1,31 @@ +--- +resources: + - name: git-resource + type: git + icon: git + source: + uri: ssh://git@git.nulloctet.com:8437/docker/hugo.git + private_key: | + ((pull_key)) + ignore_paths: + - pipeline.yml + - upload_pipeline.sh + - README.md + - name: git-resource-image + type: docker-image + icon: docker + source: + repository: ((nexus_docker_write.host))/sothr/hugo + username: ((nexus_docker_write.username)) + password: ((nexus_docker_write.password)) + +jobs: + - name: build-image + plan: + - get: git-resource + trigger: true + - put: git-resource-image + params: + build: git-resource + tag_file: git-resource/tag + tag_as_latest: true diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..b141a74 --- /dev/null +++ b/run.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +WATCH="${HUGO_WATCH:=false}" +SLEEP="${HUGO_REFRESH_TIME:=-1}" +HUGO_SOURCE="${HUGO_SOURCE:=/src}" +HUGO_DESTINATION="${HUGO_DESTINATION:=/output}" +echo "HUGO_WATCH:" $WATCH +echo "HUGO_REFRESH_TIME:" $HUGO_REFRESH_TIME +echo "HUGO_THEME:" $HUGO_THEME +echo "HUGO_BASEURL" $HUGO_BASEURL +echo "ARGS" $@ + +HUGO=/usr/local/sbin/hugo +echo "Hugo path: $HUGO" + +while [ true ] +do + if [[ $HUGO_WATCH != 'false' ]]; then + echo "Watching..." + $HUGO server --watch --source "$HUGO_SOURCE" --theme "$HUGO_THEME" --destination "$HUGO_DESTINATION" --baseURL "$HUGO_BASEURL" --bind "0.0.0.0" "$@" || exit 1 + else + echo "Building one time..." + $HUGO --source "$HUGO_SOURCE" --theme "$HUGO_THEME" --destination "$HUGO_DESTINATION" --baseURL "$HUGO_BASEURL" "$@" || exit 1 + fi + + if [[ $HUGO_REFRESH_TIME == -1 ]]; then + exit 0 + fi + echo "Sleeping for $HUGO_REFRESH_TIME seconds..." + sleep $SLEEP +done diff --git a/tag b/tag new file mode 100644 index 0000000..6e8cb1e --- /dev/null +++ b/tag @@ -0,0 +1 @@ +0.61 diff --git a/upload_pipeline.sh b/upload_pipeline.sh new file mode 100755 index 0000000..0d2a02a --- /dev/null +++ b/upload_pipeline.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +TEAM=docker +PIPELINE=hugo + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +pushd "${DIR}" + +fly -t ${TEAM} set-pipeline --pipeline ${PIPELINE} --config pipeline.yml + +popd