-
Notifications
You must be signed in to change notification settings - Fork 5
177 lines (177 loc) · 9.03 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Build Docker Image
on:
# schedule:
# - cron: "0 0 */6 * *"
push:
branches:
- latest
- develop
paths:
- Dockerfile
- python.Dockerfile
- .github/workflows/docker.yml
pull_request:
paths:
- Dockerfile
- python.Dockerfile
- .github/workflows/docker.yml
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64 #all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
- 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: Build
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'pull_request' }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4 #,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}
${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}
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 }}
- name: Build
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'pull_request' }}
with:
context: .
file: ./python.Dockerfile
platforms: linux/amd64,linux/arm64 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4 #,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}-python
${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.run_number }}-python
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
- 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/nginx/sbin/nginx nginx-x86_64
docker cp nginx-x86_64:/usr/local/modsecurity/lib/libmodsecurity.so.3 nginx/libmodsecurity.so.3
tar -cJf nginx-x86_64.tar.xz nginx
rm -r nginx
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/nginx/sbin/nginx nginx-aarch64
docker cp nginx-aarch64:/usr/local/modsecurity/lib/libmodsecurity.so.3 nginx/libmodsecurity.so.3
tar -cJf nginx-aarch64.tar.xz nginx
rm -r nginx
- uses: actions/upload-artifact@v4
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: Build (PR)
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'pull_request' }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4 #,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
push: ${{ github.event_name == 'pull_request' }}
tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}
- name: Build (PR)
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'pull_request' }}
with:
context: .
file: ./python.Dockerfile
platforms: linux/amd64,linux/arm64 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4 #,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
push: ${{ github.event_name == 'pull_request' }}
tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-python
- 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/nginx/sbin/nginx nginx-x86_64
docker cp nginx-x86_64:/usr/local/modsecurity/lib/libmodsecurity.so.3 nginx/libmodsecurity.so.3
tar -cJf nginx-x86_64.tar.xz nginx
rm -r nginx
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/nginx/sbin/nginx nginx-aarch64
docker cp nginx-aarch64:/usr/local/modsecurity/lib/libmodsecurity.so.3 nginx/libmodsecurity.so.3
tar -cJf nginx-aarch64.tar.xz nginx
rm -r nginx
- uses: actions/upload-artifact@v4
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 }}