From 9c044003693a945e8508cb7a5a9829fdb802e2c8 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Fri, 4 Oct 2019 18:58:05 -0400 Subject: [PATCH] docker: added OCI-compatible image labels See https://github.com/opencontainers/image-spec/blob/master/annotations.md --- client/Dockerfile | 13 +++++++++++++ client/hooks/build | 15 ++++++++++----- server/Dockerfile | 13 +++++++++++++ server/hooks/build | 7 +++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100755 server/hooks/build diff --git a/client/Dockerfile b/client/Dockerfile index 7d07bd9..5f02753 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -29,3 +29,16 @@ COPY --from=approot / / CMD ["/docker-start.sh"] VOLUME ["/data"] + +ARG DOCKER_REPO +ARG BUILD_DATE +ARG SOURCE_COMMIT +LABEL \ + maintainer="" \ + org.opencontainers.image.title="${DOCKER_REPO}" \ + org.opencontainers.image.url="https://github.com/rr-/szurubooru" \ + org.opencontainers.image.documentation="https://github.com/rr-/szurubooru/blob/${SOURCE_COMMIT}/doc/INSTALL.md" \ + org.opencontainers.image.created="${BUILD_DATE}" \ + org.opencontainers.image.source="https://github.com/rr-/szurubooru" \ + org.opencontainers.image.revision="${SOURCE_COMMIT}" \ + org.opencontainers.image.licenses="GPL-3.0" diff --git a/client/hooks/build b/client/hooks/build index b8c2c20..bd8c21a 100755 --- a/client/hooks/build +++ b/client/hooks/build @@ -1,11 +1,16 @@ #!/bin/sh -CLOSEST_VER=$(git describe --tags --abbrev=0) -if git describe --exact-match --abbrev=0 2> /dev/null; then +CLOSEST_VER=$(git describe --tags --abbrev=0 ${SOURCE_COMMIT}) +if git describe --exact-match --abbrev=0 ${SOURCE_COMMIT} 2> /dev/null; then BUILD_INFO="v${CLOSEST_VER}" else - BUILD_INFO="v${CLOSEST_VER}-edge-$(echo $SOURCE_COMMIT | cut -c1-7)" + BUILD_INFO="v${CLOSEST_VER}-edge-$(git rev-parse --short ${SOURCE_COMMIT})" fi -echo "Using BUILD_INFO=$BUILD_INFO" -docker build --build-arg BUILD_INFO=$BUILD_INFO -f $DOCKERFILE_PATH -t $IMAGE_NAME . +echo "Using BUILD_INFO=${BUILD_INFO}" +docker build \ + --build-arg BUILD_INFO \ + --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ + --build-arg SOURCE_COMMIT \ + --build-arg DOCKER_REPO \ + -f $DOCKERFILE_PATH -t $IMAGE_NAME . diff --git a/server/Dockerfile b/server/Dockerfile index a396793..78e44a5 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -42,3 +42,16 @@ ENV PORT=${PORT} EXPOSE ${PORT} VOLUME ["/data/"] CMD ["/opt/app/docker-start.sh"] + +ARG DOCKER_REPO +ARG BUILD_DATE +ARG SOURCE_COMMIT +LABEL \ + maintainer="" \ + org.opencontainers.image.title="${DOCKER_REPO}" \ + org.opencontainers.image.url="https://github.com/rr-/szurubooru" \ + org.opencontainers.image.documentation="https://github.com/rr-/szurubooru/blob/${SOURCE_COMMIT}/doc/INSTALL.md" \ + org.opencontainers.image.created="${BUILD_DATE}" \ + org.opencontainers.image.source="https://github.com/rr-/szurubooru" \ + org.opencontainers.image.revision="${SOURCE_COMMIT}" \ + org.opencontainers.image.licenses="GPL-3.0" diff --git a/server/hooks/build b/server/hooks/build new file mode 100755 index 0000000..fea6b42 --- /dev/null +++ b/server/hooks/build @@ -0,0 +1,7 @@ +#!/bin/sh + +docker build \ + --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ + --build-arg SOURCE_COMMIT \ + --build-arg DOCKER_REPO \ + -f $DOCKERFILE_PATH -t $IMAGE_NAME .