forked from OffchainLabs/nitro
-
Notifications
You must be signed in to change notification settings - Fork 13
93 lines (82 loc) · 3 KB
/
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
name: Docker build CI
run-name: Docker build CI triggered from @${{ github.actor }} of ${{ github.head_ref }}
on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
- master
- develop
jobs:
docker:
name: Docker build
runs-on: ubuntu-8
services:
# local registery
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-
- name: Build nitro-node docker
uses: docker/build-push-action@v2
with:
target: nitro-node
push: true
context: .
tags: localhost:5000/nitro-node:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Build nitro-node-dev docker
uses: docker/build-push-action@v2
with:
target: nitro-node-dev
push: true
context: .
tags: localhost:5000/nitro-node-dev:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Print WAVM module root
id: module-root
run: |
# Unfortunately, `docker cp` seems to always result in a "permission denied"
# We work around this by piping a tarball through stdout
docker run --rm --entrypoint tar localhost:5000/nitro-node-dev:latest -cf - target/machines/latest | tar xf -
module_root="$(cat "target/machines/latest/module-root.txt")"
echo "name=module-root=$module_root" >> $GITHUB_STATE
echo -e "\x1b[1;34mWAVM module root:\x1b[0m $module_root"
- name: Upload WAVM machine as artifact
uses: actions/upload-artifact@v3
with:
name: wavm-machine-${{ steps.module-root.outputs.module-root }}
path: target/machines/latest/*
if-no-files-found: error
- name: Move cache
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Clear cache on failure
if: failure()
run: |
keys=(${{ runner.os }}-buildx- ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }})
for key in "${keys[@]}"; do
curl -X DELETE -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/caches/$key"
done