From cd12ee1acefb03c24d60fceac47b3e3fb6cb339d Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 19 Oct 2023 20:20:11 +0100 Subject: [PATCH] versioned build --- .drone/build.sh | 2 +- .drone/deploy.sh | 1 + .drone/drone-home.yml | 8 ++++---- .drone/pull.sh | 2 +- .drone/push.sh | 2 +- docker-compose.yml | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.drone/build.sh b/.drone/build.sh index 83f8194..4b16d55 100644 --- a/.drone/build.sh +++ b/.drone/build.sh @@ -2,4 +2,4 @@ sleep 10 docker build gitea \ --build-arg REGISTRY=${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/ \ - -t ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/gitea + -t ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/gitea:$1 diff --git a/.drone/deploy.sh b/.drone/deploy.sh index 11bdc15..312db68 100644 --- a/.drone/deploy.sh +++ b/.drone/deploy.sh @@ -1,4 +1,5 @@ export LOCAL_DOCKER_REGISTRY=${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/ \ +&& export TAG=$1 \ && docker stack rm gitea \ && echo 'sleeping...zzz' \ && sleep 60 \ diff --git a/.drone/drone-home.yml b/.drone/drone-home.yml index d92c796..11835b2 100644 --- a/.drone/drone-home.yml +++ b/.drone/drone-home.yml @@ -228,8 +228,8 @@ steps: - export NAME=gitea - export ROOT=stack - "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n" - - sh .drone/build.sh - - sh .drone/push.sh + - sh .drone/build.sh $${DRONE_COMMIT_SHA} + - sh .drone/push.sh $${DRONE_COMMIT_SHA} volumes: - name: dockersock path: /var/run @@ -330,8 +330,8 @@ steps: - export ROOT=stack - cd /stack/gitea - "n=0\nwhile :\ndo\n docker login $${REGISTRY_DOMAIN}:$${REGISTRY_PORT}/ --username client --password \"$${REGISTRY_PASSWORD}\" \\\\\n && break # substitute your command here\n n=$((n+1))\n if [ $n -ge 10 ]; then\n echo \"login failed\"\n exit 1\n fi\n echo \"retrying login..$n\"\n sleep 5\ndone\n" - - sh .drone/pull.sh - - sh .drone/deploy.sh + - sh .drone/pull.sh $${DRONE_COMMIT_SHA} + - sh .drone/deploy.sh $${DRONE_COMMIT_SHA} environment: GITEA_APP_NAME: from_secret: gitea-app-name diff --git a/.drone/pull.sh b/.drone/pull.sh index e52add2..f296aaf 100644 --- a/.drone/pull.sh +++ b/.drone/pull.sh @@ -1 +1 @@ -docker pull ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/gitea +docker pull ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/gitea:$1 diff --git a/.drone/push.sh b/.drone/push.sh index 7922e60..d569c2a 100644 --- a/.drone/push.sh +++ b/.drone/push.sh @@ -1 +1 @@ -docker push ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/gitea +docker push ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/${ROOT}/${NAME}/gitea:$1 diff --git a/docker-compose.yml b/docker-compose.yml index b87a3ca..4a273e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: replicas: 1 restart_policy: condition: any - image: ${LOCAL_DOCKER_REGISTRY}gitea + image: ${LOCAL_DOCKER_REGISTRY}gitea:${TAG} environment: - USER_UID=1000 - USER_GID=1000