From 74c627bb2761b3bd3fe8300152ca35b3d0716ff8 Mon Sep 17 00:00:00 2001
From: Jairo Llopis <jairo.llopis@tecnativa.com>
Date: Mon, 14 Dec 2020 09:14:11 +0000
Subject: [PATCH] Fix build

- Update labels to match those from https://github.com/opencontainers/image-spec/blob/master/annotations.md#pre-defined-annotation-keys
- Add missing build args.
- Remove unneeded python (which was failing to install, BTW) from the image.
- Remove `hooks` folder, which was used to build the image automatically in the Docker Hub. It's done in GitHub Actions now.
---
 .github/workflows/test.yaml |  8 ++++++++
 Dockerfile                  | 19 ++++++------------
 hooks/build                 | 40 -------------------------------------
 3 files changed, 14 insertions(+), 53 deletions(-)
 delete mode 100755 hooks/build

diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index c1b2136..ac3ae47 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -29,6 +29,8 @@ jobs:
     env:
       DOCKER_REPO: tecnativa/docker-socket-proxy
     steps:
+      - name: Get date
+        run: echo "BUILD_DATE=$(date --rfc-3339 ns)" >> $GITHUB_ENV
       # Prepare Docker environment and build
       - uses: actions/checkout@v2
       - uses: docker/setup-qemu-action@v1
@@ -37,6 +39,9 @@ jobs:
       - name: Build image(s)
         uses: docker/build-push-action@v2
         with:
+          build-args: |
+            BUILD_DATE=${{ env.BUILD_DATE }}
+            VCS_REF=${{ github.sha }}
           context: .
           file: ./Dockerfile
           # HACK: Build single platform image for testing. See https://github.com/docker/buildx/issues/59
@@ -93,6 +98,9 @@ jobs:
           'refs/heads/master'
         uses: docker/build-push-action@v2
         with:
+          build-args: |
+            BUILD_DATE=${{ env.BUILD_DATE }}
+            VCS_REF=${{ github.sha }}
           context: .
           file: ./Dockerfile
           platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm/v8,linux/arm64,linux/ppc64le,linux/s390x
diff --git a/Dockerfile b/Dockerfile
index cd37ef7..f7e9523 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,4 @@
-ARG REPO=library
-FROM ${REPO}/haproxy:1.9-alpine
+FROM haproxy:1.9-alpine
 
 EXPOSE 2375
 ENV ALLOW_RESTARTS=0 \
@@ -29,17 +28,11 @@ ENV ALLOW_RESTARTS=0 \
     VOLUMES=0
 COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
 
-# Install python/pip
-ENV PYTHONUNBUFFERED=1
-RUN apk add --update --no-cache python3 && ln -sf $(which python3) /usr/local/bin/python
-RUN python -m ensurepip && python -m pip install --no-cache --upgrade pip setuptools
-
 # Metadata
 ARG VCS_REF
 ARG BUILD_DATE
-LABEL org.label-schema.schema-version="1.0" \
-      org.label-schema.vendor=Tecnativa \
-      org.label-schema.license=Apache-2.0 \
-      org.label-schema.build-date="$BUILD_DATE" \
-      org.label-schema.vcs-ref="$VCS_REF" \
-      org.label-schema.vcs-url="https://github.com/Tecnativa/docker-socket-proxy"
+LABEL org.opencontainers.image.vendor=Tecnativa \
+      org.opencontainers.image.licenses=Apache-2.0 \
+      org.opencontainers.image.created="$BUILD_DATE" \
+      org.opencontainers.image.revision="$VCS_REF" \
+      org.opencontainers.image.source="https://github.com/Tecnativa/docker-socket-proxy"
diff --git a/hooks/build b/hooks/build
deleted file mode 100755
index 74d13a4..0000000
--- a/hooks/build
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/bash
-set -ex
-
-# Extract arch repo from a docker tag suffix
-REPO=""
-case "$DOCKER_TAG" in
-    *amd64)
-        REPO="library"
-        ;;
-    *arm32v5)
-        REPO="arm32v5"
-        ;;
-    *arm32v6)
-        REPO="arm32v6"
-        ;;
-    *arm32v7)
-        REPO="arm32v7"
-        ;;
-    *arm64v8)
-        REPO="arm64v8"
-        ;;
-    *i386)
-        REPO="i386"
-        ;;
-    *ppc64le)
-        REPO="ppc64le"
-        ;;
-    *s390x)
-        REPO="s390x"
-        ;;
-    *)
-        REPO="library"
-        ;;
-esac
-
-docker build \
-    --build-arg REPO="$REPO" \
-    --build-arg VCS_REF="$GIT_SHA1" \
-    --build-arg BUILD_DATE="$(date --rfc-3339 ns)" \
-    --tag "$IMAGE_NAME" .
-- 
GitLab