From 8bc5e5b8c581828efb3e4bc0a0c3630a7db910c4 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 10 Nov 2024 15:23:04 +0100 Subject: [PATCH] [#434] Added pipeline to update registry images. --- .drone.yml | 30 ++++++++++++++++++++++++++++++ .drone/update-image-registry.sh | 12 ++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 .drone/update-image-registry.sh diff --git a/.drone.yml b/.drone.yml index 2245d86a03..de09aa3a92 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,6 +12,10 @@ volumes: host: path: /opt/repos/platypush + - name: docker_sock + host: + path: /var/run/docker.sock + steps: ### @@ -333,6 +337,31 @@ steps: commands: - . .drone/update-pip-package.sh +### +### Update the Docker image +### + +- name: update-image-registry + image: alpine + privileged: true + volumes: + - name: docker_sock + path: /var/run/docker.sock + + environment: + REGISTRY_ENDPOINT: quay.io + DOCKER_HOST: "tcp://localhost:2375/" + DOCKER_USER: platypush + DOCKER_PASS: + from_secret: registry_token + + commands: + - . .drone/update-image-registry.sh + + when: + event: + - tag + ### ### Checkpoint step that waits for all the package update ### steps to complete before proceeding to the next steps. @@ -351,6 +380,7 @@ steps: # - update-arch-git-package - update-rpm-repo - update-apt-repo + - update-image-registry commands: - echo "All packages have been successfully updated" diff --git a/.drone/update-image-registry.sh b/.drone/update-image-registry.sh new file mode 100755 index 0000000000..60ba87cde0 --- /dev/null +++ b/.drone/update-image-registry.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +export VERSION=$(grep current_version pyproject.toml | sed -r -e "s/.*=\s*['\"]?([^'\"]+)['\"]?\s*$/\1/") +export IMAGE_NAME="$REGISTRY_ENDPOINT/$DOCKER_USER/platypush" + +git config --global --add safe.directory /app +docker login "$REGISTRY_ENDPOINT" -u "$DOCKER_USER" -p "$DOCKER_PASS" +docker build -f Dockerfile.alpine -t "$IMAGE_NAME:$VERSION" . +docker tag "$IMAGE_NAME:$VERSION" "$IMAGE_NAME:latest" + +docker push "$IMAGE_NAME:$VERSION" +docker push "$IMAGE_NAME:latest"