diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b2d9e434..1b6f11a8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,6 +1,11 @@ name: Docker on: + pull_request: + branches: + - main + paths: + - 'ci/Dockerfile*' push: branches: - main @@ -22,9 +27,10 @@ jobs: id: get_version run: | VERSION=${GITHUB_REF#refs/tags/} - if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then + if [[ ${GITHUB_REF} == "refs/heads/main" || ${GITHUB_REF} =~ refs/pull/([0-9]+)/merge ]]; then VERSION=latest fi + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - name: Get Git Revision @@ -35,7 +41,7 @@ jobs: - name: PrepareReg Names run: | - echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - name: Setup QEMU uses: docker/setup-qemu-action@v3 @@ -80,7 +86,7 @@ jobs: tags: | dragonflyoss/client:${{ steps.get_version.outputs.VERSION }} ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ steps.get_version.outputs.VERSION }} - push: true + push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new @@ -103,9 +109,10 @@ jobs: id: get_version run: | VERSION=${GITHUB_REF#refs/tags/} - if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then + if [[ ${GITHUB_REF} == "refs/heads/main" || ${GITHUB_REF} =~ refs/pull/([0-9]+)/merge ]]; then VERSION=latest fi + echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT - name: Get Git Revision @@ -116,7 +123,7 @@ jobs: - name: PrepareReg Names run: | - echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV - name: Setup QEMU uses: docker/setup-qemu-action@v3 @@ -161,7 +168,7 @@ jobs: tags: | dragonflyoss/dfinit:${{ steps.get_version.outputs.VERSION }} ghcr.io/${{ env.IMAGE_REPOSITORY }}/dfinit:${{ steps.get_version.outputs.VERSION }} - push: true + push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new diff --git a/ci/Dockerfile b/ci/Dockerfile index 059b28b7..05e5a474 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -3,8 +3,8 @@ FROM rust:1.80.0 AS builder WORKDIR /app/client RUN apt-get update && apt-get install -y \ - openssl libclang-dev pkg-config protobuf-compiler git \ - && rm -rf /var/lib/apt/lists/* + openssl libclang-dev pkg-config protobuf-compiler git \ + && rm -rf /var/lib/apt/lists/* COPY Cargo.toml Cargo.lock ./ @@ -63,7 +63,7 @@ COPY --from=builder /app/client/target/release/dfget /usr/local/bin/dfget COPY --from=builder /app/client/target/release/dfdaemon /usr/local/bin/dfdaemon COPY --from=builder /app/client/target/release/dfstore /usr/local/bin/dfstore COPY --from=builder /app/client/target/release/dfcache /usr/local/bin/dfcache -COPY --from=health /bin/grpc_health_probe /bin/grpc_health_probe COPY --from=pprof /go/bin/pprof /bin/pprof +COPY --from=health /bin/grpc_health_probe /bin/grpc_health_probe ENTRYPOINT ["/usr/local/bin/dfdaemon"]