From 74040cfab7a60eb9c1ca0652f316dcb3316f4d15 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Thu, 15 Oct 2020 11:28:20 +0200 Subject: [PATCH] refactor: dockerfiles versioning using new SERVER_VERSION env --- docker/alpine/Dockerfile | 9 +++++++-- docker/alpine/tmpl.Dockerfile | 28 ---------------------------- docker/scratch/Dockerfile | 9 +++++++-- docker/scratch/tmpl.Dockerfile | 18 ------------------ docker/version.sh | 37 ------------------------------------- 5 files changed, 14 insertions(+), 87 deletions(-) delete mode 100644 docker/alpine/tmpl.Dockerfile delete mode 100644 docker/scratch/tmpl.Dockerfile delete mode 100755 docker/version.sh diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index dfee03d..5c6c83d 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -1,6 +1,11 @@ FROM alpine:3.11 -LABEL maintainer="Jose Quintana " +ARG SERVER_VERSION=0.0.0 +ENV SERVER_VERSION=${SERVER_VERSION} + +LABEL version="${SERVER_VERSION}" \ + description="A blazing fast static files-serving web server powered by Rust Iron." \ + maintainer="Jose Quintana " RUN apk --no-cache add ca-certificates tzdata RUN set -ex; \ @@ -24,5 +29,5 @@ LABEL org.opencontainers.image.vendor="Jose Quintana" \ org.opencontainers.image.url="https://github.com/joseluisq/static-web-server" \ org.opencontainers.image.title="Static Web Server" \ org.opencontainers.image.description="A blazing fast static files-serving web server powered by Rust Iron." \ - org.opencontainers.image.version="v1.10.0" \ + org.opencontainers.image.version="${SERVER_VERSION}" \ org.opencontainers.image.documentation="https://github.com/joseluisq/static-web-server" diff --git a/docker/alpine/tmpl.Dockerfile b/docker/alpine/tmpl.Dockerfile deleted file mode 100644 index 9b73267..0000000 --- a/docker/alpine/tmpl.Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM alpine:$ALPINE_VERSION - -LABEL maintainer="Jose Quintana " - -RUN apk --no-cache add ca-certificates tzdata -RUN set -ex; \ - apkArch="$(apk --print-arch)"; \ - case "$apkArch" in \ - armhf) arch='armv6' ;; \ - aarch64) arch='arm64' ;; \ - x86_64) arch='amd64' ;; \ - *) echo >&2 "error: unsupported architecture: $apkArch"; exit 1 ;; \ - esac; - -COPY ./docker/alpine/entrypoint.sh / -COPY ./bin/static-web-server /usr/local/bin/ -COPY ./public /public -EXPOSE 80 -ENTRYPOINT ["/entrypoint.sh"] -CMD ["static-web-server"] - -# Metadata -LABEL org.opencontainers.image.vendor="Jose Quintana" \ - org.opencontainers.image.url="https://github.com/joseluisq/static-web-server" \ - org.opencontainers.image.title="Static Web Server" \ - org.opencontainers.image.description="A blazing fast static files-serving web server powered by Rust Iron." \ - org.opencontainers.image.version="$VERSION" \ - org.opencontainers.image.documentation="https://github.com/joseluisq/static-web-server" diff --git a/docker/scratch/Dockerfile b/docker/scratch/Dockerfile index aaff341..2a12fd9 100644 --- a/docker/scratch/Dockerfile +++ b/docker/scratch/Dockerfile @@ -1,6 +1,11 @@ FROM scratch -LABEL maintainer="Jose Quintana " +ARG SERVER_VERSION=0.0.0 +ENV SERVER_VERSION=${SERVER_VERSION} + +LABEL version="${SERVER_VERSION}" \ + description="A blazing fast static files-serving web server powered by Rust Iron." \ + maintainer="Jose Quintana " COPY ./bin/static-web-server / COPY ./public /public @@ -14,5 +19,5 @@ LABEL org.opencontainers.image.vendor="Jose Quintana" \ org.opencontainers.image.url="https://github.com/joseluisq/static-web-server" \ org.opencontainers.image.title="Static Web Server" \ org.opencontainers.image.description="A blazing fast static files-serving web server powered by Rust Iron." \ - org.opencontainers.image.version="v1.10.0" \ + org.opencontainers.image.version="${SERVER_VERSION}" \ org.opencontainers.image.documentation="https://github.com/joseluisq/static-web-server" diff --git a/docker/scratch/tmpl.Dockerfile b/docker/scratch/tmpl.Dockerfile deleted file mode 100644 index e43b324..0000000 --- a/docker/scratch/tmpl.Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM scratch - -LABEL maintainer="Jose Quintana " - -COPY ./bin/static-web-server / -COPY ./public /public - -EXPOSE 80 -VOLUME ["/public"] -ENTRYPOINT ["/static-web-server"] - -# Metadata -LABEL org.opencontainers.image.vendor="Jose Quintana" \ - org.opencontainers.image.url="https://github.com/joseluisq/static-web-server" \ - org.opencontainers.image.title="Static Web Server" \ - org.opencontainers.image.description="A blazing fast static files-serving web server powered by Rust Iron." \ - org.opencontainers.image.version="$VERSION" \ - org.opencontainers.image.documentation="https://github.com/joseluisq/static-web-server" diff --git a/docker/version.sh b/docker/version.sh deleted file mode 100755 index 067bc24..0000000 --- a/docker/version.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -u - -LATEST_TAG=$1 -BASE_PATH="$(pwd)/docker" - -if [ $# -eq 0 ]; then - echo "Usage: ./version.sh " - exit -fi - -export VERSION=$LATEST_TAG -export ALPINE_VERSION=3.11 - -PLATFORMS=( - "alpine" - "scratch" -) - -for PLATFORM in "${PLATFORMS[@]}"; do - PLATFORM_DIR="${BASE_PATH}/${PLATFORM}" - - if [ ! -d "$PLATFORM_DIR" ]; then - echo "Directory no found for \"${PLATFORM_DIR}\"" - exit 1 - fi - - echo "Generating Dockerfile for platform \"${PLATFORM}\"" - - rm -rf "${PLATFORM_DIR}/Dockerfile" - - envsubst \$ALPINE_VERSION,\$VERSION <"${PLATFORM_DIR}/tmpl.Dockerfile" >"${PLATFORM_DIR}/Dockerfile" -done - -echo "All Dockerfiles were updated!" -- libgit2 1.7.2