Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ci #44

Merged
merged 9 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
version: 2
updates:
- package-ecosystem: docker
directory: "/"
schedule:
interval: monthly
time: '02:00'
open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/"
schedule:
interval: monthly
time: "02:00"
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: monthly
time: "03:00"
275 changes: 208 additions & 67 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,220 @@ on:
# Publish `master` as Docker `latest` image.
branches:
- master

# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.

# Run tests for PRs to `master` branch.
pull_request:

branches:
- "master"

jobs:
test:
runs-on: ubuntu-18.04
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Build squid image
run: docker build . --file Dockerfile --tag b4tman/squid

- name: Test image
run: docker-compose -f docker-compose.test.yml up sut

- name: Build 'ssl-bump' image
run: docker build ssl-bump --tag b4tman/squid:ssl-bump

- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: b4tman
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build squid image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: b4tman/squid
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
outputs: type=image,name=b4tman/squid,push=false

# 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
run: docker-compose -f docker-compose.test.yml up sut

- name: Build 'ssl-bump' image
uses: docker/build-push-action@v2
with:
context: ssl-bump
push: false
file: ssl-bump/Dockerfile
tags: b4tman/squid:ssl-bump
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

push:
needs: test
runs-on: ubuntu-18.04
if: github.event_name == 'push'
runs-on: ubuntu-20.04
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v2

- name: Build squid image
run: docker build . --file Dockerfile --tag b4tman/squid

- name: Build 'ssl-bump' image
run: docker build ssl-bump --tag b4tman/squid:ssl-bump

- name: Log into registry
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push squid image
run: |
IMAGE_ID=ghcr.io/${{ github.actor }}/squid

# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')

# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest

echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION

docker tag b4tman/squid $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION

- name: Push 'ssl-bump' image
run: |
IMAGE_ID=ghcr.io/${{ github.actor }}/squid-ssl-bump

# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')

# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest

echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION

docker tag b4tman/squid:ssl-bump $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
b4tman/squid
ghcr.io/b4tman/squid
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Docker meta (ssl-bump)
id: meta_ssl_bump
uses: docker/metadata-action@v3
with:
images: |
b4tman/squid
ghcr.io/b4tman/squid
flavor: |
latest=auto
suffix=ssl-bump
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
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/b4tman/squid-ssl-bump
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: b4tman
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}

- name: Build squid image
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.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
uses: docker/build-push-action@v2
with:
context: ssl-bump
push: true
file: ssl-bump/Dockerfile
platforms: linux/amd64,linux/arm/v7
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
uses: docker/build-push-action@v2
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
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: Update repo description
uses: peter-evans/dockerhub-description@v2
with:
username: b4tman
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: b4tman/app
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
[![Drone Build Status](https://cloud.drone.io/api/badges/b4tman/docker-squid/status.svg?ref=refs/heads/master)](https://cloud.drone.io/b4tman/docker-squid)
![Docker Build Status](https://img.shields.io/docker/cloud/build/b4tman/squid)
[![Drone Build Status](https://cloud.drone.io/api/badges/b4tman/docker-squid/status.svg?ref=refs/heads/master)](https://cloud.drone.io/b4tman/docker-squid)
![Docker Build Status](https://img.shields.io/docker/cloud/build/b4tman/squid)
![Docker Image CI Status](https://github.com/b4tman/docker-squid/workflows/Docker%20Image%20CI/badge.svg)

# docker-squid

Docker Squid container based on Alpine Linux.

Automated builds of the image are available on [Dockerhub](https://hub.docker.com/r/b4tman/squid).
Automated builds of the image are available on:

- DockerHub:
- [b4tman/squid](https://hub.docker.com/r/b4tman/squid)
- Github:
- [ghcr.io/b4tman/squid](https://github.com/users/b4tman/packages/container/package/squid)
- [ghcr.io/b4tman/squid-armhf](https://github.com/users/b4tman/packages/container/package/squid-armhf)
- [ghcr.io/b4tman/squid-ssl-bump](https://github.com/users/b4tman/packages/container/package/squid-ssl-bump)

# Quick Start

Expand All @@ -29,7 +36,6 @@ docker-compose up

- **SQUID_CONFIG_FILE**: Specify the configuration file for squid. Defaults to `/etc/squid/squid.conf`.


## Example:

```bash
Expand All @@ -39,4 +45,4 @@ docker run -p 3128:3128 \
b4tman/squid
```

This will start a squid container with your config file `/srv/docker/squid/squid.conf`.
This will start a squid container with your config file `/srv/docker/squid/squid.conf`.