version: 2.1 workflows: docker: jobs: - build - docker-frontend: context: - docker requires: - build filters: branches: ignore: master - docker-frontend-deploy: context: - docker requires: - build filters: branches: only: master - docker-proxy: context: - docker requires: - build filters: branches: ignore: master - docker-proxy-deploy: context: - docker requires: - build filters: branches: only: master jobs: build: docker: - image: cimg/go:1.17 working_directory: /home/circleci/go/src/github.com/xddxdd/bird-lg-go steps: - checkout - run: GO111MODULE=auto go get -v -t -d ./... - run: GO111MODULE=auto go test -v ./... docker-frontend: machine: image: ubuntu-2004:202111-02 environment: BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/386,linux/arm/v7 steps: - checkout - run: name: Install buildx command: | BUILDX_BINARY_URL="https://github.com/docker/buildx/releases/download/v0.7.1/buildx-v0.7.1.linux-amd64" curl --output docker-buildx \ --silent --show-error --location --fail --retry 3 \ "$BUILDX_BINARY_URL" mkdir -p ~/.docker/cli-plugins mv docker-buildx ~/.docker/cli-plugins/ chmod a+x ~/.docker/cli-plugins/docker-buildx docker buildx install # Run binfmt docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - run: name: Build Docker image environment: BUILD_ID: << pipeline.number >> command: | echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin docker buildx create --name mybuilder --use docker buildx build \ --platform $BUILDX_PLATFORMS \ -t $DOCKER_USERNAME/bird-lg-go:circleci-build$BUILD_ID \ --progress plain \ frontend docker-frontend-deploy: machine: image: ubuntu-2004:202111-02 environment: BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/386,linux/arm/v7 steps: - checkout - run: name: Install buildx command: | BUILDX_BINARY_URL="https://github.com/docker/buildx/releases/download/v0.7.1/buildx-v0.7.1.linux-amd64" curl --output docker-buildx \ --silent --show-error --location --fail --retry 3 \ "$BUILDX_BINARY_URL" mkdir -p ~/.docker/cli-plugins mv docker-buildx ~/.docker/cli-plugins/ chmod a+x ~/.docker/cli-plugins/docker-buildx docker buildx install # Run binfmt docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - run: name: Build Docker image environment: BUILD_ID: << pipeline.number >> command: | echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin docker buildx create --name mybuilder --use docker buildx build \ --platform $BUILDX_PLATFORMS \ -t $DOCKER_USERNAME/bird-lg-go:circleci-build$BUILD_ID \ --progress plain \ --push frontend docker buildx build \ --platform $BUILDX_PLATFORMS \ -t $DOCKER_USERNAME/bird-lg-go:latest \ --progress plain \ --push frontend docker-proxy: machine: image: ubuntu-2004:202111-02 environment: BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/386,linux/arm/v7 steps: - checkout - run: name: Install buildx command: | BUILDX_BINARY_URL="https://github.com/docker/buildx/releases/download/v0.7.1/buildx-v0.7.1.linux-amd64" curl --output docker-buildx \ --silent --show-error --location --fail --retry 3 \ "$BUILDX_BINARY_URL" mkdir -p ~/.docker/cli-plugins mv docker-buildx ~/.docker/cli-plugins/ chmod a+x ~/.docker/cli-plugins/docker-buildx docker buildx install # Run binfmt docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - run: name: Build Docker image environment: BUILD_ID: << pipeline.number >> command: | echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin docker buildx create --name mybuilder --use docker buildx build \ --platform $BUILDX_PLATFORMS \ -t $DOCKER_USERNAME/bird-lgproxy-go:circleci-build$BUILD_ID \ --progress plain \ proxy docker-proxy-deploy: machine: image: ubuntu-2004:202111-02 environment: BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/386,linux/arm/v7 steps: - checkout - run: name: Install buildx command: | BUILDX_BINARY_URL="https://github.com/docker/buildx/releases/download/v0.7.1/buildx-v0.7.1.linux-amd64" curl --output docker-buildx \ --silent --show-error --location --fail --retry 3 \ "$BUILDX_BINARY_URL" mkdir -p ~/.docker/cli-plugins mv docker-buildx ~/.docker/cli-plugins/ chmod a+x ~/.docker/cli-plugins/docker-buildx docker buildx install # Run binfmt docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - run: name: Build Docker image environment: BUILD_ID: << pipeline.number >> command: | echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin docker buildx create --name mybuilder --use docker buildx build \ --platform $BUILDX_PLATFORMS \ -t $DOCKER_USERNAME/bird-lgproxy-go:circleci-build$BUILD_ID \ --push proxy docker buildx build \ --platform $BUILDX_PLATFORMS \ -t $DOCKER_USERNAME/bird-lgproxy-go:latest \ --progress plain \ --push proxy