Repository navigation
84 lines (80 loc) · 2.95 KB
/
Copy pathdocker.yaml
File metadata and controls
84 lines (80 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Publish Docker Image
on:
push:
branches:
- main
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 0 */3 * *"
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
multi:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: arm64,arm
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4
# Setup the Github Actions cache.
- name: Cache Docker layers
uses: actions/cache@v6
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildxarch-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildxarch-
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Package
uses: docker/login-action@v4
with:
registry: ghcr.io
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}
# the arm64 is of course much slower due to qemu, so build and push amd64 **first**
# due to the way manifests work, the gap between this and the complete push below
# could result in pull failures or inconsistencies for arm64, such is life.
# further duplicated by building both release and debug builds
- name: Build and push amd64 Release Docker Image to DockerHub and Github docker registry
uses: docker/build-push-action@v7
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/naiveproxy-client:latest
ghcr.io/${{ github.actor }}/naiveproxy-client:latest
cache-from: type=local,src=/tmp/.buildx-cache
build-args: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
# first run does not export the cache
# Do it all again with both archs. the amd64 will be a huge cache hit
# this will update the manifest have both arches
- name: Build and push multiarch Release Docker Image to DockerHub and Github docker registry
uses: docker/build-push-action@v7
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/arm64,linux/arm/v7,linux/amd64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/naiveproxy-client:latest
ghcr.io/${{ github.actor }}/naiveproxy-client:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}