From 1b280a8c50eb204ca2d352057f67e785f1eb78f5 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 30 Oct 2025 18:46:29 +0100 Subject: [PATCH 1/2] test: add ci-build-container to pipeline trigger for testing --- .drone.yml | 64 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/.drone.yml b/.drone.yml index 860e82c..fd24515 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,43 +1,59 @@ kind: pipeline type: docker -name: check +name: build-and-publish services: - - name: postgres - image: docker.io/library/postgres:17.6 - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - name: docker image: docker:dind privileged: true - volumes: - - name: dockersock - path: /var/run trigger: + branch: + - main + - ci-build-container # TODO: Remove after testing event: - push + - tag steps: - - name: build & publish container? - image: docker:dind - volumes: - - name: dockersock - path: /var/run + - name: build-and-publish-container + image: docker:cli + environment: + DOCKER_HOST: tcp://docker:2375 # Connect to dind service + REGISTRY: git.local-it.org/ci-builder + IMAGE_NAME: mitgliederverwaltung + REGISTRY_USERNAME: + from_secret: DRONE_REGISTRY_USERNAME + REGISTRY_TOKEN: + from_secret: DRONE_REGISTRY_TOKEN commands: - - sleep 6 # give docker time to start - - docker build --tag git.local-it.org/ci-builder/mitgliederverwaltung:latest . - - docker login --username $DRONE_FORGEJO_ACCOUNT_USERNAME --password $DRONE_FORGEJO_ACCOUNT_PASSWORD git.local-it.org - - docker push git.local-it.org/ci-builder/mitgliederverwaltung:latest + - sleep 5 # give docker time to start + - docker info # verify docker is ready + # Build image once + - docker build --tag $REGISTRY/$IMAGE_NAME:build-$DRONE_BUILD_NUMBER . + # 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 -volumes: - - name: cache - host: - path: /tmp/drone_cache - - name: dockersock - temp: {} +# No volumes needed - docker:cli connects to dind service via TCP --- kind: pipeline From c076b47c77640a4e277bfc1b60f438dcd46f84d9 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 30 Oct 2025 18:46:29 +0100 Subject: [PATCH 2/2] test: add ci-build-container to pipeline trigger for testing --- .drone.yml | 66 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/.drone.yml b/.drone.yml index 860e82c..2c77dc2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,43 +1,61 @@ kind: pipeline type: docker -name: check +name: build-and-publish services: - - name: postgres - image: docker.io/library/postgres:17.6 - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - name: docker image: docker:dind privileged: true - volumes: - - name: dockersock - path: /var/run + environment: + DOCKER_TLS_CERTDIR: "" # Disable TLS and Unix socket - use TCP only trigger: + branch: + - main + - ci-build-container # TODO: Remove after testing event: - push + - tag steps: - - name: build & publish container? - image: docker:dind - volumes: - - name: dockersock - path: /var/run + - name: build-and-publish-container + image: docker:cli + environment: + DOCKER_HOST: tcp://docker:2375 # Connect to dind service + REGISTRY: git.local-it.org/ci-builder + IMAGE_NAME: mitgliederverwaltung + REGISTRY_USERNAME: + from_secret: DRONE_REGISTRY_USERNAME + REGISTRY_TOKEN: + from_secret: DRONE_REGISTRY_TOKEN commands: - - sleep 6 # give docker time to start - - docker build --tag git.local-it.org/ci-builder/mitgliederverwaltung:latest . - - docker login --username $DRONE_FORGEJO_ACCOUNT_USERNAME --password $DRONE_FORGEJO_ACCOUNT_PASSWORD git.local-it.org - - docker push git.local-it.org/ci-builder/mitgliederverwaltung:latest + - sleep 5 # give docker time to start + - docker info # verify docker is ready + # Build image once + - docker build --tag $REGISTRY/$IMAGE_NAME:build-$DRONE_BUILD_NUMBER . + # 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 -volumes: - - name: cache - host: - path: /tmp/drone_cache - - name: dockersock - temp: {} +# No volumes needed - docker:cli connects to dind service via TCP --- kind: pipeline