|
6 | 6 | pull_request: |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - docker-linux-build: |
| 9 | + # Parallelized: run quick docker build tests per-Dockerfile in parallel |
| 10 | + linux-test: |
10 | 11 | runs-on: ubuntu-latest |
11 | 12 | container: |
12 | 13 | image: hairyhenderson/dockerfiles-builder:latest |
13 | 14 | env: |
14 | 15 | BASHBREW_LIBRARY: ./library |
15 | 16 | BASHBREW_NAMESPACE: caddy |
16 | 17 | DOCKER_BUILDKIT: '1' |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + path: |
| 21 | + - 2.10/alpine |
| 22 | + - 2.10/builder |
| 23 | + - 2.11/alpine |
| 24 | + - 2.11/builder |
17 | 25 | steps: |
18 | 26 | - uses: actions/checkout@master |
19 | | - - name: non-master build test |
20 | | - run: | |
21 | | - docker build -f 2.10/alpine/Dockerfile 2.10/alpine |
22 | | - docker build -f 2.10/builder/Dockerfile 2.10/builder |
| 27 | + - name: non-master build test (per-path) |
23 | 28 | if: github.repository != 'caddyserver/caddy-docker' || github.ref != 'refs/heads/master' |
| 29 | + run: | |
| 30 | + docker build -f ${{ matrix.path }}/Dockerfile ${{ matrix.path }} |
| 31 | +
|
| 32 | + # Main linux bashbrew build. |
| 33 | + linux-build: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + container: |
| 36 | + image: hairyhenderson/dockerfiles-builder:latest |
| 37 | + env: |
| 38 | + BASHBREW_LIBRARY: ./library |
| 39 | + BASHBREW_NAMESPACE: caddy |
| 40 | + DOCKER_BUILDKIT: '1' |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@master |
| 43 | + |
24 | 44 | - name: build |
25 | 45 | run: bashbrew build caddy |
| 46 | + |
26 | 47 | - name: push |
| 48 | + if: github.repository == 'caddyserver/caddy-docker' && github.ref == 'refs/heads/master' |
27 | 49 | # NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/caddyserver/caddy-docker/settings |
28 | 50 | # the user must have permission to push to https://hub.docker.com/r/caddy/caddy |
29 | 51 | run: | |
30 | 52 | echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin |
31 | 53 | bashbrew push caddy |
32 | | - if: github.repository == 'caddyserver/caddy-docker' && github.ref == 'refs/heads/master' |
| 54 | +
|
33 | 55 | - name: push (non-master dry run) |
| 56 | + if: github.repository != 'caddyserver/caddy-docker' || github.ref != 'refs/heads/master' |
34 | 57 | run: | |
35 | 58 | bashbrew push --dry-run caddy |
36 | | - if: github.repository != 'caddyserver/caddy-docker' || github.ref != 'refs/heads/master' |
37 | 59 |
|
38 | | - docker-windows-build: |
39 | | - runs-on: windows-2022 |
40 | | - # env: |
41 | | - # BASHBREW_LIBRARY: ./library |
42 | | - # BASHBREW_NAMESPACE: caddy |
| 60 | +
|
| 61 | + # Parallelized: run quick windows docker build tests per-Dockerfile in parallel |
| 62 | + windows-test: |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + include: |
| 66 | + - version: '2.10' |
| 67 | + os: ltsc2022 |
| 68 | + runner: windows-2022 |
| 69 | + - version: '2.10' |
| 70 | + os: ltsc2025 |
| 71 | + runner: windows-2025 |
| 72 | + - version: '2.11' |
| 73 | + os: ltsc2022 |
| 74 | + runner: windows-2022 |
| 75 | + - version: '2.11' |
| 76 | + os: ltsc2025 |
| 77 | + runner: windows-2025 |
| 78 | + name: windows-test (${{ matrix.version }}/windows/${{ matrix.os }}) |
| 79 | + runs-on: ${{ matrix.runner }} |
43 | 80 | steps: |
44 | 81 | - uses: actions/checkout@master |
45 | | - - name: non-master build test |
46 | | - run: | |
47 | | - docker build -f 2.10/windows/ltsc2022/Dockerfile 2.10/windows/ltsc2022 |
48 | | - docker build -f 2.10/windows-nanoserver/ltsc2022/Dockerfile 2.10/windows-nanoserver/ltsc2022 |
| 82 | + - name: non-master build test (per-path) |
49 | 83 | if: github.repository != 'caddyserver/caddy-docker' || github.ref != 'refs/heads/master' |
| 84 | + shell: pwsh |
| 85 | + run: | |
| 86 | + $path = "${{ matrix.version }}/windows/${{ matrix.os }}" |
| 87 | + $nanopath = "${{ matrix.version }}/windows-nanoserver/${{ matrix.os }}" |
| 88 | + Write-Host "Building test for $path" |
| 89 | +
|
| 90 | + # Early-exit: if there's no nanoserver Dockerfile for this version/os, |
| 91 | + # just build the servercore Dockerfile and finish early. |
| 92 | + if (-not (Test-Path "$nanopath\Dockerfile")) { |
| 93 | + Write-Host "No nanoserver Dockerfile at $nanopath; building servercore only" |
| 94 | + docker build -f "$path\Dockerfile" "$path" |
| 95 | + exit 0 |
| 96 | + } |
| 97 | +
|
| 98 | + # nanoserver Dockerfile exists — parse it for the referenced servercore tag. |
| 99 | + $nanoDockerfile = Get-Content "$nanopath\Dockerfile" -Raw |
| 100 | + if (-not ($nanoDockerfile -match 'COPY\s+--from=caddy:([^\s]+)')) { |
| 101 | + throw "Could not find 'COPY --from=caddy:<tag>' in $nanopath/Dockerfile; aborting nanoserver test." |
| 102 | + } |
| 103 | +
|
| 104 | + $referencedTag = $Matches[1] |
| 105 | + Write-Host "Found nanoserver copy-from tag: $referencedTag" |
| 106 | +
|
| 107 | + # Ensure the servercore Dockerfile exists and build/tag it so nanoserver can COPY from it. |
| 108 | + $servercorePath = $path |
| 109 | + if (-not (Test-Path "$servercorePath\Dockerfile")) { |
| 110 | + throw "Expected servercore Dockerfile at $servercorePath not found; cannot prepare nanoserver build." |
| 111 | + } |
| 112 | +
|
| 113 | + Write-Host "Building and tagging servercore image at $servercorePath as caddy:$referencedTag" |
| 114 | + docker build -t "caddy:$referencedTag" -f "$servercorePath\Dockerfile" "$servercorePath" |
| 115 | + Write-Host "Building nanoserver image at $nanopath" |
| 116 | + docker build -f "$nanopath\Dockerfile" "$nanopath" |
| 117 | +
|
| 118 | + # Main windows build (matrix over constraints) - runs after tests |
| 119 | + windows-build: |
| 120 | + strategy: |
| 121 | + matrix: |
| 122 | + # TODO: nanoserver depends on servercore to be |
| 123 | + # tagged beforehand, I can't figure it out so |
| 124 | + # we'll skip it for now. |
| 125 | + include: |
| 126 | + - name: core-ltsc2022 |
| 127 | + constraint: windowsservercore-ltsc2022 |
| 128 | + runner: windows-2022 |
| 129 | + # - name: nano-ltsc2022 |
| 130 | + # constraint: nanoserver-ltsc2022,windowsservercore-ltsc2022 |
| 131 | + # runner: windows-2022 |
| 132 | + - name: core-ltsc2025 |
| 133 | + constraint: windowsservercore-ltsc2025 |
| 134 | + runner: windows-2025 |
| 135 | + # - name: nano-ltsc2025 |
| 136 | + # constraint: nanoserver-ltsc2025,windowsservercore-ltsc2025 |
| 137 | + # runner: windows-2025 |
| 138 | + name: windows-build (${{ matrix.name }}) |
| 139 | + runs-on: ${{ matrix.runner }} |
| 140 | + env: |
| 141 | + BASHBREW_LIBRARY: ./library |
| 142 | + BASHBREW_NAMESPACE: caddy |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@master |
| 145 | + |
50 | 146 | - name: install bashbrew |
| 147 | + shell: bash |
51 | 148 | run: curl -o /bashbrew.exe https://doi-janky.infosiftr.net/job/bashbrew/job/master/lastSuccessfulBuild/artifact/bashbrew-windows-amd64.exe |
| 149 | + |
| 150 | + - name: set constraint args |
| 151 | + shell: bash |
| 152 | + run: | |
| 153 | + constraint="${{ matrix.constraint }}" |
| 154 | + if [[ $constraint == *,* ]]; then |
| 155 | + IFS=',' read -ra CONSTR <<< "$constraint" |
| 156 | + constr_args="" |
| 157 | + for c in "${CONSTR[@]}"; do |
| 158 | + constr_args="$constr_args --constraint $c" |
| 159 | + done |
| 160 | + else |
| 161 | + constr_args="--constraint $constraint" |
| 162 | + fi |
| 163 | + echo "CONSTR_ARGS=$constr_args" >> $GITHUB_ENV |
| 164 | +
|
52 | 165 | - name: build |
| 166 | + shell: bash |
53 | 167 | run: | |
54 | | - /bashbrew --arch windows-amd64 --constraint windowsservercore-ltsc2022 --namespace caddy --library ./library build caddy; |
55 | | - /bashbrew --arch windows-amd64 --constraint windowsnanoserver-ltsc2022 --namespace caddy --library ./library build caddy |
| 168 | + /bashbrew --arch windows-amd64 $CONSTR_ARGS build caddy |
| 169 | +
|
56 | 170 | - name: push |
| 171 | + if: github.repository == 'caddyserver/caddy-docker' && github.ref == 'refs/heads/master' |
| 172 | + shell: bash |
57 | 173 | # NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/caddyserver/caddy-docker/settings |
58 | 174 | # the user must have permission to push to https://hub.docker.com/r/caddy/caddy |
59 | 175 | run: | |
60 | 176 | echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin; |
61 | | - /bashbrew --arch windows-amd64 --constraint windowsservercore-ltsc2022 --namespace caddy --library ./library push caddy; |
62 | | - /bashbrew --arch windows-amd64 --constraint windowsnanoserver-ltsc2022 --namespace caddy --library ./library push caddy |
63 | | - if: github.repository == 'caddyserver/caddy-docker' && github.ref == 'refs/heads/master' |
| 177 | + /bashbrew --arch windows-amd64 $CONSTR_ARGS push caddy |
| 178 | +
|
64 | 179 | - name: push (non-master dry run) |
65 | | - run: | |
66 | | - /bashbrew --arch windows-amd64 --constraint windowsservercore-ltsc2022 --namespace caddy --library ./library push --dry-run caddy; |
67 | | - /bashbrew --arch windows-amd64 --constraint windowsnanoserver-ltsc2022 --namespace caddy --library ./library push --dry-run caddy |
68 | 180 | if: github.repository != 'caddyserver/caddy-docker' || github.ref != 'refs/heads/master' |
| 181 | + shell: bash |
| 182 | + run: | |
| 183 | + /bashbrew --arch windows-amd64 $CONSTR_ARGS push --dry-run caddy |
| 184 | +
|
0 commit comments