From a48f1c80406b4710ba3e59fb471400de2dd10e60 Mon Sep 17 00:00:00 2001 From: Lan Tian Date: Wed, 6 Sep 2023 20:48:14 -0700 Subject: [PATCH] general: move Docker image build to GitHub Actions --- .circleci/config.yml | 127 ------------------ .github/workflows/docker-develop.yaml | 38 ++++++ .github/workflows/docker-release.yaml | 35 +++++ .../{release.yaml => go-release.yaml} | 0 4 files changed, 73 insertions(+), 127 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/docker-develop.yaml create mode 100644 .github/workflows/docker-release.yaml rename .github/workflows/{release.yaml => go-release.yaml} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b040d17..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,127 +0,0 @@ -version: 2.1 - -workflows: - docker: - jobs: - - build - - docker-frontend-deploy: - context: - - docker - requires: - - build - filters: - branches: - only: 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: - name: Test frontend - command: | - export GO111MODULE=on - cd frontend - go get -v -t -d ./... - go test -v ./... - - run: - name: Test proxy - command: | - export GO111MODULE=on - cd proxy - go get -v -t -d ./... - go test -v ./... - - 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-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 diff --git a/.github/workflows/docker-develop.yaml b/.github/workflows/docker-develop.yaml new file mode 100644 index 0000000..7d00d4c --- /dev/null +++ b/.github/workflows/docker-develop.yaml @@ -0,0 +1,38 @@ +on: + push: + branches: + - '**' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build frontend docker image + uses: docker/build-push-action@v4 + with: + context: '{{defaultContext}}:frontend' + push: true + tags: | + xddxdd/bird-lg-go:develop + xddxdd/bird-lg-go:develop-${{ github.sha }} + + - name: Build proxy docker image + uses: docker/build-push-action@v4 + with: + context: '{{defaultContext}}:proxy' + push: true + tags: | + xddxdd/bird-lgproxy-go:develop + xddxdd/bird-lgproxy-go:develop-${{ github.sha }} diff --git a/.github/workflows/docker-release.yaml b/.github/workflows/docker-release.yaml new file mode 100644 index 0000000..77d907c --- /dev/null +++ b/.github/workflows/docker-release.yaml @@ -0,0 +1,35 @@ +on: + release: + types: [created] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build frontend docker image + uses: docker/build-push-action@v4 + with: + context: '{{defaultContext}}:frontend' + push: true + tags: | + xddxdd/bird-lg-go:latest + + - name: Build proxy docker image + uses: docker/build-push-action@v4 + with: + context: '{{defaultContext}}:proxy' + push: true + tags: | + xddxdd/bird-lgproxy-go:latest diff --git a/.github/workflows/release.yaml b/.github/workflows/go-release.yaml similarity index 100% rename from .github/workflows/release.yaml rename to .github/workflows/go-release.yaml