summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShyam Sunder <sgsunder1@gmail.com>2019-10-04 18:58:05 -0400
committerShyam Sunder <sgsunder1@gmail.com>2019-10-04 19:52:57 -0400
commit9c044003693a945e8508cb7a5a9829fdb802e2c8 (patch)
tree894fab6da7a8f8c52caba034048bbcf17fd378f2
parent91f5a4245941ee460580f92bd73fe5e81b6bcfac (diff)
docker: added OCI-compatible image labels
See https://github.com/opencontainers/image-spec/blob/master/annotations.md
-rw-r--r--client/Dockerfile13
-rwxr-xr-xclient/hooks/build15
-rw-r--r--server/Dockerfile13
-rwxr-xr-xserver/hooks/build7
4 files changed, 43 insertions, 5 deletions
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 .