-
Notifications
You must be signed in to change notification settings - Fork 45
132 lines (121 loc) · 5.11 KB
/
docker-build.yml
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Docker build
on:
push:
paths-ignore:
- "docs"
- ".github"
jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Set derived configuration variables:
# - images: images to build (docker and/or github)
# - push: if images need to be uploaded to repository (when secrets available)
# - has_docker_token
# - has_github_token
# - cache_from: image tag to use for imported cache
# - cache_to: image tag to use for exported cache
# - github_server_url: reference to source code repository
- name: Prepare
id: prep
run: |
IMAGES=""
PUSH=false
if [ -n "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
IMAGES="gameonwhales/wolf"
PUSH=true
echo "has_docker_token=true" >> $GITHUB_OUTPUT
fi
if [ -n "${{ secrets.GHCR_TOKEN }}" ]; then
REGISTRY_IMAGE="ghcr.io/${{ github.repository_owner }}/wolf"
if [ "$IMAGES" = "" ]; then
IMAGES="ghcr.io/${REGISTRY_IMAGE}"
else
IMAGES="$IMAGES,ghcr.io/${REGISTRY_IMAGE}"
fi
PUSH=true
echo "has_github_token=true" >> $GITHUB_OUTPUT
echo "cache_from=type=registry,ref=${REGISTRY_IMAGE}:buildcache" >> $GITHUB_OUTPUT
echo "cache_to=type=registry,ref=${REGISTRY_IMAGE}:buildcache,mode=max" >> $GITHUB_OUTPUT
else
echo "cache_from=type=registry,ref=${REGISTRY_IMAGE}:buildcache" >> $GITHUB_OUTPUT
echo "cache_to=" >> $GITHUB_OUTPUT
fi
echo "images=${IMAGES}" >> $GITHUB_OUTPUT
echo "push=${PUSH}" >> $GITHUB_OUTPUT
echo "github_server_url=${GITHUB_SERVER_URL}" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: ${{ steps.prep.outputs.images }}
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=edge,branch=master
type=ref,event=branch
type=raw,value=alpha
type=sha
flavor: latest=false # let's not produce a :latest tag
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
- name: Login to DockerHub
if: steps.prep.outputs.has_docker_token != '' # secrets not available in PRs
uses: docker/login-action@v2
with:
username: abeltramo
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: steps.prep.outputs.has_github_token != '' # secrets not available in PRs
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build GPU Drivers
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: docker/
file: docker/gpu-drivers.Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/gpu-drivers:2023.04,gameonwhales/gpu-drivers:2023.04 # TODO: set build version as param
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gpu-drivers:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gpu-drivers:buildcache,mode=max
- name: Build Gstreamer
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: docker/
file: docker/gstreamer.Dockerfile
push: true
build-args: |
GSTREAMER_VERSION=1.22.0
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/gpu-drivers:2023.04
tags: ghcr.io/${{ github.repository_owner }}/gstreamer:1.22.0,gameonwhales/gstreamer:1.22.0 # TODO: set gstreamer version as param
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gstreamer:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gstreamer:buildcache,mode=max
- name: Build Wolf
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: docker/wolf.Dockerfile
push: ${{ steps.prep.outputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/gstreamer:1.22.0
IMAGE_SOURCE=${{ steps.prep.outputs.github_server_url }}/${{ github.repository }}
cache-from: ${{ steps.prep.outputs.cache_from }}
cache-to: ${{ steps.prep.outputs.cache_to }}