Update python.Dockerfile #635
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Docker Image | |
| on: | |
| push: | |
| branches: | |
| - latest | |
| - develop | |
| paths: | |
| - Dockerfile | |
| - requirements.txt | |
| - attachment.patch | |
| - python.Dockerfile | |
| - .github/workflows/docker.yml | |
| pull_request: | |
| paths: | |
| - Dockerfile | |
| - requirements.txt | |
| - attachment.patch | |
| - python.Dockerfile | |
| - .github/workflows/docker.yml | |
| workflow_dispatch: | |
| jobs: | |
| build-x86_64: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Convert Username | |
| id: un | |
| run: echo "un=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ steps.un.outputs.un }} | |
| password: ${{ github.token }} | |
| - name: Build | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-x86_64 | |
| build-args: | | |
| FLAGS=-march=x86-64-v2 -mtune=generic -fcf-protection=full | |
| - name: Build | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./python.Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-x86_64 | |
| build-args: | | |
| IMAGE=ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-x86_64 | |
| - name: Set PR-Number (PR) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| id: pr | |
| run: echo "pr=$(echo pr-${{ github.ref_name }} | sed "s|refs/pull/:||g" | sed "s|/merge||g")" >> $GITHUB_OUTPUT | |
| - name: Build (PR) | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name == 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-x86_64 | |
| build-args: | | |
| FLAGS=-march=x86-64-v2 -mtune=generic -fcf-protection=full | |
| - name: Build (PR) | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name == 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./python.Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python-x86_64 | |
| build-args: | | |
| IMAGE=ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-x86_64 | |
| build-aarch64: | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Convert Username | |
| id: un | |
| run: echo "un=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ steps.un.outputs.un }} | |
| password: ${{ github.token }} | |
| - name: Build | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-aarch64 | |
| build-args: | | |
| FLAGS=-mbranch-protection=standard | |
| - name: Build | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./python.Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-aarch64 | |
| build-args: | | |
| IMAGE=ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-aarch64 | |
| - name: Set PR-Number (PR) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| id: pr | |
| run: echo "pr=$(echo pr-${{ github.ref_name }} | sed "s|refs/pull/:||g" | sed "s|/merge||g")" >> $GITHUB_OUTPUT | |
| - name: Build (PR) | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name == 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-aarch64 | |
| build-args: | | |
| FLAGS=-mbranch-protection=standard | |
| - name: Build (PR) | |
| uses: docker/build-push-action@v6 | |
| if: ${{ github.event_name == 'pull_request' }} | |
| with: | |
| context: . | |
| file: ./python.Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python-aarch64 | |
| build-args: | | |
| IMAGE=ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-aarch64 | |
| merge: | |
| needs: [build-x86_64, build-aarch64] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Login to DockerHub | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Convert Username | |
| id: un | |
| run: echo "un=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ steps.un.outputs.un }} | |
| password: ${{ github.token }} | |
| - name: create multiarch | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-aarch64 | |
| docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-aarch64 | |
| docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-aarch64 | |
| docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-aarch64 | |
| docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}-python ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-aarch64 | |
| docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-aarch64 | |
| docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}-python ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-aarch64 | |
| docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python-aarch64 | |
| - name: show version | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| docker run --rm ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} -V | |
| docker run --rm ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }} -V | |
| docker run --rm ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} -V | |
| docker run --rm ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }} -V | |
| docker run --rm ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}-python -V | |
| docker run --rm ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python -V | |
| docker run --rm ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}-python -V | |
| docker run --rm ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python -V | |
| - name: copy nginx | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| docker run -d --pull always --platform amd64 --name nginx-x86_64 ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} | |
| docker cp nginx-x86_64:/usr/local/nginx nginx | |
| docker cp nginx-x86_64:/usr/local/lib lib | |
| docker cp nginx-x86_64:/usr/local/nginx/sbin/nginx nginx-x86_64 | |
| tar -cJf nginx-x86_64.tar.xz nginx lib | |
| rm -vr nginx lib | |
| docker run -d --pull always --platform arm64 --name nginx-aarch64 ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} | |
| docker cp nginx-aarch64:/usr/local/nginx nginx | |
| docker cp nginx-aarch64:/usr/local/lib lib | |
| docker cp nginx-aarch64:/usr/local/nginx/sbin/nginx nginx-aarch64 | |
| tar -cJf nginx-aarch64.tar.xz nginx lib | |
| rm -vr nginx lib | |
| - uses: actions/upload-artifact@v5 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| with: | |
| name: artifacts | |
| path: | | |
| nginx-x86_64 | |
| nginx-x86_64.tar.xz | |
| nginx-aarch64 | |
| nginx-aarch64.tar.xz | |
| - uses: crowbarmaster/GH-Automatic-Releases@latest | |
| if: ${{ github.event_name != 'pull_request' }} | |
| with: | |
| prerelease: false | |
| repo_token: ${{ github.token }} | |
| title: ${{ github.run_number }} | |
| automatic_release_tag: ${{ github.run_number }} | |
| files: | | |
| nginx-x86_64 | |
| nginx-x86_64.tar.xz | |
| nginx-aarch64 | |
| nginx-aarch64.tar.xz | |
| - name: Set PR-Number (PR) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| id: pr | |
| run: echo "pr=$(echo pr-${{ github.ref_name }} | sed "s|refs/pull/:||g" | sed "s|/merge||g")" >> $GITHUB_OUTPUT | |
| - name: create multiarch | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-aarch64 | |
| docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python-aarch64 | |
| - name: show version (PR) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| docker run --rm ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }} -V | |
| docker run --rm ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python -V | |
| - name: copy nginx (PR) | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| docker run -d --pull always --platform amd64 --name nginx-x86_64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }} | |
| docker cp nginx-x86_64:/usr/local/nginx nginx | |
| docker cp nginx-x86_64:/usr/local/lib lib | |
| docker cp nginx-x86_64:/usr/local/nginx/sbin/nginx nginx-x86_64 | |
| tar -cJf nginx-x86_64.tar.xz nginx lib | |
| rm -vr nginx lib | |
| docker run -d --pull always --platform arm64 --name nginx-aarch64 ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }} | |
| docker cp nginx-aarch64:/usr/local/nginx nginx | |
| docker cp nginx-aarch64:/usr/local/lib lib | |
| docker cp nginx-aarch64:/usr/local/nginx/sbin/nginx nginx-aarch64 | |
| tar -cJf nginx-aarch64.tar.xz nginx lib | |
| rm -vr nginx lib | |
| - uses: actions/upload-artifact@v5 | |
| if: ${{ github.event_name == 'pull_request' }} | |
| with: | |
| name: artifacts | |
| path: | | |
| nginx-x86_64 | |
| nginx-x86_64.tar.xz | |
| nginx-aarch64 | |
| nginx-aarch64.tar.xz | |
| - name: add comment (PR) | |
| uses: mshick/add-pr-comment@v2 | |
| if: ${{ github.event_name == 'pull_request' }} | |
| with: | |
| message: "The Docker Image can now be found here: `ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}` and `ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python`" | |
| repo-token: ${{ github.token }} |