-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (103 loc) · 3.5 KB
/
build_docker.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
name: Deploy Docker images
# Disabled because it takes forever and is bug prone
# on:
# workflow_dispatch:
# push:
# branches: ["main"]
# tags: ["v*"]
# pull_request:
# branches:
# - "main"
concurrency: docker
jobs:
base_image:
name: Build base image
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
build-mount-path: '/var/lib/docker/volumes'
root-reserve-mb: 512
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/educelab/ci-docker
flavor: |
latest=false
tags: |
type=ref,prefix=base.pr-,event=pr
type=semver,prefix=base.,pattern={{version}}
type=semver,prefix=base.,pattern={{major}}.{{minor}}
type=raw,prefix=base.,value=edge,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.base
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha,mode=max
cache-from: type=gha
vcdeps_images:
name: Build vc-deps images
runs-on: ubuntu-latest
needs: base_image
strategy:
fail-fast: false
matrix:
type: [static, dynamic]
steps:
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/educelab/ci-docker
flavor: |
latest=false
tags: |
type=ref,prefix={{ matrix.type }}.,event=pr
type=semver,prefix={{ matrix.type }}.,pattern={{version}}
type=semver,prefix={{ matrix.type }}.,pattern={{major}}.{{minor}}
type=raw,value=edge,enable={{is_default_branch}}
type=raw,value=latest,enable={{ is_default_branch && matrix.type == 'static' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.{{ matrix.type }}
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha,mode=max
cache-from: type=gha