From 91c56d430e23477715188591d8af49569aed2dee Mon Sep 17 00:00:00 2001 From: Adam Veldhousen Date: Wed, 12 Jul 2023 22:40:12 -0500 Subject: [PATCH] try script --- .drone.yml | 4 +--- hack/kaniko-test.sh | 19 +++++++++++++++++++ hack/promote.sh | 24 ++++++++++++++++++++++++ src/.dockerignore | 1 + 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100755 hack/kaniko-test.sh create mode 100755 hack/promote.sh diff --git a/.drone.yml b/.drone.yml index ca34da2..a9474b1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -265,9 +265,7 @@ steps: DOCKER_PASSWORD: from_secret: DOCKER_PASSWORD commands: - - ls -lash - #- export MANIFEST=$(curl -u "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" -H "Accept: ${CONTENT_TYPE}" "${REGISTRY_NAME}/v2/barretthousen/service-catalog}/manifests/beta") - #- curl -X PUT -u "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" -H "Content-Type: ${CONTENT_TYPE}" -d "${MANIFEST}" "${REGISTRY_NAME}/v2/barretthousen/service-catalog}/manifests/prod" + - ./hack/promote.sh barretthousen/catalog beta prod - name: Deploy Success image: appleboy/drone-discord diff --git a/hack/kaniko-test.sh b/hack/kaniko-test.sh new file mode 100755 index 0000000..973c70c --- /dev/null +++ b/hack/kaniko-test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +docker run --rm \ + -e DRONE_COMMIT_REF=refs/heads/trunk \ + -e DRONE_REPO_BRANCH=trunk \ + -e PLUGIN_REGISTRY=git.vdhsn.com \ + -e PLUGIN_REPO=git.vdhsn.com/barretthousen/service-catalog \ + -e PLUGIN_BUILD_ARGS="service=catalog" \ + -e PLUGIN_TAGS=$(git rev-parse --verify --short HEAD) \ + -e PLUGIN_CONTEXT="./src" \ + -e PLUGIN_DOCKERFILE="./src/Dockerfile.prod-backend" \ + -e PLUGIN_USERNAME=${DOCKER_USERNAME} \ + -e PLUGIN_PASSWORD=${DOCKER_PASSWORD} \ + -e PLUGIN_ENABLE_CACHE=true \ + -e PLUGIN_CACHE_REPO='git.vdhsn.com/barretthousen/ci-cache' \ + -e PLUGIN_SKIP_UNUSED_STAGES=true \ + -v $(pwd):/drone \ + -w /drone \ + plugins/kaniko:linux-amd64 diff --git a/hack/promote.sh b/hack/promote.sh new file mode 100755 index 0000000..e5f87b0 --- /dev/null +++ b/hack/promote.sh @@ -0,0 +1,24 @@ +#!/bin/sh + + +main(){ + local REPOSITORY=${1}; + if [ -z "${REPOSITORY}" ]; then + echo "First argument must be container repository"; + exit 1; + fi + + local FROM=${2:-beta}; + local TO=${3:-prod}; + + local CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json"; + local REGISTRY_URL="https://git.vdhsn.com/v2/${REPOSITORY}/manifests"; + + export MANIFEST=$(curl -u "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" \ + -H "Accept: ${CONTENT_TYPE}" "${REGISTRY_URL}/${FROM}"); + + + curl -u "${DOCKER_USERNAME}:${DOCKER_PASSWORD}" \ + -X PUT -H "Content-Type: ${CONTENT_TYPE}" -d "${MANIFEST}" "${REGISTRY_URL}/${TO}"; +} + diff --git a/src/.dockerignore b/src/.dockerignore index 7863953..ade6f27 100644 --- a/src/.dockerignore +++ b/src/.dockerignore @@ -1,3 +1,4 @@ .idea web-client admin-client +