|
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 | + include: |
| 123 | + - constraint: windowsservercore-ltsc2022 |
| 124 | + runner: windows-2022 |
| 125 | + - constraint: nanoserver-ltsc2022 |
| 126 | + runner: windows-2022 |
| 127 | + - constraint: windowsservercore-ltsc2025 |
| 128 | + runner: windows-2025 |
| 129 | + - constraint: nanoserver-ltsc2025 |
| 130 | + runner: windows-2025 |
| 131 | + name: windows-build (${{ matrix.constraint }}) |
| 132 | + runs-on: ${{ matrix.runner }} |
| 133 | + steps: |
| 134 | + - uses: actions/checkout@master |
| 135 | + |
50 | 136 | - name: install bashbrew |
51 | 137 | run: curl -o /bashbrew.exe https://doi-janky.infosiftr.net/job/bashbrew/job/master/lastSuccessfulBuild/artifact/bashbrew-windows-amd64.exe |
| 138 | + |
52 | 139 | - name: build |
53 | 140 | 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 |
| 141 | + /bashbrew --arch windows-amd64 --constraint ${{ matrix.constraint }} --namespace caddy --library ./library build caddy |
| 142 | +
|
56 | 143 | - name: push |
| 144 | + if: github.repository == 'caddyserver/caddy-docker' && github.ref == 'refs/heads/master' |
57 | 145 | # NOTE: DOCKERHUB_TOKEN and DOCKERHUB_USERNAME must be present in https://github.com/caddyserver/caddy-docker/settings |
58 | 146 | # the user must have permission to push to https://hub.docker.com/r/caddy/caddy |
59 | 147 | run: | |
60 | 148 | 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' |
| 149 | + /bashbrew --arch windows-amd64 --constraint ${{ matrix.constraint }} --namespace caddy --library ./library push caddy |
| 150 | +
|
64 | 151 | - 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 | 152 | if: github.repository != 'caddyserver/caddy-docker' || github.ref != 'refs/heads/master' |
| 153 | + run: | |
| 154 | + /bashbrew --arch windows-amd64 --constraint ${{ matrix.constraint }} --namespace caddy --library ./library push --dry-run caddy |
| 155 | +
|
0 commit comments