diff --git a/.circleci/config.yml b/.circleci/config.yml index 015bf33b..420e9203 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ executors: orbs: ruby: circleci/ruby@2.1.4 browser-tools: circleci/browser-tools@1.4.8 - docker: circleci/docker@2.2.1 + docker: circleci/docker@2.8.2 jobs: test: @@ -43,69 +43,29 @@ jobs: path: coverage build-and-push: - docker: - - image: cimg/node:current - environment: - DOCKER_CLI_EXPERIMENTAL: enabled + executor: + name: docker/docker + # You can also specify a different image if required. + parameters: + tag: + type: string + default: "rc" steps: - checkout - - - run: - name: Set branch variable - command: | - if [ -z "$CIRCLE_BRANCH" ]; then - echo 'export BUILD_BRANCH=master' >> $BASH_ENV - else - echo "export BUILD_BRANCH=$CIRCLE_BRANCH" >> $BASH_ENV - fi - - - setup_remote_docker: - version: 20.10.24 - docker_layer_caching: true - - - run: - name: Install dependencies - command: npm install - + # Login to Docker Hub using the orb command. The orb expects environment + # variables DOCKERHUB_USERNAME and DOCKERHUB_PASSWORD (or DOCKERHUB_TOKEN). - docker/login: - username: << pipeline.parameters.DOCKERHUB_USERNAME >> - password: << pipeline.parameters.DOCKERHUB_TOKEN >> - - - run: - name: Set Docker tags - command: | - if [[ -n "$CIRCLE_TAG" ]]; then - VERSION="${CIRCLE_TAG}" - else - VERSION="latest" - fi - - TAGS="freikin/dawarich:${VERSION}" - - if [[ "$CIRCLE_TAG" =~ rc ]]; then - TAGS="${TAGS},freikin/dawarich:rc" - else - TAGS="${TAGS},freikin/dawarich:latest" - fi - - echo "export DOCKER_TAGS=\"$TAGS\"" >> $BASH_ENV - - - run: - name: Build and push (arm64) - command: | - docker buildx create --use - docker buildx build --platform linux/arm64 \ - --file ./docker/Dockerfile.dev \ - --tag freikin/dawarich:${VERSION} \ - --push . - - - run: - name: Build and push (other architectures) - command: | - docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm/v6 \ - --file ./docker/Dockerfile.dev \ - --tag freikin/dawarich:${VERSION} \ - --push . + username: "$DOCKERHUB_USERNAME" + password: "$DOCKERHUB_TOKEN" + # Build and publish the Docker image. + - docker/build-publish: + image: "freikin/dawarich:<< parameters.tag >>" + dockerfile: ./docker/Dockerfile.dev + # Set additional options if needed: + build-args: "" + extra-build-args: "--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6" + registry: "docker.io" + push: true workflows: version: 2 @@ -113,10 +73,11 @@ workflows: jobs: - test - build-and-push: + requires: + - test filters: branches: - only: - - master - - dev + ignore: /.*/ # Ignore branches; run only on tag builds (or adjust as needed) tags: - only: /.*/ # Match ANY tag name + only: /.*/ # Run for any tag; adjust regex if you want more specific tag matching + tag: "<< pipeline.parameters.tag >>"