Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(build): streamline Docker image build process in CI configuration

LinkinStars58dbe2c02759
diff --git a/.github/workflows/build-image-for-test.yml b/.github/workflows/build-image-for-test.yml
index b90a1ac4..a650f06e 100644
--- a/.github/workflows/build-image-for-test.yml
+++ b/.github/workflows/build-image-for-test.yml
@@ -30,32 +30,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- - name: Docker meta
- id: meta
- uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
- with:
- images: apache/answer
- tags: |
- type=raw,value=test
-
- - name: Set up QEMU
- uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
+ - name: Login to DockerHub
+ run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username "${{ secrets.DOCKERHUB_USER }}" --password-stdin
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
-
- - name: Login to DockerHub
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
- with:
- username: ${{ secrets.DOCKERHUB_USER }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
+ run: |
+ docker buildx create --name answer-builder --driver docker-container --use
+ docker buildx inspect --bootstrap
- name: Build and push
- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
- with:
- context: .
- file: ./Dockerfile
- platforms: linux/amd64
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
+ run: |
+ BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
+ docker buildx build \
+ --file ./Dockerfile \
+ --platform linux/amd64 \
+ --push \
+ --tag apache/answer:test \
+ --label org.opencontainers.image.created="${BUILD_DATE}" \
+ --label org.opencontainers.image.revision="${GITHUB_SHA}" \
+ --label org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}" \
+ .