Fix Drone pipeline.
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Stanislav Nikitin 2024-05-04 13:12:46 +05:00
parent a9e910ae6b
commit 692c08d22e
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550
2 changed files with 29 additions and 13 deletions

View File

@ -18,18 +18,20 @@ name: "build toolbox"
trigger:
event: ["tag"]
depends_on:
- "lint"
steps:
- name: "build toolbox"
image: "docker:20.10.17-dind"
image: "code.pztrn.name/containers/mirror/docker:26.1.1-dind"
pull: if-not-exists
settings:
privileged: true
environment:
REGISTRY: code.pztrn.name
REGISTRY_PROJECT: /containers/go-toolbox
REGISTRY_USERNAME: drone
REGISTRY_PASSWORD:
from_secret: drone_secret
commands:
- apk add --no-cache bash
- ./build.sh
privileged: true
environment:
REGISTRY: code.pztrn.name
REGISTRY_PROJECT: /containers/go-toolbox
REGISTRY_USERNAME: drone
REGISTRY_PASSWORD:
from_secret: drone_secret
commands:
- apk add --no-cache bash
- ./build.sh

16
build.sh Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# build.sh checks if docker image with same sha256 exists remotely.
# if exists, do nothing, if not, build the image
@ -12,6 +12,20 @@ else
tag="${DRONE_COMMIT_SHA}"
fi
# Starting Docker daemon.
/usr/local/bin/dockerd --data-root=/var/lib/docker --max-concurrent-uploads 1 &
# Wait for it.
echo "* Waiting for Docker daemon to start..."
while true; do
if docker ps &>/dev/null; then
break
fi
done
echo "* Logging in to registry..."
docker login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}" "${REGISTRY}"
echo "* Building docker image ${image_path}:${tag}..."
if docker manifest inspect "${image_path}:${tag}" >/dev/null; then