Skip to content

Commit

Permalink
fixup! fixup! fixup! Distill to single Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
hairyhenderson committed Nov 1, 2019
1 parent cc8e9a0 commit 4756e9b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ARG DIST_COMMIT=97bcdfccf5392c650216ebb0634a5ed4c680ad6a

WORKDIR /src/dist
RUN git clone https://github.com/caddyserver/dist .
RUN git checkout ${DIST_COMMIT}
RUN git checkout $DIST_COMMIT

RUN cp config/Caddyfile /Caddyfile
RUN cp welcome/index.html /index.html
Expand Down Expand Up @@ -55,8 +55,6 @@ CMD [ "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

FROM scratch AS scratch

COPY build/files .

COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs
COPY --from=builder /etc/passwd /etc/passwd
Expand Down
19 changes: 9 additions & 10 deletions hooks/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@
set -exuo pipefail

echo "=== Build hook running"
export VCS_REF=`git rev-parse --short HEAD`
VCS_REF=$(git rev-parse --short HEAD)
export VCS_REF
export DOCKER_REPO=${DOCKER_REPO:-caddy/caddy}
export DOCKER_TAG=${DOCKER_TAG:-latest}
export IMAGE_NAME=${IMAGE_NAME:-${DOCKER_REPO}:${DOCKER_TAG}}


if (git describe --abbrev=0 --exact-match &>/dev/null); then
export VERSION=$(git describe --abbrev=0 --exact-match)
VERSION=$(git describe --abbrev=0 --exact-match)
else
export VERSION=0.0.0-devel
VERSION=0.0.0-devel
fi
export VERSION

tags=( alpine scratch )
for tag in ${tags[@]}; do
echo "=== Building ${DOCKER_REPO}:${tag}"
for tag in "${tags[@]}"; do
echo "=== Building $DOCKER_REPO:$tag"
docker build \
--build-arg VCS_REF \
--build-arg VERSION \
--target ${tag} \
--tag ${DOCKER_REPO}:${tag} \
--target "$tag" \
--tag "$DOCKER_REPO:$tag" \
.
done

# :latest tracks scratch, for now
docker tag ${DOCKER_REPO}:scratch ${IMAGE_NAME}
34 changes: 17 additions & 17 deletions hooks/post_push
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ set -exuo pipefail

export DOCKER_REPO=${DOCKER_REPO:-caddy/caddy}
export DOCKER_TAG=${DOCKER_TAG:-latest}
export IMAGE_NAME=${IMAGE_NAME:-${DOCKER_REPO}:${DOCKER_TAG}}
export IMAGE_NAME=${IMAGE_NAME:-$DOCKER_REPO:$DOCKER_TAG}

docker push ${DOCKER_REPO}:alpine
docker push ${DOCKER_REPO}:scratch
docker push "$DOCKER_REPO:alpine"
docker push "$DOCKER_REPO:scratch"

# This magic figures out if we're currently on a tag (i.e. a release).
# We only want to have special tags for releases.
Expand All @@ -18,19 +18,19 @@ if (git describe --abbrev=0 --exact-match &>/dev/null); then
# minor=${tag%\.*}

# make sure latest is tagged when it's a versioned build too
docker tag ${DOCKER_REPO}:scratch ${DOCKER_REPO}:latest
docker tag ${DOCKER_REPO}:scratch ${DOCKER_REPO}:${tag}
docker tag ${DOCKER_REPO}:scratch ${DOCKER_REPO}:${major}
docker tag ${DOCKER_REPO}:scratch ${DOCKER_REPO}:${tag}-scratch
docker tag ${DOCKER_REPO}:scratch ${DOCKER_REPO}:${major}-scratch
docker tag ${DOCKER_REPO}:alpine ${DOCKER_REPO}:${tag}-alpine
docker tag ${DOCKER_REPO}:alpine ${DOCKER_REPO}:${major}-alpine
docker tag "$DOCKER_REPO:scratch" "$DOCKER_REPO:latest"
docker tag "$DOCKER_REPO:scratch" "$DOCKER_REPO:$tag"
docker tag "$DOCKER_REPO:scratch" "$DOCKER_REPO:$major"
docker tag "$DOCKER_REPO:scratch" "$DOCKER_REPO:${tag}-scratch"
docker tag "$DOCKER_REPO:scratch" "$DOCKER_REPO:${major}-scratch"
docker tag "$DOCKER_REPO:alpine" "$DOCKER_REPO:${tag}-alpine"
docker tag "$DOCKER_REPO:alpine" "$DOCKER_REPO:${major}-alpine"

docker push ${DOCKER_REPO}:latest
docker push ${DOCKER_REPO}:${tag}
docker push ${DOCKER_REPO}:${major}
docker push ${DOCKER_REPO}:${tag}-scratch
docker push ${DOCKER_REPO}:${major}-scratch
docker push ${DOCKER_REPO}:${tag}-alpine
docker push ${DOCKER_REPO}:${major}-alpine
docker push "$DOCKER_REPO:latest"
docker push "$DOCKER_REPO:$tag"
docker push "$DOCKER_REPO:$major"
docker push "$DOCKER_REPO:${tag}-scratch"
docker push "$DOCKER_REPO:${major}-scratch"
docker push "$DOCKER_REPO:${tag}-alpine"
docker push "$DOCKER_REPO:${major}-alpine"
fi

0 comments on commit 4756e9b

Please sign in to comment.