2019-09-04 06:38:16 +00:00
|
|
|
name: Docker Image CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2020-02-02 15:51:35 +00:00
|
|
|
# Publish `master` as Docker `latest` image.
|
2019-09-04 06:38:16 +00:00
|
|
|
branches:
|
2023-05-02 14:11:44 +00:00
|
|
|
- master
|
2023-07-06 13:17:53 +00:00
|
|
|
- v5
|
2021-06-10 14:17:50 +00:00
|
|
|
|
2020-02-02 15:51:35 +00:00
|
|
|
# Publish `v1.2.3` tags as releases.
|
|
|
|
tags:
|
|
|
|
- v*
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
# Run tests for PRs to `master` branch.
|
2020-02-02 15:51:35 +00:00
|
|
|
pull_request:
|
2021-06-10 14:17:50 +00:00
|
|
|
branches:
|
|
|
|
- "master"
|
|
|
|
|
2023-03-01 12:34:59 +00:00
|
|
|
env:
|
|
|
|
TEST_TAG: b4tman/squid:test
|
|
|
|
|
2019-09-04 06:38:16 +00:00
|
|
|
jobs:
|
2021-06-10 14:17:50 +00:00
|
|
|
test:
|
|
|
|
runs-on: ubuntu-20.04
|
2019-09-04 06:38:16 +00:00
|
|
|
steps:
|
2023-10-01 03:07:59 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
2023-10-01 10:07:39 +00:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2023-10-01 15:28:18 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
if: github.event_name != 'pull_request'
|
2023-10-01 03:08:03 +00:00
|
|
|
uses: docker/login-action@v3
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
username: b4tman
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Cache Docker layers
|
2024-03-01 03:26:43 +00:00
|
|
|
uses: actions/cache@v4.0.1
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
|
|
|
|
- name: Build squid image
|
2023-11-01 03:42:32 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: false
|
2023-03-01 13:12:06 +00:00
|
|
|
load: true # automatically load the single-platform build result to docker images
|
2023-03-01 12:34:59 +00:00
|
|
|
tags: ${{ env.TEST_TAG }}
|
2021-06-10 14:17:50 +00:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
2022-02-11 11:48:38 +00:00
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
# Temp fix
|
|
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
|
|
- name: Move cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
|
|
|
|
|
|
- name: Test image
|
2024-01-23 19:45:13 +00:00
|
|
|
run: |
|
|
|
|
set -ex
|
|
|
|
docker compose -f docker-compose.test.yml up --pull never sut --exit-code-from sut
|
|
|
|
docker compose -f docker-compose.test.yml down
|
2023-03-01 12:34:59 +00:00
|
|
|
|
2024-01-23 19:45:13 +00:00
|
|
|
- name: set base image for 'ssl-bump'
|
2021-06-10 14:17:50 +00:00
|
|
|
run: |
|
2023-03-01 13:30:13 +00:00
|
|
|
sed -i "s%FROM b4tman/squid%FROM $TEST_TAG%" ssl-bump/Dockerfile
|
2024-01-23 19:45:13 +00:00
|
|
|
|
|
|
|
- name: Build 'ssl-bump' image
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: false
|
|
|
|
load: true
|
|
|
|
tags: ${{ env.TEST_TAG }}-ssl-bump
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
2021-06-10 14:17:50 +00:00
|
|
|
|
2024-01-23 19:45:13 +00:00
|
|
|
# Temp fix
|
|
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
|
|
- name: Move cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
|
|
|
|
|
|
- name: Test 'ssl-bump' image
|
|
|
|
run: |
|
|
|
|
set -ex
|
|
|
|
TEST_TAG="${TEST_TAG}-ssl-bump" docker compose -f docker-compose.test.yml up --pull never sut --exit-code-from sut
|
|
|
|
docker compose -f docker-compose.test.yml down
|
2020-02-02 15:51:35 +00:00
|
|
|
push:
|
|
|
|
needs: test
|
2021-06-10 14:17:50 +00:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
if: github.event_name != 'pull_request'
|
2020-02-02 15:55:25 +00:00
|
|
|
steps:
|
2023-10-01 03:07:59 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
2023-11-01 03:42:29 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
b4tman/squid
|
|
|
|
ghcr.io/b4tman/squid
|
|
|
|
flavor: |
|
2021-06-10 17:11:08 +00:00
|
|
|
latest=${{ github.ref == 'refs/heads/master' }}
|
2021-06-10 14:17:50 +00:00
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
|
|
|
|
- name: Docker meta (ssl-bump)
|
|
|
|
id: meta_ssl_bump
|
2023-11-01 03:42:29 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
b4tman/squid
|
|
|
|
ghcr.io/b4tman/squid
|
|
|
|
flavor: |
|
2021-06-10 16:19:35 +00:00
|
|
|
latest=false
|
|
|
|
suffix=-ssl-bump
|
2021-06-10 14:17:50 +00:00
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
|
|
|
|
- name: Docker meta (ssl-bump ghcr)
|
|
|
|
id: meta_ssl_bump_ghcr
|
2023-11-01 03:42:29 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
ghcr.io/b4tman/squid-ssl-bump
|
|
|
|
flavor: |
|
2021-06-10 17:11:08 +00:00
|
|
|
latest=${{ github.ref == 'refs/heads/master' }}
|
2021-06-10 14:17:50 +00:00
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
2023-10-01 10:07:39 +00:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2023-10-01 15:28:18 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
- name: Cache Docker layers
|
2024-03-01 03:26:43 +00:00
|
|
|
uses: actions/cache@v4.0.1
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
|
|
|
|
- name: Login to DockerHub
|
2023-10-01 03:08:03 +00:00
|
|
|
uses: docker/login-action@v3
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
username: b4tman
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Login to GHCR
|
2023-10-01 03:08:03 +00:00
|
|
|
uses: docker/login-action@v3
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.CR_PAT }}
|
|
|
|
|
|
|
|
- name: Build squid image
|
2023-11-01 03:42:32 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2021-06-10 17:13:01 +00:00
|
|
|
platforms: linux/amd64,linux/arm/v7
|
2021-06-10 14:17:50 +00:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
2022-02-11 11:48:38 +00:00
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
# Temp fix
|
|
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
|
|
- name: Move cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
|
|
|
|
|
|
- name: Build 'ssl-bump' image
|
2023-11-01 03:42:32 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
context: ssl-bump
|
|
|
|
push: true
|
|
|
|
file: ssl-bump/Dockerfile
|
2021-06-10 17:13:01 +00:00
|
|
|
platforms: linux/amd64,linux/arm/v7
|
2021-06-10 14:17:50 +00:00
|
|
|
tags: ${{ steps.meta_ssl_bump.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta_ssl_bump.outputs.labels }}
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
|
|
|
|
|
|
# Temp fix
|
|
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
|
|
- name: Move cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
|
|
|
|
|
|
- name: Build 'ssl-bump' image for ghcr
|
2023-11-01 03:42:32 +00:00
|
|
|
uses: docker/build-push-action@v5
|
2021-06-10 14:17:50 +00:00
|
|
|
with:
|
|
|
|
context: ssl-bump
|
|
|
|
push: true
|
|
|
|
file: ssl-bump/Dockerfile
|
|
|
|
platforms: linux/amd64,linux/arm/v7
|
|
|
|
tags: ${{ steps.meta_ssl_bump_ghcr.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta_ssl_bump_ghcr.outputs.labels }}
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
2022-02-11 11:48:38 +00:00
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
2021-06-10 14:17:50 +00:00
|
|
|
|
|
|
|
# Temp fix
|
|
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
|
|
- name: Move cache
|
|
|
|
run: |
|
|
|
|
rm -rf /tmp/.buildx-cache
|
|
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|