refactor: use plugins/docker instead of manual dind setup
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c076b47c77
commit
4c5d642dcc
1 changed files with 11 additions and 42 deletions
53
.drone.yml
53
.drone.yml
|
|
@ -2,13 +2,6 @@ kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: build-and-publish
|
name: build-and-publish
|
||||||
|
|
||||||
services:
|
|
||||||
- name: docker
|
|
||||||
image: docker:dind
|
|
||||||
privileged: true
|
|
||||||
environment:
|
|
||||||
DOCKER_TLS_CERTDIR: "" # Disable TLS and Unix socket - use TCP only
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
|
|
@ -19,43 +12,19 @@ trigger:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-and-publish-container
|
- name: build-and-publish-container
|
||||||
image: docker:cli
|
image: plugins/docker
|
||||||
environment:
|
settings:
|
||||||
DOCKER_HOST: tcp://docker:2375 # Connect to dind service
|
registry: git.local-it.org
|
||||||
REGISTRY: git.local-it.org/ci-builder
|
repo: git.local-it.org/ci-builder/mitgliederverwaltung
|
||||||
IMAGE_NAME: mitgliederverwaltung
|
username:
|
||||||
REGISTRY_USERNAME:
|
|
||||||
from_secret: DRONE_REGISTRY_USERNAME
|
from_secret: DRONE_REGISTRY_USERNAME
|
||||||
REGISTRY_TOKEN:
|
password:
|
||||||
from_secret: DRONE_REGISTRY_TOKEN
|
from_secret: DRONE_REGISTRY_TOKEN
|
||||||
commands:
|
tags:
|
||||||
- sleep 5 # give docker time to start
|
- latest
|
||||||
- docker info # verify docker is ready
|
- ${DRONE_COMMIT_SHA}
|
||||||
# Build image once
|
auto_tag: true
|
||||||
- docker build --tag $REGISTRY/$IMAGE_NAME:build-$DRONE_BUILD_NUMBER .
|
auto_tag_suffix: linux-amd64
|
||||||
# Login to registry
|
|
||||||
- echo "$REGISTRY_TOKEN" | docker login --username "$REGISTRY_USERNAME" --password-stdin git.local-it.org
|
|
||||||
# Tag and push based on event type
|
|
||||||
- |
|
|
||||||
if [ "$DRONE_BUILD_EVENT" = "tag" ]; then
|
|
||||||
# For tag events: use tag version (e.g., v1.0.0 -> 1.0.0) and latest
|
|
||||||
VERSION=$(echo $DRONE_TAG | sed 's/^v//')
|
|
||||||
echo "Tagging and pushing version $VERSION"
|
|
||||||
docker tag $REGISTRY/$IMAGE_NAME:build-$DRONE_BUILD_NUMBER $REGISTRY/$IMAGE_NAME:$VERSION
|
|
||||||
docker tag $REGISTRY/$IMAGE_NAME:build-$DRONE_BUILD_NUMBER $REGISTRY/$IMAGE_NAME:latest
|
|
||||||
docker push $REGISTRY/$IMAGE_NAME:$VERSION
|
|
||||||
docker push $REGISTRY/$IMAGE_NAME:latest
|
|
||||||
else
|
|
||||||
# For main branch pushes: use commit SHA and latest
|
|
||||||
echo "Tagging and pushing commit $DRONE_COMMIT_SHA"
|
|
||||||
docker tag $REGISTRY/$IMAGE_NAME:build-$DRONE_BUILD_NUMBER $REGISTRY/$IMAGE_NAME:$DRONE_COMMIT_SHA
|
|
||||||
docker tag $REGISTRY/$IMAGE_NAME:build-$DRONE_BUILD_NUMBER $REGISTRY/$IMAGE_NAME:latest
|
|
||||||
docker push $REGISTRY/$IMAGE_NAME:$DRONE_COMMIT_SHA
|
|
||||||
docker push $REGISTRY/$IMAGE_NAME:latest
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# No volumes needed - docker:cli connects to dind service via TCP
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue