From f7a59b25b055ede8e7665f90b11cad85214b4614 Mon Sep 17 00:00:00 2001 From: Michael Balsillie Date: Sun, 21 Aug 2022 23:41:10 +1200 Subject: [PATCH] map docker sock, var expansion --- .woodpecker/main.yml | 48 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/.woodpecker/main.yml b/.woodpecker/main.yml index 29e70ed..b4c77e2 100644 --- a/.woodpecker/main.yml +++ b/.woodpecker/main.yml @@ -1,13 +1,13 @@ variables: &vars - REGISTRY=code.balsillie.net - REGISTRY_USER=michael - ORGANIZATION=containers - SOURCE_ORGANIZATION=mirrors - REPO=matrix-service-synapse - BUILD_ARGS="PYTHON_VERSION=3.10" - DOCKERFILE="docker/Dockerfile" - CONTEXT=. + - REGISTRY=code.balsillie.net + - REGISTRY_USER=michael + - ORGANIZATION=containers + - SOURCE_ORGANIZATION=mirrors + - REPO=matrix-service-synapse + - BUILD_ARGS="PYTHON_VERSION=3.10" + - DOCKERFILE="docker/Dockerfile" + - CONTEXT=. workspace: base: /git @@ -25,27 +25,31 @@ pipeline: - /bin/bash check-tag.sh clone-source: image: docker:git - commands: - - *vars - - git clone https://$REGISTRY/$SOURCE_ORGANIZATION/$REPO.git /git/$REPO - - cd /git/$REPO + environment: + *vars + commands: + - git clone https://${REGISTRY}/${SOURCE_ORGANIZATION}/${REPO}.git /git/${REPO} + - cd /git/${REPO} - git checkout $TAG docker-build: image: docker:latest secrets: - source: REGISTRY_PASSWORD target: REGISTRY_PASSWORD + volumes: + - /var/run/docker.sock:/var/run/docker.sock + environment: + *vars commands: - - *vars - export DOCKER_BUILDKIT=1 - - cd /git/$REPO - - echo $REGISTRY_PASSWORD | docker login $REGISTRY -u $REGISTRY_USER --password-stdin + - cd /git/${REPO} + - echo $REGISTRY_PASSWORD | docker login ${REGISTRY} -u ${REGISTRY_USER} --password-stdin - docker build - -t $REGISTRY/$ORGANIZATION/$REPO:$TAG - -t $REGISTRY/$ORGANIZATION/$REPO:$(date +%F) - -t $REGISTRY/$ORGANIZATION/$REPO:latest + -t ${REGISTRY}/${ORGANIZATION}/${REPO}:$TAG + -t ${REGISTRY}/${ORGANIZATION}/${REPO}:$(date +%F) + -t ${REGISTRY}/${ORGANIZATION}/${REPO}:latest --pull - --build-arg $BUILD_ARGS - -f $DOCKERFILE - $CONTEXT - - docker push $REGISTRY/$ORGANIZATION/$REPO:latest \ No newline at end of file + --build-arg ${BUILD_ARGS} + -f $}DOCKERFILE} + ${CONTEXT} + - docker push -a ${REGISTRY}/${ORGANIZATION}/${REPO} \ No newline at end of file