Skip to content

Update Dockerfile

Update Dockerfile #547

Workflow file for this run

name: Build Docker Image
on:
push:
branches:
- latest
- develop
paths:
- Dockerfile
- dns.Dockerfile
- .github/workflows/docker.yml
pull_request:
paths:
- Dockerfile
- dns.Dockerfile
- .github/workflows/docker.yml
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read version
id: version
run: echo "version=$(cat Dockerfile | grep -wE "ARG CLOUDFLARED_VERSION=*" | sed "s|ARG CLOUDFLARED_VERSION=||g" | sed "s| \\\||g")" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 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 cloudflared
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'pull_request' }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}
ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}
- name: create version tag if latest
if: ${{ github.ref_name == 'latest' }}
run: |
docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.version.outputs.version }} ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}
docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.version.outputs.version }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }}
- name: Build cloudflared-dns
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'pull_request' }}
with:
context: .
file: ./dns.Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }}
${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ github.ref_name }}
ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }}
ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ github.ref_name }}
- name: create dns and version tag if latest
if: ${{ github.ref_name == 'latest' }}
run: |
docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }}
docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ steps.version.outputs.version }} ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }}
docker buildx imagetools create --tag ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ steps.version.outputs.version }} ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ github.ref_name }}
docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }}
docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ steps.version.outputs.version }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }}
docker buildx imagetools create --tag ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ steps.version.outputs.version }} ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ github.ref_name }}
- name: show version
if: ${{ github.event_name != 'pull_request' }}
run: |
docker run --rm --entrypoint cloudflared ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} version
docker run --rm --entrypoint cloudflared ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }} version
docker run --rm --entrypoint cloudflared ${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ github.ref_name }} version
docker run --rm --entrypoint cloudflared ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ github.ref_name }} version
docker run --rm --entrypoint cloudflared ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:dns-${{ github.ref_name }} version
docker run --rm --entrypoint cloudflared ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ github.ref_name }} version
- 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 cloudflared (PR)
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'pull_request' }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4
push: ${{ github.event_name == 'pull_request' }}
tags: ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}
- name: Build cloudflared-dns (PR)
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'pull_request' }}
with:
context: .
file: ./dns.Dockerfile
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 #,linux/amd64/v2,linux/amd64/v3,linux/amd64/v4
push: ${{ github.event_name == 'pull_request' }}
tags: |
ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-dns
ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ steps.pr.outputs.pr }}
- name: show version (PR)
if: ${{ github.event_name == 'pull_request' }}
run: |
docker run --rm --entrypoint cloudflared ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }} version
docker run --rm --entrypoint cloudflared ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-dns version
docker run --rm --entrypoint cloudflared ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ steps.pr.outputs.pr }} version
- name: add comment (PR)
uses: mshick/add-pr-comment@v2
if: ${{ github.event_name == 'pull_request' }}
with:
message: "The Docker Images can now be found here: `ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}`/`ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}:${{ steps.pr.outputs.pr }}-dns`/`ghcr.io/${{ steps.un.outputs.un }}/${{ github.event.repository.name }}-dns:${{ steps.pr.outputs.pr }}`"
repo-token: ${{ github.token }}