mirror of
https://github.com/docker/build-push-action.git
synced 2025-06-13 22:57:12 +02:00
Compare commits
219 Commits
Author | SHA1 | Date | |
---|---|---|---|
1104d47137 | |||
838bf90c88 | |||
337a09d182 | |||
37abcedcc1 | |||
67109bc4b2 | |||
d1b0eb0a29 | |||
a0635fe7cd | |||
f834265449 | |||
0191543e0b | |||
2a16835223 | |||
9b96801525 | |||
6afac853c9 | |||
3bfdd83cd7 | |||
316d5eb8b3 | |||
1d910c8aa2 | |||
f9ccca010f | |||
c40bf0fdf6 | |||
223ed1ebd4 | |||
fdafae777b | |||
0cb700ffba | |||
ee7989df81 | |||
74f883a069 | |||
0149503e26 | |||
26ce4f3617 | |||
ed2672fc33 | |||
472ccddef1 | |||
d235d2d5ea | |||
2f519a7883 | |||
4eb68bb2ac | |||
b4755849f0 | |||
ade1a6afe3 | |||
21d6059e1e | |||
c2c50190db | |||
a154a68da0 | |||
4ac90f5dca | |||
175d02bffe | |||
546378e7fb | |||
ffe65bfc27 | |||
d4c14fd006 | |||
6e95f19fb8 | |||
2a752d5a63 | |||
c56af95754 | |||
75aaa63262 | |||
f97d6e2850 | |||
47c00d78bf | |||
871b930e7a | |||
105bf59b00 | |||
48888e0b13 | |||
6b820ad47e | |||
e1a10350ee | |||
0f5a7d48d5 | |||
6a6e8c7c14 | |||
e189a1cb78 | |||
2cf0d6fbdc | |||
3cde535b0c | |||
83a00fb5e6 | |||
1d5915004a | |||
2e87529dad | |||
e27bcee4eb | |||
71d260c49a | |||
965c6a410d | |||
08aa123a28 | |||
1527803881 | |||
a49d9ab751 | |||
cbb574ee73 | |||
8b56e74b48 | |||
a5024d816a | |||
2235b57edd | |||
15b9e74b95 | |||
48daa618bd | |||
c84f382811 | |||
cd5d0b79ea | |||
30a32246ba | |||
1f19633b92 | |||
67af6dc1d3 | |||
988cb093f2 | |||
1cb9d22b93 | |||
5ffbca1432 | |||
a8d76c070a | |||
12b1e419c2 | |||
2a60beff0d | |||
5268745b5f | |||
a2a27346c0 | |||
05d9e522ae | |||
42863b1282 | |||
c372f73edc | |||
d17cab8f42 | |||
4c2810ab91 | |||
307a009589 | |||
f2c26aa560 | |||
a806b8fe18 | |||
ae74c4950a | |||
80c878df65 | |||
a571ccfa72 | |||
283625c36b | |||
bb751c2095 | |||
8d9444d675 | |||
c5e6528d5d | |||
ceb414dc73 | |||
dda70725ed | |||
e551b19e49 | |||
3554377aa3 | |||
a62bc1b22b | |||
c2085839e1 | |||
fcd91249e5 | |||
0ebe720aed | |||
38b45804b5 | |||
ba317382dc | |||
43721d2346 | |||
5ea21bf2ba | |||
300b1bdff7 | |||
84580d7737 | |||
a460b5e683 | |||
9f1392c9bf | |||
9472e90210 | |||
5accc8e023 | |||
f7a2a67b4c | |||
b905f177bc | |||
0779722168 | |||
fd75456293 | |||
ada965aa7b | |||
b5730d2471 | |||
839389a46c | |||
34c1caa1ce | |||
6ff230f13e | |||
75c825aabc | |||
5f7b938b8c | |||
7ae34a20f3 | |||
acb76cdd52 | |||
2d081a4fd5 | |||
ac9327eae2 | |||
7c41daf2a5 | |||
e115266953 | |||
50fa0058d9 | |||
309fb9180f | |||
db68526220 | |||
fe02965b48 | |||
5af8693d82 | |||
7f9d37fa54 | |||
d7458455bb | |||
1ca185b339 | |||
eebf87aed1 | |||
d8b0ca6f0e | |||
da767377fb | |||
8c76bb76c2 | |||
b598b2a3bd | |||
eb2857f4ca | |||
f4cf574474 | |||
5c924147ba | |||
253376207c | |||
6f7a604875 | |||
604f033158 | |||
5645ea7274 | |||
1814d3dfb3 | |||
fc5a732e0c | |||
b1aeb1103e | |||
e31f93ab9f | |||
9ed5823618 | |||
4222161e3e | |||
67ff4df4b7 | |||
91274a04da | |||
ff329397c0 | |||
04841f2a72 | |||
049b7cab08 | |||
0a196c9deb | |||
94e0a28d6a | |||
5e11b373bf | |||
6f3b90dea1 | |||
f71a68fb09 | |||
82446970f9 | |||
2cf7b61533 | |||
0732bea0f8 | |||
96daefdf52 | |||
9f46d13e71 | |||
a8f79af565 | |||
04d5124fcb | |||
541dfa92f4 | |||
291bae5a41 | |||
91520dfd9f | |||
a41d90ba13 | |||
22baeb6cdf | |||
6061a365d8 | |||
9962be8aaf | |||
375f72aff6 | |||
8ba85ead00 | |||
c6dca826de | |||
0c3d31c275 | |||
5681933133 | |||
821890eae4 | |||
d0931a71a9 | |||
326ec1ede4 | |||
b0c26e5619 | |||
3139e8d280 | |||
a66e35b9cb | |||
6a98f97e24 | |||
26f24d6851 | |||
b0b7751850 | |||
c0b121fe44 | |||
09d66c261a | |||
24d162ecb4 | |||
6484a61448 | |||
c40e0ee07a | |||
e06a3af40d | |||
2e10e1984b | |||
1a60e0d706 | |||
3530a97c47 | |||
3c507bedc4 | |||
7c64fd5e10 | |||
c65ff7ffb1 | |||
2a8d638779 | |||
900c06250b | |||
b5e5b85e1b | |||
cf25934f0f | |||
37831a7a20 | |||
ad1d2e93be | |||
e80adc3299 | |||
7594ecce5b | |||
1bc1040cae | |||
fcaaa5e487 |
23
.eslintrc.json
Normal file
23
.eslintrc.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es2021": true,
|
||||||
|
"jest/globals": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:jest/recommended",
|
||||||
|
"plugin:prettier/recommended"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint",
|
||||||
|
"jest",
|
||||||
|
"prettier"
|
||||||
|
]
|
||||||
|
}
|
BIN
.github/build-push-action.png
vendored
BIN
.github/build-push-action.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 19 KiB |
717
.github/workflows/ci.yml
vendored
717
.github/workflows/ci.yml
vendored
@ -2,12 +2,25 @@ name: ci
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
buildx-version:
|
||||||
|
description: 'Buildx version or Git context'
|
||||||
|
default: 'latest'
|
||||||
|
required: false
|
||||||
|
buildkit-image:
|
||||||
|
description: 'BuildKit image'
|
||||||
|
default: 'moby/buildkit:buildx-stable-1'
|
||||||
|
required: false
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- 'master'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- 'master'
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILDX_VERSION: latest
|
||||||
|
BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
minimal:
|
minimal:
|
||||||
@ -15,21 +28,21 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: action
|
path: action
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./action
|
uses: ./action
|
||||||
with:
|
with:
|
||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
git-context:
|
git-context:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -41,19 +54,21 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: action
|
path: action
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: network=host
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
@ -69,10 +84,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0 --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
-
|
-
|
||||||
name: Check digest
|
name: Check digest
|
||||||
run: |
|
run: |
|
||||||
@ -80,10 +92,6 @@ jobs:
|
|||||||
echo "::error::Digest should not be empty"
|
echo "::error::Digest should not be empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
git-context-secret:
|
git-context-secret:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -95,18 +103,21 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: action
|
path: action
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
driver-opts: network=host
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
@ -132,10 +143,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0 --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
-
|
-
|
||||||
name: Check digest
|
name: Check digest
|
||||||
run: |
|
run: |
|
||||||
@ -143,19 +151,9 @@ jobs:
|
|||||||
echo "::error::Digest should not be empty"
|
echo "::error::Digest should not be empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
path-context:
|
path-context:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
buildx-version:
|
|
||||||
- ""
|
|
||||||
- latest
|
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2
|
image: registry:2
|
||||||
@ -164,17 +162,19 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.buildx-version }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: network=host
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
@ -190,10 +190,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0 --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
-
|
-
|
||||||
name: Check digest
|
name: Check digest
|
||||||
run: |
|
run: |
|
||||||
@ -201,17 +198,13 @@ jobs:
|
|||||||
echo "::error::Digest should not be empty"
|
echo "::error::Digest should not be empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Stop docker
|
name: Stop docker
|
||||||
run: |
|
run: |
|
||||||
@ -232,23 +225,23 @@ jobs:
|
|||||||
echo "::error::Should have failed"
|
echo "::error::Should have failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
error-buildx:
|
error-buildx:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
id: docker_build
|
id: docker_build
|
||||||
@ -268,10 +261,6 @@ jobs:
|
|||||||
echo "::error::Should have failed"
|
echo "::error::Should have failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
docker-driver:
|
docker-driver:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -283,7 +272,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
id: docker_build
|
id: docker_build
|
||||||
@ -293,17 +282,13 @@ jobs:
|
|||||||
file: ./test/Dockerfile
|
file: ./test/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: localhost:5000/name/app:latest
|
tags: localhost:5000/name/app:latest
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
export-docker:
|
export-docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Build
|
name: Build
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -316,20 +301,43 @@ jobs:
|
|||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker image inspect myimage:latest
|
docker image inspect myimage:latest
|
||||||
|
|
||||||
|
secret:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
-
|
-
|
||||||
name: Dump context
|
name: Checkout
|
||||||
if: always()
|
uses: actions/checkout@v3
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./test/secret.Dockerfile
|
||||||
|
secrets: |
|
||||||
|
MYSECRET=foo
|
||||||
|
INVALID_SECRET=
|
||||||
|
|
||||||
network:
|
network:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: List networks
|
name: List networks
|
||||||
run: docker network ls
|
run: docker network ls
|
||||||
@ -340,19 +348,275 @@ jobs:
|
|||||||
context: ./test
|
context: ./test
|
||||||
tags: name/app:latest
|
tags: name/app:latest
|
||||||
network: host
|
network: host
|
||||||
|
|
||||||
|
shm-size:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
-
|
-
|
||||||
name: Dump context
|
name: Checkout
|
||||||
if: always()
|
uses: actions/checkout@v3
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
file: ./test/shmsize.Dockerfile
|
||||||
|
tags: name/app:latest
|
||||||
|
shm-size: 2g
|
||||||
|
|
||||||
|
ulimit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
file: ./test/ulimit.Dockerfile
|
||||||
|
tags: name/app:latest
|
||||||
|
ulimit: |
|
||||||
|
nofile=1024:1024
|
||||||
|
nproc=3
|
||||||
|
|
||||||
|
cgroup-parent:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
file: ./test/cgroup.Dockerfile
|
||||||
|
tags: name/app:latest
|
||||||
|
cgroup-parent: foo
|
||||||
|
|
||||||
|
add-hosts:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
file: ./test/addhost.Dockerfile
|
||||||
|
tags: name/app:latest
|
||||||
|
add-hosts: |
|
||||||
|
docker:10.180.0.1
|
||||||
|
foo:10.0.0.1
|
||||||
|
|
||||||
|
build-contexts:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
file: ./test/buildcontext.Dockerfile
|
||||||
|
build-contexts: |
|
||||||
|
alpine=docker-image://debian:stable-slim
|
||||||
|
tags: name/app:latest
|
||||||
|
|
||||||
|
no-cache-filters:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
file: ./test/nocachefilter.Dockerfile
|
||||||
|
no-cache-filters: build
|
||||||
|
tags: name/app:latest
|
||||||
|
cache-from: type=gha,scope=nocachefilter
|
||||||
|
cache-to: type=gha,scope=nocachefilter,mode=max
|
||||||
|
|
||||||
|
attests-compat:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- buildx: latest
|
||||||
|
buildkit: moby/buildkit:buildx-stable-1
|
||||||
|
- buildx: latest
|
||||||
|
buildkit: moby/buildkit:v0.10.6
|
||||||
|
- buildx: v0.9.1
|
||||||
|
buildkit: moby/buildkit:buildx-stable-1
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.buildx }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ matrix.buildkit }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test/go
|
||||||
|
file: ./test/go/Dockerfile
|
||||||
|
outputs: type=cacheonly
|
||||||
|
|
||||||
|
provenance:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
attrs:
|
||||||
|
- ''
|
||||||
|
- mode=max
|
||||||
|
- builder-id=foo
|
||||||
|
- false
|
||||||
|
- true
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test/go
|
||||||
|
file: ./test/go/Dockerfile
|
||||||
|
target: binary
|
||||||
|
outputs: type=oci,dest=/tmp/build.tar
|
||||||
|
provenance: ${{ matrix.attrs }}
|
||||||
|
cache-from: type=gha,scope=provenance
|
||||||
|
cache-to: type=gha,scope=provenance,mode=max
|
||||||
|
|
||||||
|
sbom:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- target: image
|
||||||
|
output: type=image,name=localhost:5000/name/app:latest,push=true
|
||||||
|
- target: binary
|
||||||
|
output: /tmp/buildx-build
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test/go
|
||||||
|
file: ./test/go/Dockerfile
|
||||||
|
target: ${{ matrix.target }}
|
||||||
|
outputs: ${{ matrix.output }}
|
||||||
|
sbom: true
|
||||||
|
cache-from: type=gha,scope=attests-${{ matrix.target }}
|
||||||
|
cache-to: type=gha,scope=attests-${{ matrix.target }},mode=max
|
||||||
|
-
|
||||||
|
name: Inspect image
|
||||||
|
if: matrix.target == 'image'
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
||||||
|
-
|
||||||
|
name: Check output folder
|
||||||
|
if: matrix.target == 'binary'
|
||||||
|
run: |
|
||||||
|
tree /tmp/buildx-build
|
||||||
|
-
|
||||||
|
name: Print SBOM
|
||||||
|
if: matrix.target == 'binary'
|
||||||
|
run: |
|
||||||
|
cat /tmp/buildx-build/sbom.spdx.json | jq
|
||||||
|
|
||||||
multi:
|
multi:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
buildx-version:
|
|
||||||
- ""
|
|
||||||
- latest
|
|
||||||
dockerfile:
|
dockerfile:
|
||||||
- multi
|
- multi
|
||||||
- multi-sudo
|
- multi-sudo
|
||||||
@ -364,17 +628,19 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.buildx-version }}
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: network=host
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
@ -391,10 +657,7 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0 --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
-
|
-
|
||||||
name: Check digest
|
name: Check digest
|
||||||
run: |
|
run: |
|
||||||
@ -402,10 +665,94 @@ jobs:
|
|||||||
echo "::error::Digest should not be empty"
|
echo "::error::Digest should not be empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
digest:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DOCKER_IMAGE: localhost:5000/name/app
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
driver:
|
||||||
|
- docker
|
||||||
|
- docker-container
|
||||||
|
load:
|
||||||
|
- true
|
||||||
|
- false
|
||||||
|
push:
|
||||||
|
- true
|
||||||
|
- false
|
||||||
|
exclude:
|
||||||
|
- driver: docker
|
||||||
|
load: true
|
||||||
|
push: true
|
||||||
|
- driver: docker-container
|
||||||
|
load: true
|
||||||
|
push: true
|
||||||
|
- driver: docker
|
||||||
|
load: false
|
||||||
|
push: false
|
||||||
|
- driver: docker-container
|
||||||
|
load: false
|
||||||
|
push: false
|
||||||
|
services:
|
||||||
|
registry:
|
||||||
|
image: registry:2
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
steps:
|
||||||
-
|
-
|
||||||
name: Dump context
|
name: Checkout
|
||||||
if: always()
|
uses: actions/checkout@v3
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver: ${{ matrix.driver }}
|
||||||
|
driver-opts: |
|
||||||
|
network=host
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
id: docker_build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
context: ./test
|
||||||
|
load: ${{ matrix.load }}
|
||||||
|
push: ${{ matrix.push }}
|
||||||
|
tags: ${{ env.DOCKER_IMAGE }}:latest
|
||||||
|
platforms: ${{ matrix.platforms }}
|
||||||
|
-
|
||||||
|
name: Docker images
|
||||||
|
run: |
|
||||||
|
docker image ls --no-trunc
|
||||||
|
-
|
||||||
|
name: Check digest
|
||||||
|
if: ${{ matrix.push }}
|
||||||
|
run: |
|
||||||
|
if [ -z "${{ steps.docker_build.outputs.digest }}" ]; then
|
||||||
|
echo "::error::Digest should not be empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
-
|
||||||
|
name: Check manifest
|
||||||
|
if: ${{ matrix.push }}
|
||||||
|
run: |
|
||||||
|
set -x
|
||||||
|
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}@${{ steps.docker_build.outputs.digest }} --format '{{json .}}'
|
||||||
|
-
|
||||||
|
name: Check image ID
|
||||||
|
run: |
|
||||||
|
if [ -z "${{ steps.docker_build.outputs.imageid }}" ]; then
|
||||||
|
echo "::error::Image ID should not be empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
-
|
||||||
|
name: Inspect image
|
||||||
|
if: ${{ matrix.load }}
|
||||||
|
run: |
|
||||||
|
set -x
|
||||||
|
docker image inspect ${{ steps.docker_build.outputs.imageid }}
|
||||||
|
|
||||||
registry-cache:
|
registry-cache:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -417,19 +764,20 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
uses: docker/setup-buildx-action@v2
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
network=host
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Build and push (1)
|
name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@ -444,69 +792,19 @@ jobs:
|
|||||||
cache-from: type=registry,ref=localhost:5000/name/app
|
cache-from: type=registry,ref=localhost:5000/name/app
|
||||||
cache-to: type=inline
|
cache-to: type=inline
|
||||||
-
|
-
|
||||||
name: Inspect (1)
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:latest
|
docker buildx imagetools inspect localhost:5000/name/app:latest --format '{{json .}}'
|
||||||
-
|
-
|
||||||
name: Image digest (1)
|
name: Check digest
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
-
|
|
||||||
name: Check digest (1)
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${{ steps.docker_build.outputs.digest }}" ]; then
|
if [ -z "${{ steps.docker_build.outputs.digest }}" ]; then
|
||||||
echo "::error::Digest should not be empty"
|
echo "::error::Digest should not be empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
-
|
|
||||||
name: Prune
|
|
||||||
run: |
|
|
||||||
docker buildx prune -a -f --verbose
|
|
||||||
-
|
|
||||||
name: Build and push (2)
|
|
||||||
id: docker_build2
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
context: ./test
|
|
||||||
file: ./test/multi.Dockerfile
|
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
localhost:5000/name/app:latest
|
|
||||||
localhost:5000/name/app:1.0.0
|
|
||||||
cache-from: type=registry,ref=localhost:5000/name/app
|
|
||||||
cache-to: type=inline
|
|
||||||
-
|
|
||||||
name: Inspect (2)
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:latest
|
|
||||||
-
|
|
||||||
name: Image digest (2)
|
|
||||||
run: echo ${{ steps.docker_build2.outputs.digest }}
|
|
||||||
-
|
|
||||||
name: Check digest (2)
|
|
||||||
run: |
|
|
||||||
if [ -z "${{ steps.docker_build2.outputs.digest }}" ]; then
|
|
||||||
echo "::error::Digest should not be empty"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
-
|
|
||||||
name: Compare digests
|
|
||||||
run: |
|
|
||||||
echo Compare "${{ steps.docker_build.outputs.digest }}" with "${{ steps.docker_build2.outputs.digest }}"
|
|
||||||
if [ "${{ steps.docker_build.outputs.digest }}" != "${{ steps.docker_build2.outputs.digest }}" ]; then
|
|
||||||
echo "::error::Digests should be identical"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
github-cache-first:
|
github-cache:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
digest: ${{ steps.docker_build.outputs.digest }}
|
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: registry:2
|
image: registry:2
|
||||||
@ -515,135 +813,58 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
uses: docker/setup-buildx-action@v2
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
network=host
|
network=host
|
||||||
-
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
name: Cache Docker layers
|
buildkitd-flags: --debug
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: /tmp/.buildx-cache
|
|
||||||
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-ghcache-
|
|
||||||
-
|
|
||||||
name: Erase cache
|
|
||||||
run: |
|
|
||||||
rm -rf /tmp/.buildx-cache/*
|
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
context: ./test
|
context: ./test
|
||||||
file: ./test/multi.Dockerfile
|
file: ./test/multi.Dockerfile
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
localhost:5000/name/app:latest
|
localhost:5000/name/app:latest
|
||||||
localhost:5000/name/app:1.0.0
|
localhost:5000/name/app:1.0.0
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=gha,scope=ci-${{ matrix.buildx_version }}
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
cache-to: type=gha,scope=ci-${{ matrix.buildx_version }}
|
||||||
-
|
-
|
||||||
name: Inspect
|
name: Inspect
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
docker buildx imagetools inspect localhost:5000/name/app:1.0.0 --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
-
|
|
||||||
name: Check digest
|
|
||||||
run: |
|
|
||||||
if [ -z "${{ steps.docker_build.outputs.digest }}" ]; then
|
|
||||||
echo "::error::Digest should not be empty"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
|
||||||
github-cache-hit:
|
standalone:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: github-cache-first
|
|
||||||
services:
|
|
||||||
registry:
|
|
||||||
image: registry:2
|
|
||||||
ports:
|
|
||||||
- 5000:5000
|
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Uninstall moby cli
|
||||||
uses: docker/setup-qemu-action@v1
|
run: |
|
||||||
|
sudo apt-get purge -y moby-cli moby-buildx
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
id: buildx
|
uses: docker/setup-buildx-action@v2
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
driver-opts: |
|
driver-opts: |
|
||||||
network=host
|
network=host
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Cache Docker layers
|
name: Build
|
||||||
uses: actions/cache@v2
|
|
||||||
id: cache
|
|
||||||
with:
|
|
||||||
path: /tmp/.buildx-cache
|
|
||||||
key: ${{ runner.os }}-buildx-ghcache-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-ghcache-
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
context: ./test
|
context: ./test
|
||||||
file: ./test/multi.Dockerfile
|
file: ./test/Dockerfile
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
localhost:5000/name/app:latest
|
|
||||||
localhost:5000/name/app:1.0.0
|
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
||||||
-
|
|
||||||
name: Inspect
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:1.0.0
|
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
-
|
|
||||||
name: Check digest
|
|
||||||
run: |
|
|
||||||
if [ -z "${{ steps.docker_build.outputs.digest }}" ]; then
|
|
||||||
echo "::error::Digest should not be empty"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
-
|
|
||||||
name: Compare digests
|
|
||||||
run: |
|
|
||||||
echo Compare "${{ needs.github-cache-first.outputs.digest }}" with "${{ steps.docker_build.outputs.digest }}"
|
|
||||||
if [ "${{ needs.github-cache-first.outputs.digest }}" != "${{ steps.docker_build.outputs.digest }}" ]; then
|
|
||||||
echo "::error::Digests should be identical"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
-
|
|
||||||
name: Cache hit
|
|
||||||
run: echo ${{ steps.cache.outputs.cache-hit }}
|
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
42
.github/workflows/e2e.yml
vendored
42
.github/workflows/e2e.yml
vendored
@ -2,14 +2,27 @@ name: e2e
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
buildx-version:
|
||||||
|
description: 'Buildx version or Git context'
|
||||||
|
default: 'latest'
|
||||||
|
required: false
|
||||||
|
buildkit-image:
|
||||||
|
description: 'BuildKit image'
|
||||||
|
default: 'moby/buildkit:buildx-stable-1'
|
||||||
|
required: false
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 10 * * *' # everyday at 10am
|
- cron: '0 10 * * *'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- 'master'
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILDX_VERSION: latest
|
||||||
|
BUILDKIT_IMAGE: moby/buildkit:buildx-stable-1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -52,26 +65,35 @@ jobs:
|
|||||||
slug: gcr.io/sandbox-298914/test-docker-action
|
slug: gcr.io/sandbox-298914/test-docker-action
|
||||||
username_secret: GCR_USERNAME
|
username_secret: GCR_USERNAME
|
||||||
password_secret: GCR_JSON_KEY
|
password_secret: GCR_JSON_KEY
|
||||||
|
-
|
||||||
|
registry: officialgithubactions.azurecr.io
|
||||||
|
slug: officialgithubactions.azurecr.io/test-docker-action
|
||||||
|
username_secret: AZURE_CLIENT_ID
|
||||||
|
password_secret: AZURE_CLIENT_SECRET
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: ${{ matrix.slug }}
|
images: ${{ matrix.slug }}
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
-
|
-
|
||||||
name: Login to Registry
|
name: Login to Registry
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ${{ matrix.registry }}
|
registry: ${{ matrix.registry }}
|
||||||
username: ${{ secrets[matrix.username_secret] }}
|
username: ${{ secrets[matrix.username_secret] }}
|
||||||
@ -98,8 +120,4 @@ jobs:
|
|||||||
name: Check manifest
|
name: Check manifest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect ${{ matrix.slug }}:${{ steps.meta.outputs.version }}
|
docker buildx imagetools inspect ${{ matrix.slug }}:${{ steps.meta.outputs.version }} --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
16
.github/workflows/example.yml
vendored
16
.github/workflows/example.yml
vendored
@ -1,9 +1,9 @@
|
|||||||
# This workflow is provided just as an usage example and not for repo testing/verification
|
# This workflow is provided just as an example and not for repo testing/verification
|
||||||
name: example
|
name: example
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 10 * * 0' # everyday sunday at 10am
|
- cron: '0 10 * * 0'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- '**'
|
||||||
@ -25,11 +25,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKER_IMAGE }}
|
images: ${{ env.DOCKER_IMAGE }}
|
||||||
tags: |
|
tags: |
|
||||||
@ -42,7 +42,7 @@ jobs:
|
|||||||
type=sha
|
type=sha
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
driver-opts: network=host
|
driver-opts: network=host
|
||||||
-
|
-
|
||||||
@ -71,8 +71,4 @@ jobs:
|
|||||||
name: Check manifest
|
name: Check manifest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
|
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} --format '{{json .}}'
|
||||||
-
|
|
||||||
name: Dump context
|
|
||||||
if: always()
|
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
|
||||||
|
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@ -14,19 +14,19 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Validate
|
||||||
uses: docker/bake-action@v1
|
uses: docker/bake-action@v2
|
||||||
with:
|
with:
|
||||||
targets: validate
|
targets: validate
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v1
|
uses: docker/bake-action@v2
|
||||||
with:
|
with:
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v3
|
||||||
with:
|
with:
|
||||||
file: ./coverage/clover.xml
|
file: ./coverage/clover.xml
|
||||||
|
38
.github/workflows/virtual-env.yml
vendored
38
.github/workflows/virtual-env.yml
vendored
@ -3,7 +3,17 @@ name: virtual-env
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 10 * * *' # everyday at 10am
|
- cron: '0 10 * * *'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/virtual-env.yml'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/virtual-env.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
os:
|
os:
|
||||||
@ -13,25 +23,49 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
|
- ubuntu-22.04
|
||||||
- ubuntu-20.04
|
- ubuntu-20.04
|
||||||
- ubuntu-18.04
|
- ubuntu-18.04
|
||||||
- ubuntu-16.04
|
|
||||||
steps:
|
steps:
|
||||||
|
-
|
||||||
|
name: File system
|
||||||
|
run: df -ah
|
||||||
|
-
|
||||||
|
name: Mounts
|
||||||
|
run: mount
|
||||||
|
-
|
||||||
|
name: Node info
|
||||||
|
run: node -p process
|
||||||
|
-
|
||||||
|
name: NPM version
|
||||||
|
run: npm version
|
||||||
-
|
-
|
||||||
name: List install packages
|
name: List install packages
|
||||||
run: apt list --installed
|
run: apt list --installed
|
||||||
|
-
|
||||||
|
name: Docker daemon conf
|
||||||
|
run: |
|
||||||
|
cat /etc/docker/daemon.json
|
||||||
-
|
-
|
||||||
name: Docker info
|
name: Docker info
|
||||||
run: docker info
|
run: docker info
|
||||||
-
|
-
|
||||||
name: Docker version
|
name: Docker version
|
||||||
run: docker version
|
run: docker version
|
||||||
|
-
|
||||||
|
name: Cgroups
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y cgroup-tools
|
||||||
|
lscgroup
|
||||||
-
|
-
|
||||||
name: buildx version
|
name: buildx version
|
||||||
run: docker buildx version
|
run: docker buildx version
|
||||||
-
|
-
|
||||||
name: containerd version
|
name: containerd version
|
||||||
run: containerd --version
|
run: containerd --version
|
||||||
|
-
|
||||||
|
name: Docker images
|
||||||
|
run: docker image ls
|
||||||
-
|
-
|
||||||
name: Dump context
|
name: Dump context
|
||||||
if: always()
|
if: always()
|
||||||
|
247
README.md
247
README.md
@ -1,23 +1,15 @@
|
|||||||
[](https://github.com/docker/build-push-action/releases/latest)
|
[](https://github.com/docker/build-push-action/releases/latest)
|
||||||
[](https://github.com/marketplace/actions/build-and-push-docker-images)
|
[](https://github.com/marketplace/actions/build-and-push-docker-images)
|
||||||
[](https://github.com/docker/build-push-action/actions?workflow=ci)
|
[](https://github.com/docker/build-push-action/actions?workflow=ci)
|
||||||
[](https://github.com/docker/build-push-action/actions?workflow=test)
|
[](https://github.com/docker/build-push-action/actions?workflow=test)
|
||||||
[](https://codecov.io/gh/docker/build-push-action)
|
[](https://codecov.io/gh/docker/build-push-action)
|
||||||
|
|
||||||
## Upgrade from v1
|
|
||||||
|
|
||||||
`v2` of this action includes significant updates and now uses Docker [Buildx](https://github.com/docker/buildx). It's
|
|
||||||
also rewritten as a [typescript-action](https://github.com/actions/typescript-action/) to be as close as possible
|
|
||||||
of the [GitHub Runner](https://github.com/actions/virtual-environments) during its execution.
|
|
||||||
|
|
||||||
[Upgrade notes](UPGRADE.md) with many [usage examples](#advanced-usage) have been added to handle most use cases but
|
|
||||||
`v1` is still available through [`releases/v1` branch](https://github.com/docker/build-push-action/tree/releases/v1).
|
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
GitHub Action to build and push Docker images with [Buildx](https://github.com/docker/buildx) with full support of the
|
GitHub Action to build and push Docker images with [Buildx](https://github.com/docker/buildx)
|
||||||
features provided by [Moby BuildKit](https://github.com/moby/buildkit) builder toolkit. This includes multi-platform
|
with full support of the features provided by [Moby BuildKit](https://github.com/moby/buildkit)
|
||||||
build, secrets, remote cache, etc. and different builder deployment/namespacing options.
|
builder toolkit. This includes multi-platform build, secrets, remote cache, etc.
|
||||||
|
and different builder deployment/namespacing options.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -26,56 +18,43 @@ ___
|
|||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Git context](#git-context)
|
* [Git context](#git-context)
|
||||||
* [Path context](#path-context)
|
* [Path context](#path-context)
|
||||||
* [Advanced usage](#advanced-usage)
|
* [Examples](#examples)
|
||||||
* [Multi-platform image](docs/advanced/multi-platform.md)
|
|
||||||
* [Secrets](docs/advanced/secrets.md)
|
|
||||||
* [Isolated builders](docs/advanced/isolated-builders.md)
|
|
||||||
* [Push to multi-registries](docs/advanced/push-multi-registries.md)
|
|
||||||
* [Copy between registries](docs/advanced/copy-between-registries.md)
|
|
||||||
* [Cache](docs/advanced/cache.md)
|
|
||||||
* [Registry cache](docs/advanced/cache.md#registry-cache)
|
|
||||||
* [GitHub cache](docs/advanced/cache.md#github-cache)
|
|
||||||
* [Local registry](docs/advanced/local-registry.md)
|
|
||||||
* [Export image to Docker](docs/advanced/export-docker.md)
|
|
||||||
* [Share built image between jobs](docs/advanced/share-image-jobs.md)
|
|
||||||
* [Handle tags and labels](docs/advanced/tags-labels.md)
|
|
||||||
* [Update DockerHub repo description](docs/advanced/dockerhub-desc.md)
|
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
* [Troubleshooting](#troubleshooting)
|
* [Troubleshooting](#troubleshooting)
|
||||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
* [Contributing](#contributing)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
By default, this action uses the [Git context](#git-context) so you don't need to use the
|
In the examples below we are also using 3 other actions:
|
||||||
[`actions/checkout`](https://github.com/actions/checkout/) action to checkout the repository because this will be
|
|
||||||
done directly by buildkit. The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/reference/events-that-trigger-workflows)
|
|
||||||
and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`.
|
|
||||||
|
|
||||||
Be careful because **any file mutation in the steps that precede the build step will be ignored** since
|
* [`setup-buildx`](https://github.com/docker/setup-buildx-action) action will
|
||||||
the context is based on the git reference. However, you can use the [Path context](#path-context) using the
|
create and boot a builder using by default the [`docker-container` driver](https://docs.docker.com/build/building/drivers/docker-container/).
|
||||||
[`context` input](#inputs) alongside the [`actions/checkout`](https://github.com/actions/checkout/) action to remove
|
This is **not required but recommended** using it to be able to build
|
||||||
this restriction.
|
multi-platform images, export cache, etc.
|
||||||
|
* [`setup-qemu`](https://github.com/docker/setup-qemu-action) action can be
|
||||||
In the examples below we are using 3 other actions:
|
useful if you want to add emulation support with QEMU to be able to build
|
||||||
|
against more platforms.
|
||||||
* [`setup-buildx`](https://github.com/docker/setup-buildx-action) action will create and boot a builder using by
|
* [`login`](https://github.com/docker/login-action) action will take care to
|
||||||
default the `docker-container` [builder driver](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#driver).
|
log in against a Docker registry.
|
||||||
This is **not required but recommended** using it to be able to build multi-platform images, export cache, etc.
|
|
||||||
* [`setup-qemu`](https://github.com/docker/setup-qemu-action) action can be useful if you want
|
|
||||||
to add emulation support with QEMU to be able to build against more platforms.
|
|
||||||
* [`login`](https://github.com/docker/login-action) action will take care to log in against a Docker registry.
|
|
||||||
|
|
||||||
### Git context
|
### Git context
|
||||||
|
|
||||||
|
By default, this action uses the [Git context](https://docs.docker.com/engine/reference/commandline/build/#git-repositories),
|
||||||
|
so you don't need to use the [`actions/checkout`](https://github.com/actions/checkout/)
|
||||||
|
action to check out the repository as this will be done directly by [BuildKit](https://github.com/moby/buildkit).
|
||||||
|
|
||||||
|
The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)
|
||||||
|
and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'main'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@ -83,37 +62,67 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to Docker Hub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
uses: docker/build-push-action@v3
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: user/app:latest
|
tags: user/app:latest
|
||||||
-
|
|
||||||
name: Image digest
|
|
||||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Building from the current repository automatically uses the [GitHub Token](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)
|
Be careful because **any file mutation in the steps that precede the build step
|
||||||
so it does not need to be passed. If you want to authenticate against another private repository, you have to use
|
will be ignored, including processing of the `.dockerignore` file** since
|
||||||
a [secret](docs/advanced/secrets.md) named `GIT_AUTH_TOKEN` to be able to authenticate against it with buildx:
|
the context is based on the Git reference. However, you can use the
|
||||||
|
[Path context](#path-context) using the [`context` input](#inputs) alongside
|
||||||
|
the [`actions/checkout`](https://github.com/actions/checkout/) action to remove
|
||||||
|
this restriction.
|
||||||
|
|
||||||
|
Default Git context can also be provided using the [Handlebars template](https://handlebarsjs.com/guide/)
|
||||||
|
expression `{{defaultContext}}`. Here we can use it to provide a subdirectory
|
||||||
|
to the default Git context:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
-
|
||||||
|
# Setting up Docker Buildx with docker-container driver is required
|
||||||
|
# at the moment to be able to use a subdirectory with Git context
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: "{{defaultContext}}:mysubdir"
|
||||||
|
push: true
|
||||||
|
tags: user/app:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> Subdirectory for Git context is available from [BuildKit v0.9.0](https://github.com/moby/buildkit/releases/tag/v0.9.0).
|
||||||
|
> If you're using the `docker` builder (default if `setup-buildx-action` not used),
|
||||||
|
> then BuildKit in Docker Engine will be used. As Docker Engine < v22.x.x embeds
|
||||||
|
> Buildkit 0.8.2 at the moment, it does not support this feature. It's therefore
|
||||||
|
> required to use the `setup-buildx-action` at the moment.
|
||||||
|
|
||||||
|
Building from the current repository automatically uses the [GitHub Token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication),
|
||||||
|
so it does not need to be passed. If you want to authenticate against another
|
||||||
|
private repository, you have to use a [secret](https://docs.docker.com/build/ci/github-actions/examples/#secrets)
|
||||||
|
named `GIT_AUTH_TOKEN` to be able to authenticate against it with Buildx:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
id: docker_build
|
uses: docker/build-push-action@v3
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
tags: user/app:latest
|
tags: user/app:latest
|
||||||
@ -121,9 +130,6 @@ a [secret](docs/advanced/secrets.md) named `GIT_AUTH_TOKEN` to be able to authen
|
|||||||
GIT_AUTH_TOKEN=${{ secrets.MYTOKEN }}
|
GIT_AUTH_TOKEN=${{ secrets.MYTOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
> :warning: Subdir for Git context is not yet supported ([moby/buildkit#1684](https://github.com/moby/buildkit/issues/1684))
|
|
||||||
> but you can use the [path context](#path-context) in the meantime. More info on [Docker docs website](https://docs.docker.com/engine/reference/commandline/build/#git-repositories).
|
|
||||||
|
|
||||||
### Path context
|
### Path context
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -132,7 +138,7 @@ name: ci
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 'master'
|
- 'main'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@ -140,43 +146,31 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to Docker Hub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: user/app:latest
|
tags: user/app:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Advanced usage
|
## Examples
|
||||||
|
|
||||||
* [Multi-platform image](docs/advanced/multi-platform.md)
|
See https://docs.docker.com/build/ci/github-actions/examples/.
|
||||||
* [Secrets](docs/advanced/secrets.md)
|
|
||||||
* [Isolated builders](docs/advanced/isolated-builders.md)
|
|
||||||
* [Push to multi-registries](docs/advanced/push-multi-registries.md)
|
|
||||||
* [Copy between registries](docs/advanced/copy-between-registries.md)
|
|
||||||
* [Cache](docs/advanced/cache.md)
|
|
||||||
* [Registry cache](docs/advanced/cache.md#registry-cache)
|
|
||||||
* [GitHub cache](docs/advanced/cache.md#github-cache)
|
|
||||||
* [Local registry](docs/advanced/local-registry.md)
|
|
||||||
* [Export image to Docker](docs/advanced/export-docker.md)
|
|
||||||
* [Share built image between jobs](docs/advanced/share-image-jobs.md)
|
|
||||||
* [Handle tags and labels](docs/advanced/tags-labels.md)
|
|
||||||
* [Update DockerHub repo description](docs/advanced/dockerhub-desc.md)
|
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
@ -196,53 +190,58 @@ Following inputs can be used as `step.with` keys
|
|||||||
> tags: name/app:latest,name/app:1.0.0
|
> tags: name/app:latest,name/app:1.0.0
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|---------------------|----------|------------------------------------|
|
|--------------------|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `allow` | List/CSV | List of [extra privileged entitlement](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#allow) (eg. `network.host,security.insecure`) |
|
| `add-hosts` | List/CSV | List of [customs host-to-IP mapping](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) (e.g., `docker:10.180.0.1`) |
|
||||||
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
|
| `allow` | List/CSV | List of [extra privileged entitlement](https://docs.docker.com/engine/reference/commandline/buildx_build/#allow) (e.g., `network.host,security.insecure`) |
|
||||||
| `build-args` | List | List of build-time variables |
|
| `attests` | List | List of [attestation](https://docs.docker.com/build/attestations/) parameters (e.g., `type=sbom,generator=image`) |
|
||||||
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-from) (eg. `type=local,src=path/to/dir`) |
|
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
|
||||||
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-to) (eg. `type=local,dest=path/to/dir`) |
|
| `build-args` | List | List of [build-time variables](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-arg) |
|
||||||
| `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) |
|
| `build-contexts` | List | List of additional [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., `name=path`) |
|
||||||
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
|
| `cache-from` | List | List of [external cache sources](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from) (e.g., `type=local,src=path/to/dir`) |
|
||||||
| `labels` | List | List of metadata for an image |
|
| `cache-to` | List | List of [cache export destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-to) (e.g., `type=local,dest=path/to/dir`) |
|
||||||
| `load` | Bool | [Load](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#load) is a shorthand for `--output=type=docker` (default `false`) |
|
| `cgroup-parent` | String | Optional [parent cgroup](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) for the container used in the build |
|
||||||
| `network` | String | Set the networking mode for the `RUN` instructions during build |
|
| `context` | String | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) |
|
||||||
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
|
| `file` | String | Path to the Dockerfile. (default `{context}/Dockerfile`) |
|
||||||
| `outputs` | List | List of [output destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#output) (format: `type=local,dest=path`) |
|
| `labels` | List | List of metadata for an image |
|
||||||
| `platforms` | List/CSV | List of [target platforms](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#platform) for build |
|
| `load` | Bool | [Load](https://docs.docker.com/engine/reference/commandline/buildx_build/#load) is a shorthand for `--output=type=docker` (default `false`) |
|
||||||
| `pull` | Bool | Always attempt to pull a newer version of the image (default `false`) |
|
| `network` | String | Set the networking mode for the `RUN` instructions during build |
|
||||||
| `push` | Bool | [Push](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#push) is a shorthand for `--output=type=registry` (default `false`) |
|
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
|
||||||
| `secrets` | List | List of secrets to expose to the build (eg. `key=string`, `GIT_AUTH_TOKEN=mytoken`) |
|
| `no-cache-filters` | List/CSV | Do not cache specified stages |
|
||||||
| `secret-files` | List | List of secret files to expose to the build (eg. `key=filename`, `MY_SECRET=./secret.txt`) |
|
| `outputs`¹ | List | List of [output destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#output) (format: `type=local,dest=path`) |
|
||||||
| `ssh` | List | List of SSH agent socket or keys to expose to the build |
|
| `platforms` | List/CSV | List of [target platforms](https://docs.docker.com/engine/reference/commandline/buildx_build/#platform) for build |
|
||||||
| `tags` | List/CSV | List of tags |
|
| `provenance` | Bool/String | Generate [provenance](https://docs.docker.com/build/attestations/slsa-provenance/) attestation for the build (shorthand for `--attest=type=provenance`) |
|
||||||
| `target` | String | Sets the target stage to build |
|
| `pull` | Bool | Always attempt to pull all referenced images (default `false`) |
|
||||||
|
| `push` | Bool | [Push](https://docs.docker.com/engine/reference/commandline/buildx_build/#push) is a shorthand for `--output=type=registry` (default `false`) |
|
||||||
|
| `sbom` | Bool/String | Generate [SBOM](https://docs.docker.com/build/attestations/sbom/) attestation for the build (shorthand for `--attest=type=sbom`) |
|
||||||
|
| `secrets` | List | List of [secrets](https://docs.docker.com/engine/reference/commandline/buildx_build/#secret) to expose to the build (e.g., `key=string`, `GIT_AUTH_TOKEN=mytoken`) |
|
||||||
|
| `secret-files` | List | List of [secret files](https://docs.docker.com/engine/reference/commandline/buildx_build/#secret) to expose to the build (e.g., `key=filename`, `MY_SECRET=./secret.txt`) |
|
||||||
|
| `shm-size` | String | Size of [`/dev/shm`](https://docs.docker.com/engine/reference/commandline/buildx_build/#shm-size) (e.g., `2g`) |
|
||||||
|
| `ssh` | List | List of [SSH agent socket or keys](https://docs.docker.com/engine/reference/commandline/buildx_build/#ssh) to expose to the build |
|
||||||
|
| `tags` | List/CSV | List of tags |
|
||||||
|
| `target` | String | Sets the target stage to build |
|
||||||
|
| `ulimit` | List | [Ulimit](https://docs.docker.com/engine/reference/commandline/buildx_build/#ulimit) options (e.g., `nofile=1024:1024`) |
|
||||||
|
| `github-token` | String | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`) |
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
>
|
||||||
|
> * ¹ multiple `outputs` are [not yet supported](https://github.com/moby/buildkit/issues/1555)
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
Following outputs are available
|
Following outputs are available
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|---------------|---------|---------------------------------------|
|
|------------|---------|-----------------------|
|
||||||
| `digest` | String | Image content-addressable identifier also called a digest |
|
| `imageid` | String | Image ID |
|
||||||
|
| `digest` | String | Image digest |
|
||||||
|
| `metadata` | JSON | Build result metadata |
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
See [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
|
See [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
|
||||||
|
|
||||||
## Keep up-to-date with GitHub Dependabot
|
## Contributing
|
||||||
|
|
||||||
Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot)
|
Want to contribute? Awesome! You can find information about contributing to
|
||||||
has [native GitHub Actions support](https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#package-ecosystem),
|
this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
|
||||||
to enable it on your GitHub repo all you need to do is add the `.github/dependabot.yml` file:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
# Maintain dependencies for GitHub Actions
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
```
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
* [Cannot push to a registry](#cannot-push-to-a-registry)
|
* [Cannot push to a registry](#cannot-push-to-a-registry)
|
||||||
* [BuildKit container logs](#buildkit-container-logs)
|
* [BuildKit container logs](#buildkit-container-logs)
|
||||||
* [With containerd](#with-containerd)
|
* [With containerd](#with-containerd)
|
||||||
|
* [`repository name must be lowercase`](#repository-name-must-be-lowercase)
|
||||||
|
|
||||||
## Cannot push to a registry
|
## Cannot push to a registry
|
||||||
|
|
||||||
@ -14,9 +15,11 @@ While pushing to a registry, you may encounter these kinds of issues:
|
|||||||
* `failed commit on ref "manifest-sha256:...": unexpected status: 401 Unauthorized`
|
* `failed commit on ref "manifest-sha256:...": unexpected status: 401 Unauthorized`
|
||||||
* `unexpected response: 401 Unauthorized`
|
* `unexpected response: 401 Unauthorized`
|
||||||
|
|
||||||
These issues are not directly related to this action but are rather linked to [buildx](https://github.com/docker/buildx),
|
These issues are not directly related to this action but are rather linked to
|
||||||
[buildkit](https://github.com/moby/buildkit), [containerd](https://github.com/containerd/containerd) or the registry
|
[Buildx](https://github.com/docker/buildx), [BuildKit](https://github.com/moby/buildkit),
|
||||||
on which you're pushing your image. The quality of error message depends on the registry and are usually not very informative.
|
[containerd](https://github.com/containerd/containerd) or the registry on which
|
||||||
|
you're pushing your image. The quality of error message depends on the registry
|
||||||
|
and are usually not very informative.
|
||||||
|
|
||||||
### BuildKit container logs
|
### BuildKit container logs
|
||||||
|
|
||||||
@ -25,8 +28,9 @@ action step and attach BuildKit container logs to your issue.
|
|||||||
|
|
||||||
### With containerd
|
### With containerd
|
||||||
|
|
||||||
Next you can test pushing with [containerd action](https://github.com/crazy-max/ghaction-setup-containerd) using the
|
Next you can test pushing with [containerd action](https://github.com/crazy-max/ghaction-setup-containerd)
|
||||||
following workflow. If it works then open an issue on [buildkit](https://github.com/moby/buildkit) repository.
|
using the following workflow. If it works then open an issue on [BuildKit](https://github.com/moby/buildkit)
|
||||||
|
repository.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: containerd
|
name: containerd
|
||||||
@ -40,21 +44,21 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v2
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v2
|
||||||
with:
|
with:
|
||||||
buildkitd-flags: --debug
|
buildkitd-flags: --debug
|
||||||
-
|
-
|
||||||
name: Set up containerd
|
name: Set up containerd
|
||||||
uses: crazy-max/ghaction-setup-containerd@v1
|
uses: crazy-max/ghaction-setup-containerd@v2
|
||||||
-
|
-
|
||||||
name: Build Docker image
|
name: Build Docker image
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
@ -69,3 +73,65 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo ctr --debug i push --user "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" docker.io/user/app:latest
|
sudo ctr --debug i push --user "${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }}" docker.io/user/app:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `repository name must be lowercase`
|
||||||
|
|
||||||
|
You may encounter this issue if you're using `github.repository` as a repo slug
|
||||||
|
in your tag:
|
||||||
|
|
||||||
|
```
|
||||||
|
#6 exporting to image
|
||||||
|
#6 exporting layers
|
||||||
|
#6 exporting layers 1.2s done
|
||||||
|
#6 exporting manifest sha256:b47f7dfb97b89ccd5de553af3c8cd94c4795884cbe5693e93946b1d95a7b1d12 0.0s done
|
||||||
|
#6 exporting config sha256:995e93fab8196893192f08a38deea6769dc4d98f86cf705eccc24ec96a3e271c 0.0s done
|
||||||
|
#6 ERROR: invalid reference format: repository name must be lowercase
|
||||||
|
------
|
||||||
|
> exporting to image:
|
||||||
|
------
|
||||||
|
error: failed to solve: invalid reference format: repository name must be lowercase
|
||||||
|
```
|
||||||
|
|
||||||
|
or a cache reference:
|
||||||
|
|
||||||
|
```
|
||||||
|
#10 importing cache manifest from ghcr.io/My-Org/repo:main
|
||||||
|
#10 ERROR: invalid reference format: repository name must be lowercase
|
||||||
|
```
|
||||||
|
|
||||||
|
To fix this issue you can use our [metadata action](https://github.com/docker/metadata-action)
|
||||||
|
to generate sanitized tags:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
tags: latest
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Or a dedicated step to sanitize the slug:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Sanitize repo slug
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
id: repo_slug
|
||||||
|
with:
|
||||||
|
result-encoding: string
|
||||||
|
script: return 'ghcr.io/${{ github.repository }}'.toLowerCase()
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.repo_slug.outputs.result }}:latest
|
||||||
|
```
|
||||||
|
147
UPGRADE.md
147
UPGRADE.md
@ -1,147 +0,0 @@
|
|||||||
# Upgrade notes
|
|
||||||
|
|
||||||
## v1 to v2
|
|
||||||
|
|
||||||
* Input `path` is now called `context` for consistency with other Docker build tools
|
|
||||||
* `path` defaults to current git repository so checkout action is not required in a workflow
|
|
||||||
* Rename `dockerfile` input to `file` for consistency with other Docker build tools
|
|
||||||
* Rename `always_pull` input to `pull` for consistency with other Docker build tools
|
|
||||||
* Add `builder` input to be able to choose a builder instance through our [setup-buildx action](https://github.com/docker/setup-buildx-action)
|
|
||||||
* Add `platforms` input to support multi-platform builds
|
|
||||||
* Add `allow` input
|
|
||||||
* Add `load` input
|
|
||||||
* Add `outputs` input
|
|
||||||
* Add `cache-from` input (`cache_froms` removed)
|
|
||||||
* Add `cache-to` input
|
|
||||||
* Rename `build_args` input to `build-args` for consistency with other Docker build tools
|
|
||||||
* Add `secrets` input
|
|
||||||
* Review `tags` input
|
|
||||||
* Remove `repository` input. See [Simple workflow](#simple-workflow) for migration
|
|
||||||
* Remove `username`, `password` and `registry` inputs. Login support moved to [docker/login-action](https://github.com/docker/login-action) repo
|
|
||||||
* Remove `tag_with_sha`, `tag_with_ref`, `add_git_labels` inputs. See [Tags with ref and Git labels](#tags-with-ref-and-git-labels) for migration
|
|
||||||
* Handle Git context
|
|
||||||
* Add `digest` output
|
|
||||||
|
|
||||||
### Simple workflow
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# v1
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Build and push Docker images
|
|
||||||
uses: docker/build-push-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: myorg/myrepository
|
|
||||||
always_pull: true
|
|
||||||
build_args: arg1=value1,arg2=value2
|
|
||||||
cache_froms: myorg/myrepository:latest
|
|
||||||
tags: latest
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# v2
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
build-args: |
|
|
||||||
arg1=value1
|
|
||||||
arg2=value2
|
|
||||||
cache-from: type=registry,ref=myorg/myrepository:latest
|
|
||||||
cache-to: type=inline
|
|
||||||
tags: myorg/myrepository:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
### Tags with ref and Git labels
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# v1
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Build and push Docker images
|
|
||||||
uses: docker/build-push-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
repository: myorg/myrepository
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tag_with_ref: true
|
|
||||||
tag_with_sha: true
|
|
||||||
add_git_labels: true
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# v2
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Prepare
|
|
||||||
id: prep
|
|
||||||
run: |
|
|
||||||
DOCKER_IMAGE=myorg/myrepository
|
|
||||||
VERSION=edge
|
|
||||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
|
||||||
elif [[ $GITHUB_REF == refs/heads/* ]]; then
|
|
||||||
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
|
|
||||||
elif [[ $GITHUB_REF == refs/pull/* ]]; then
|
|
||||||
VERSION=pr-${{ github.event.number }}
|
|
||||||
fi
|
|
||||||
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
|
||||||
if [ "${{ github.event_name }}" = "push" ]; then
|
|
||||||
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
|
|
||||||
fi
|
|
||||||
echo ::set-output name=version::${VERSION}
|
|
||||||
echo ::set-output name=tags::${TAGS}
|
|
||||||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.prep.outputs.tags }}
|
|
||||||
labels: |
|
|
||||||
org.opencontainers.image.source=${{ github.event.repository.html_url }}
|
|
||||||
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
|
||||||
org.opencontainers.image.revision=${{ github.sha }}
|
|
||||||
```
|
|
||||||
|
|
||||||
> You can also use the [Docker meta action to handle tags and labels](docs/advanced/tags-labels.md) based on GitHub
|
|
||||||
> actions events and Git metadata.
|
|
@ -1,13 +1,17 @@
|
|||||||
|
import {describe, expect, it, jest, test} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
import * as buildx from '../src/buildx';
|
import * as buildx from '../src/buildx';
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context';
|
||||||
|
|
||||||
const tmpNameSync = path.join('/tmp/.docker-build-push-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
const tmpNameSync = path.join('/tmp/.docker-build-push-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||||
const digest = 'sha256:bfb45ab72e46908183546477a08f8867fc40cebadd00af54b071b097aed127a9';
|
const imageID = 'sha256:bfb45ab72e46908183546477a08f8867fc40cebadd00af54b071b097aed127a9';
|
||||||
|
const metadata = `{
|
||||||
|
"containerimage.config.digest": "sha256:059b68a595b22564a1cbc167af369349fdc2ecc1f7bc092c2235cbf601a795fd",
|
||||||
|
"containerimage.digest": "sha256:b09b9482c72371486bb2c1d2c2a2633ed1d0b8389e12c8d52b9e052725c0c83c"
|
||||||
|
}`;
|
||||||
|
|
||||||
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
||||||
const tmpDir = path.join('/tmp/.docker-build-push-jest').split(path.sep).join(path.posix.sep);
|
const tmpDir = path.join('/tmp/.docker-build-push-jest').split(path.sep).join(path.posix.sep);
|
||||||
@ -24,104 +28,72 @@ jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
|
|||||||
describe('getImageID', () => {
|
describe('getImageID', () => {
|
||||||
it('matches', async () => {
|
it('matches', async () => {
|
||||||
const imageIDFile = await buildx.getImageIDFile();
|
const imageIDFile = await buildx.getImageIDFile();
|
||||||
console.log(`imageIDFile: ${imageIDFile}`);
|
await fs.writeFileSync(imageIDFile, imageID);
|
||||||
await fs.writeFileSync(imageIDFile, digest);
|
const expected = await buildx.getImageID();
|
||||||
const imageID = await buildx.getImageID();
|
expect(expected).toEqual(imageID);
|
||||||
console.log(`imageID: ${imageID}`);
|
});
|
||||||
expect(imageID).toEqual(digest);
|
});
|
||||||
|
|
||||||
|
describe('getMetadata', () => {
|
||||||
|
it('matches', async () => {
|
||||||
|
const metadataFile = await buildx.getMetadataFile();
|
||||||
|
await fs.writeFileSync(metadataFile, metadata);
|
||||||
|
const expected = await buildx.getMetadata();
|
||||||
|
expect(expected).toEqual(metadata);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getDigest', () => {
|
||||||
|
it('matches', async () => {
|
||||||
|
const metadataFile = await buildx.getMetadataFile();
|
||||||
|
await fs.writeFileSync(metadataFile, metadata);
|
||||||
|
const expected = await buildx.getDigest(metadata);
|
||||||
|
expect(expected).toEqual('sha256:b09b9482c72371486bb2c1d2c2a2633ed1d0b8389e12c8d52b9e052725c0c83c');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isLocalOrTarExporter', () => {
|
describe('isLocalOrTarExporter', () => {
|
||||||
// prettier-ignore
|
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[['type=registry,ref=user/app'], false],
|
||||||
[
|
[['type=docker'], false],
|
||||||
'type=registry,ref=user/app',
|
[['type=local,dest=./release-out'], true],
|
||||||
],
|
[['type=tar,dest=/tmp/image.tar'], true],
|
||||||
false
|
[['type=docker', 'type=tar,dest=/tmp/image.tar'], true],
|
||||||
],
|
[['"type=tar","dest=/tmp/image.tar"'], true],
|
||||||
[
|
[['" type= local" , dest=./release-out'], true],
|
||||||
[
|
[['.'], true]
|
||||||
'type=docker',
|
])('given %p returns %p', async (outputs: Array<string>, expected: boolean) => {
|
||||||
],
|
expect(buildx.isLocalOrTarExporter(outputs)).toEqual(expected);
|
||||||
false
|
});
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'type=local,dest=./release-out'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'type=tar,dest=/tmp/image.tar'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'type=docker',
|
|
||||||
'type=tar,dest=/tmp/image.tar'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'"type=tar","dest=/tmp/image.tar"'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'" type= local" , dest=./release-out'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
],
|
|
||||||
[
|
|
||||||
[
|
|
||||||
'.'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
],
|
|
||||||
])(
|
|
||||||
'given %p returns %p',
|
|
||||||
async (outputs: Array<string>, expected: boolean) => {
|
|
||||||
expect(buildx.isLocalOrTarExporter(outputs)).toEqual(expected);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isAvailable', () => {
|
describe('isAvailable', () => {
|
||||||
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
|
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
buildx.isAvailable();
|
buildx.isAvailable();
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/no-standalone-expect
|
||||||
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx'], {
|
||||||
silent: true,
|
silent: true,
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isAvailable standalone', () => {
|
||||||
|
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
buildx.isAvailable(true);
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/no-standalone-expect
|
||||||
|
expect(execSpy).toHaveBeenCalledWith(`buildx`, [], {
|
||||||
|
silent: true,
|
||||||
|
ignoreReturnCode: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('getVersion', () => {
|
describe('getVersion', () => {
|
||||||
async function isDaemonRunning() {
|
it('valid', async () => {
|
||||||
return await exec
|
const version = await buildx.getVersion();
|
||||||
.getExecOutput(`docker`, ['version', '--format', '{{.Server.Os}}'], {
|
expect(semver.valid(version)).not.toBeNull();
|
||||||
ignoreReturnCode: true,
|
});
|
||||||
silent: true
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
return !res.stdout.includes(' ') && res.exitCode == 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
(isDaemonRunning() ? it : it.skip)(
|
|
||||||
'valid',
|
|
||||||
async () => {
|
|
||||||
const version = await buildx.getVersion();
|
|
||||||
console.log(`version: ${version}`);
|
|
||||||
expect(semver.valid(version)).not.toBeNull();
|
|
||||||
},
|
|
||||||
100000
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('parseVersion', () => {
|
describe('parseVersion', () => {
|
||||||
@ -164,12 +136,10 @@ describe('getSecret', () => {
|
|||||||
secret = await buildx.getSecretString(kvp);
|
secret = await buildx.getSecretString(kvp);
|
||||||
}
|
}
|
||||||
expect(true).toBe(!invalid);
|
expect(true).toBe(!invalid);
|
||||||
console.log(`secret: ${secret}`);
|
|
||||||
expect(secret).toEqual(`id=${exKey},src=${tmpNameSync}`);
|
expect(secret).toEqual(`id=${exKey},src=${tmpNameSync}`);
|
||||||
const secretValue = await fs.readFileSync(tmpNameSync, 'utf-8');
|
expect(fs.readFileSync(tmpNameSync, 'utf-8')).toEqual(exValue);
|
||||||
console.log(`secretValue: ${secretValue}`);
|
|
||||||
expect(secretValue).toEqual(exValue);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line jest/no-conditional-expect
|
||||||
expect(true).toBe(invalid);
|
expect(true).toBe(invalid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
|
import * as buildx from '../src/buildx';
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context';
|
||||||
|
|
||||||
const pgp = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
const pgp = `-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||||
@ -127,6 +128,8 @@ jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
|
|||||||
return path.join('/tmp/.docker-build-push-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
return path.join('/tmp/.docker-build-push-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jest.spyOn(buildx, 'satisfiesBuildKitVersion').mockResolvedValueOnce(true);
|
||||||
|
|
||||||
describe('getArgs', () => {
|
describe('getArgs', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env = Object.keys(process.env).reduce((object, key) => {
|
process.env = Object.keys(process.env).reduce((object, key) => {
|
||||||
@ -140,58 +143,64 @@ describe('getArgs', () => {
|
|||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
|
0,
|
||||||
'0.4.1',
|
'0.4.1',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', '.'],
|
['context', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
'.'
|
'.'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
1,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['build-args', 'MY_ARG=val1,val2,val3\nARG=val'],
|
['build-args', `MY_ARG=val1,val2,val3
|
||||||
|
ARG=val
|
||||||
|
"MULTILINE=aaaa
|
||||||
|
bbbb
|
||||||
|
ccc"`],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--build-arg', 'MY_ARG=val1,val2,val3',
|
'--build-arg', 'MY_ARG=val1,val2,val3',
|
||||||
'--build-arg', 'ARG=val',
|
'--build-arg', 'ARG=val',
|
||||||
|
'--build-arg', `MULTILINE=aaaa\nbbbb\nccc`,
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
2,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['tags', 'name/app:7.4, name/app:latest'],
|
['tags', 'name/app:7.4, name/app:latest'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
'--tag', 'name/app:7.4',
|
'--tag', 'name/app:7.4',
|
||||||
'--tag', 'name/app:latest',
|
'--tag', 'name/app:latest',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
||||||
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
3,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', '.'],
|
['context', '.'],
|
||||||
@ -200,10 +209,9 @@ describe('getArgs', () => {
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--label', 'org.opencontainers.image.title=buildkit',
|
'--label', 'org.opencontainers.image.title=buildkit',
|
||||||
'--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit',
|
'--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit',
|
||||||
@ -212,6 +220,7 @@ describe('getArgs', () => {
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
4,
|
||||||
'0.4.1',
|
'0.4.1',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', '.'],
|
['context', '.'],
|
||||||
@ -219,32 +228,32 @@ describe('getArgs', () => {
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--platform', 'linux/amd64,linux/arm64',
|
'--platform', 'linux/amd64,linux/arm64',
|
||||||
'.'
|
'.'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
5,
|
||||||
'0.4.1',
|
'0.4.1',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', '.'],
|
['context', '.'],
|
||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
'.'
|
'.'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
6,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', '.'],
|
['context', '.'],
|
||||||
@ -252,10 +261,9 @@ describe('getArgs', () => {
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
@ -263,6 +271,7 @@ describe('getArgs', () => {
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
7,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['github-token', 'abcdefghijklmno0123456789'],
|
['github-token', 'abcdefghijklmno0123456789'],
|
||||||
@ -270,10 +279,9 @@ describe('getArgs', () => {
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--output', '.',
|
'--output', '.',
|
||||||
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
@ -281,6 +289,7 @@ describe('getArgs', () => {
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
8,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||||
@ -292,21 +301,21 @@ describe('getArgs', () => {
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'true'],
|
['push', 'true'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--platform', 'linux/amd64,linux/arm64',
|
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
|
||||||
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
|
||||||
'--file', './test/Dockerfile',
|
'--file', './test/Dockerfile',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--platform', 'linux/amd64,linux/arm64',
|
||||||
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--builder', 'builder-git-context-2',
|
'--builder', 'builder-git-context-2',
|
||||||
'--push',
|
'--push',
|
||||||
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
9,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||||
@ -326,24 +335,24 @@ ccc"`],
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'true'],
|
['push', 'true'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--platform', 'linux/amd64,linux/arm64',
|
'--file', './test/Dockerfile',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--platform', 'linux/amd64,linux/arm64',
|
||||||
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--file', './test/Dockerfile',
|
|
||||||
'--builder', 'builder-git-context-2',
|
'--builder', 'builder-git-context-2',
|
||||||
'--push',
|
'--push',
|
||||||
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
10,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||||
@ -363,24 +372,24 @@ ccc`],
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'true'],
|
['push', 'true'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--platform', 'linux/amd64,linux/arm64',
|
'--file', './test/Dockerfile',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--platform', 'linux/amd64,linux/arm64',
|
||||||
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=MYSECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=FOO,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=EMPTYLINE,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--file', './test/Dockerfile',
|
|
||||||
'--builder', 'builder-git-context-2',
|
'--builder', 'builder-git-context-2',
|
||||||
'--push',
|
'--push',
|
||||||
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
'https://github.com/docker/build-push-action.git#refs/heads/master'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
11,
|
||||||
'0.5.1',
|
'0.5.1',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
['context', 'https://github.com/docker/build-push-action.git#refs/heads/master'],
|
||||||
@ -392,14 +401,13 @@ ccc`],
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'true'],
|
['push', 'true'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
|
'--file', './test/Dockerfile',
|
||||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
'--secret', 'id=MY_SECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
'--secret', 'id=MY_SECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
'--file', './test/Dockerfile',
|
|
||||||
'--builder', 'builder-git-context-2',
|
'--builder', 'builder-git-context-2',
|
||||||
'--network', 'host',
|
'--network', 'host',
|
||||||
'--push',
|
'--push',
|
||||||
@ -407,6 +415,7 @@ ccc`],
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
12,
|
||||||
'0.4.2',
|
'0.4.2',
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['context', '.'],
|
['context', '.'],
|
||||||
@ -415,28 +424,266 @@ ccc`],
|
|||||||
['load', 'false'],
|
['load', 'false'],
|
||||||
['no-cache', 'false'],
|
['no-cache', 'false'],
|
||||||
['push', 'false'],
|
['push', 'false'],
|
||||||
['pull', 'false']
|
['pull', 'false'],
|
||||||
]),
|
]),
|
||||||
[
|
[
|
||||||
'buildx',
|
|
||||||
'build',
|
'build',
|
||||||
'--label', 'org.opencontainers.image.title=filter_results_top_n',
|
'--label', 'org.opencontainers.image.title=filter_results_top_n',
|
||||||
'--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"',
|
'--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"',
|
||||||
'--output', 'type=local,dest=./release-out',
|
'--output', 'type=local,dest=./release-out',
|
||||||
'.'
|
'.'
|
||||||
]
|
]
|
||||||
]
|
],
|
||||||
|
[
|
||||||
|
13,
|
||||||
|
'0.6.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['tag', 'localhost:5000/name/app:latest'],
|
||||||
|
['file', './test/Dockerfile'],
|
||||||
|
['add-hosts', 'docker:10.180.0.1,foo:10.0.0.1'],
|
||||||
|
['network', 'host'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'true'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--add-host', 'docker:10.180.0.1',
|
||||||
|
'--add-host', 'foo:10.0.0.1',
|
||||||
|
'--file', './test/Dockerfile',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'--network', 'host',
|
||||||
|
'--push',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
14,
|
||||||
|
'0.7.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['file', './test/Dockerfile'],
|
||||||
|
['add-hosts', 'docker:10.180.0.1\nfoo:10.0.0.1'],
|
||||||
|
['cgroup-parent', 'foo'],
|
||||||
|
['shm-size', '2g'],
|
||||||
|
['ulimit', `nofile=1024:1024
|
||||||
|
nproc=3`],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--add-host', 'docker:10.180.0.1',
|
||||||
|
'--add-host', 'foo:10.0.0.1',
|
||||||
|
'--cgroup-parent', 'foo',
|
||||||
|
'--file', './test/Dockerfile',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--shm-size', '2g',
|
||||||
|
'--ulimit', 'nofile=1024:1024',
|
||||||
|
'--ulimit', 'nproc=3',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
15,
|
||||||
|
'0.7.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '{{defaultContext}}:docker'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest:docker'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
16,
|
||||||
|
'0.8.2',
|
||||||
|
new Map<string, string>([
|
||||||
|
['github-token', 'abcdefghijklmno0123456789'],
|
||||||
|
['context', '{{defaultContext}}:subdir'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'https://github.com/docker/build-push-action.git#refs/heads/test-jest:subdir'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
17,
|
||||||
|
'0.8.2',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['provenance', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
18,
|
||||||
|
'0.10.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
"--provenance", 'false',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
19,
|
||||||
|
'0.10.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['provenance', 'true'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
"--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
20,
|
||||||
|
'0.10.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['provenance', 'mode=max'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
"--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
21,
|
||||||
|
'0.10.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['provenance', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
"--provenance", 'false',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
22,
|
||||||
|
'0.10.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['provenance', 'builder-id=foo'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
"--provenance", 'builder-id=foo',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
23,
|
||||||
|
'0.10.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
['outputs', 'type=docker'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
"--output", 'type=docker',
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
24,
|
||||||
|
'0.10.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['context', '.'],
|
||||||
|
['load', 'true'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||||
|
"--load",
|
||||||
|
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
|
||||||
|
'.'
|
||||||
|
]
|
||||||
|
],
|
||||||
])(
|
])(
|
||||||
'given %p with %p as inputs, returns %p',
|
'[%d] given %p with %p as inputs, returns %p',
|
||||||
async (buildxVersion: string, inputs: Map<string, any>, expected: Array<string>) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
|
||||||
await inputs.forEach((value: string, name: string) => {
|
inputs.forEach((value: string, name: string) => {
|
||||||
setInput(name, value);
|
setInput(name, value);
|
||||||
});
|
});
|
||||||
const defContext = context.defaultContext();
|
const defContext = context.defaultContext();
|
||||||
const inp = await context.getInputs(defContext);
|
const inp = await context.getInputs(defContext);
|
||||||
console.log(inp);
|
|
||||||
const res = await context.getArgs(inp, defContext, buildxVersion);
|
const res = await context.getArgs(inp, defContext, buildxVersion);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(expected);
|
expect(res).toEqual(expected);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -446,63 +693,54 @@ describe('getInputList', () => {
|
|||||||
it('single line correctly', async () => {
|
it('single line correctly', async () => {
|
||||||
await setInput('foo', 'bar');
|
await setInput('foo', 'bar');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['bar']);
|
expect(res).toEqual(['bar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('multiline correctly', async () => {
|
it('multiline correctly', async () => {
|
||||||
setInput('foo', 'bar\nbaz');
|
setInput('foo', 'bar\nbaz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('empty lines correctly', async () => {
|
it('empty lines correctly', async () => {
|
||||||
setInput('foo', 'bar\n\nbaz');
|
setInput('foo', 'bar\n\nbaz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('comma correctly', async () => {
|
it('comma correctly', async () => {
|
||||||
setInput('foo', 'bar,baz');
|
setInput('foo', 'bar,baz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('empty result correctly', async () => {
|
it('empty result correctly', async () => {
|
||||||
setInput('foo', 'bar,baz,');
|
setInput('foo', 'bar,baz,');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('different new lines correctly', async () => {
|
it('different new lines correctly', async () => {
|
||||||
setInput('foo', 'bar\r\nbaz');
|
setInput('foo', 'bar\r\nbaz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('different new lines and comma correctly', async () => {
|
it('different new lines and comma correctly', async () => {
|
||||||
setInput('foo', 'bar\r\nbaz,bat');
|
setInput('foo', 'bar\r\nbaz,bat');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['bar', 'baz', 'bat']);
|
expect(res).toEqual(['bar', 'baz', 'bat']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('multiline and ignoring comma correctly', async () => {
|
it('multiline and ignoring comma correctly', async () => {
|
||||||
setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir');
|
setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir');
|
||||||
const res = await context.getInputList('cache-from', true);
|
const res = await context.getInputList('cache-from', true);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('different new lines and ignoring comma correctly', async () => {
|
it('different new lines and ignoring comma correctly', async () => {
|
||||||
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
|
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
|
||||||
const res = await context.getInputList('cache-from', true);
|
const res = await context.getInputList('cache-from', true);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -516,7 +754,6 @@ ccccccccc"
|
|||||||
FOO=bar`
|
FOO=bar`
|
||||||
);
|
);
|
||||||
const res = await context.getInputList('secrets', true);
|
const res = await context.getInputList('secrets', true);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual([
|
expect(res).toEqual([
|
||||||
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||||
`MYSECRET=aaaaaaaa
|
`MYSECRET=aaaaaaaa
|
||||||
@ -540,7 +777,6 @@ bbbb
|
|||||||
ccc"`
|
ccc"`
|
||||||
);
|
);
|
||||||
const res = await context.getInputList('secrets', true);
|
const res = await context.getInputList('secrets', true);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual([
|
expect(res).toEqual([
|
||||||
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||||
`MYSECRET=aaaaaaaa
|
`MYSECRET=aaaaaaaa
|
||||||
@ -564,7 +800,6 @@ ccccccccc
|
|||||||
FOO=bar`
|
FOO=bar`
|
||||||
);
|
);
|
||||||
const res = await context.getInputList('secrets', true);
|
const res = await context.getInputList('secrets', true);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
|
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -575,7 +810,6 @@ FOO=bar`
|
|||||||
FOO=bar`
|
FOO=bar`
|
||||||
);
|
);
|
||||||
const res = await context.getInputList('secrets', true);
|
const res = await context.getInputList('secrets', true);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual([`GPG_KEY=${pgp}`, 'FOO=bar']);
|
expect(res).toEqual([`GPG_KEY=${pgp}`, 'FOO=bar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -589,11 +823,10 @@ ccccccccc"
|
|||||||
FOO=bar`
|
FOO=bar`
|
||||||
);
|
);
|
||||||
const res = await context.getInputList('secrets', true);
|
const res = await context.getInputList('secrets', true);
|
||||||
console.log(res);
|
|
||||||
expect(res).toEqual([
|
expect(res).toEqual([
|
||||||
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||||
`MYSECRET=aaaaaaaa
|
`MYSECRET=aaaaaaaa
|
||||||
bbbb\"bbb
|
bbbb"bbb
|
||||||
ccccccccc`,
|
ccccccccc`,
|
||||||
'FOO=bar'
|
'FOO=bar'
|
||||||
]);
|
]);
|
||||||
@ -613,27 +846,6 @@ describe('asyncForEach', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('setOutput', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
process.stdout.write = jest.fn();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('setOutput produces the correct command', () => {
|
|
||||||
context.setOutput('some output', 'some value');
|
|
||||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('setOutput handles bools', () => {
|
|
||||||
context.setOutput('some output', false);
|
|
||||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('setOutput handles numbers', () => {
|
|
||||||
context.setOutput('some output', 1.01);
|
|
||||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
|
||||||
function getInputName(name: string): string {
|
function getInputName(name: string): string {
|
||||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
@ -642,11 +854,3 @@ function getInputName(name: string): string {
|
|||||||
function setInput(name: string, value: string): void {
|
function setInput(name: string, value: string): void {
|
||||||
process.env[getInputName(name)] = value;
|
process.env[getInputName(name)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that process.stdout.write calls called only with the given arguments.
|
|
||||||
function assertWriteCalls(calls: string[]): void {
|
|
||||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
|
||||||
for (let i = 0; i < calls.length; i++) {
|
|
||||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
16
__tests__/docker.test.ts
Normal file
16
__tests__/docker.test.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import {describe, expect, it, jest} from '@jest/globals';
|
||||||
|
import * as docker from '../src/docker';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
|
describe('isAvailable', () => {
|
||||||
|
it('cli', () => {
|
||||||
|
const execSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
docker.isAvailable();
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/no-standalone-expect
|
||||||
|
expect(execSpy).toHaveBeenCalledWith(`docker`, undefined, {
|
||||||
|
silent: true,
|
||||||
|
ignoreReturnCode: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
47
action.yml
47
action.yml
@ -7,20 +7,32 @@ branding:
|
|||||||
color: 'blue'
|
color: 'blue'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
|
add-hosts:
|
||||||
|
description: "List of a customs host-to-IP mapping (e.g., docker:10.180.0.1)"
|
||||||
|
required: false
|
||||||
allow:
|
allow:
|
||||||
description: "List of extra privileged entitlement (eg. network.host,security.insecure)"
|
description: "List of extra privileged entitlement (e.g., network.host,security.insecure)"
|
||||||
|
required: false
|
||||||
|
attests:
|
||||||
|
description: "List of attestation parameters (e.g., type=sbom,generator=image)"
|
||||||
required: false
|
required: false
|
||||||
build-args:
|
build-args:
|
||||||
description: "List of build-time variables"
|
description: "List of build-time variables"
|
||||||
required: false
|
required: false
|
||||||
|
build-contexts:
|
||||||
|
description: "List of additional build contexts (e.g., name=path)"
|
||||||
|
required: false
|
||||||
builder:
|
builder:
|
||||||
description: "Builder instance"
|
description: "Builder instance"
|
||||||
required: false
|
required: false
|
||||||
cache-from:
|
cache-from:
|
||||||
description: "List of external cache sources for buildx (eg. user/app:cache, type=local,src=path/to/dir)"
|
description: "List of external cache sources for buildx (e.g., user/app:cache, type=local,src=path/to/dir)"
|
||||||
required: false
|
required: false
|
||||||
cache-to:
|
cache-to:
|
||||||
description: "List of cache export destinations for buildx (eg. user/app:cache, type=local,dest=path/to/dir)"
|
description: "List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir)"
|
||||||
|
required: false
|
||||||
|
cgroup-parent:
|
||||||
|
description: "Optional parent cgroup for the container used in the build"
|
||||||
required: false
|
required: false
|
||||||
context:
|
context:
|
||||||
description: "Build's context is the set of files located in the specified PATH or URL"
|
description: "Build's context is the set of files located in the specified PATH or URL"
|
||||||
@ -42,25 +54,37 @@ inputs:
|
|||||||
description: "Do not use cache when building the image"
|
description: "Do not use cache when building the image"
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
no-cache-filters:
|
||||||
|
description: "Do not cache specified stages"
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
description: "List of output destinations (format: type=local,dest=path)"
|
description: "List of output destinations (format: type=local,dest=path)"
|
||||||
required: false
|
required: false
|
||||||
platforms:
|
platforms:
|
||||||
description: "List of target platforms for build"
|
description: "List of target platforms for build"
|
||||||
required: false
|
required: false
|
||||||
|
provenance:
|
||||||
|
description: "Generate provenance attestation for the build (shorthand for --attest=type=provenance)"
|
||||||
|
required: false
|
||||||
pull:
|
pull:
|
||||||
description: "Always attempt to pull a newer version of the image"
|
description: "Always attempt to pull all referenced images"
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
push:
|
push:
|
||||||
description: "Push is a shorthand for --output=type=registry"
|
description: "Push is a shorthand for --output=type=registry"
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
sbom:
|
||||||
|
description: "Generate SBOM attestation for the build (shorthand for --attest=type=sbom)"
|
||||||
|
required: false
|
||||||
secrets:
|
secrets:
|
||||||
description: "List of secrets to expose to the build (eg. key=string, GIT_AUTH_TOKEN=mytoken)"
|
description: "List of secrets to expose to the build (e.g., key=string, GIT_AUTH_TOKEN=mytoken)"
|
||||||
required: false
|
required: false
|
||||||
secret-files:
|
secret-files:
|
||||||
description: "List of secret files to expose to the build (eg. key=filename, MY_SECRET=./secret.txt)"
|
description: "List of secret files to expose to the build (e.g., key=filename, MY_SECRET=./secret.txt)"
|
||||||
|
required: false
|
||||||
|
shm-size:
|
||||||
|
description: "Size of /dev/shm (e.g., 2g)"
|
||||||
required: false
|
required: false
|
||||||
ssh:
|
ssh:
|
||||||
description: "List of SSH agent socket or keys to expose to the build"
|
description: "List of SSH agent socket or keys to expose to the build"
|
||||||
@ -71,16 +95,23 @@ inputs:
|
|||||||
target:
|
target:
|
||||||
description: "Sets the target stage to build"
|
description: "Sets the target stage to build"
|
||||||
required: false
|
required: false
|
||||||
|
ulimit:
|
||||||
|
description: "Ulimit options (e.g., nofile=1024:1024)"
|
||||||
|
required: false
|
||||||
github-token:
|
github-token:
|
||||||
description: "GitHub Token used to authenticate against a repository for Git context"
|
description: "GitHub Token used to authenticate against a repository for Git context"
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
|
imageid:
|
||||||
|
description: 'Image ID'
|
||||||
digest:
|
digest:
|
||||||
description: 'Image content-addressable identifier also called a digest'
|
description: 'Image digest'
|
||||||
|
metadata:
|
||||||
|
description: 'Build result metadata'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
post: 'dist/index.js'
|
post: 'dist/index.js'
|
||||||
|
76
dev.Dockerfile
Normal file
76
dev.Dockerfile
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
ARG NODE_VERSION=16
|
||||||
|
ARG DOCKER_VERSION=20.10.13
|
||||||
|
ARG BUILDX_VERSION=0.8.0
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache cpio findutils git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base AS deps
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn install && mkdir /vendor && cp yarn.lock /vendor
|
||||||
|
|
||||||
|
FROM scratch AS vendor-update
|
||||||
|
COPY --from=deps /vendor /
|
||||||
|
|
||||||
|
FROM deps AS vendor-validate
|
||||||
|
RUN --mount=type=bind,target=.,rw <<EOT
|
||||||
|
set -e
|
||||||
|
git add -A
|
||||||
|
cp -rf /vendor/* .
|
||||||
|
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then
|
||||||
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'
|
||||||
|
git status --porcelain -- yarn.lock
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
EOT
|
||||||
|
|
||||||
|
FROM deps AS build
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run build && mkdir /out && cp -Rf dist /out/
|
||||||
|
|
||||||
|
FROM scratch AS build-update
|
||||||
|
COPY --from=build /out /
|
||||||
|
|
||||||
|
FROM build AS build-validate
|
||||||
|
RUN --mount=type=bind,target=.,rw <<EOT
|
||||||
|
set -e
|
||||||
|
git add -A
|
||||||
|
cp -rf /out/* .
|
||||||
|
if [ -n "$(git status --porcelain -- dist)" ]; then
|
||||||
|
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
|
||||||
|
git status --porcelain -- dist
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
EOT
|
||||||
|
|
||||||
|
FROM deps AS format
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run format \
|
||||||
|
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
|
||||||
|
|
||||||
|
FROM scratch AS format-update
|
||||||
|
COPY --from=format /out /
|
||||||
|
|
||||||
|
FROM deps AS lint
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run lint
|
||||||
|
|
||||||
|
FROM docker:${DOCKER_VERSION} as docker
|
||||||
|
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx
|
||||||
|
|
||||||
|
FROM deps AS test
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
--mount=type=bind,from=docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
|
||||||
|
--mount=type=bind,from=buildx,source=/buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
|
||||||
|
yarn run test --coverageDirectory=/tmp/coverage
|
||||||
|
|
||||||
|
FROM scratch AS test-coverage
|
||||||
|
COPY --from=test /tmp/coverage /
|
17040
dist/index.js
generated
vendored
17040
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/index.js.map
generated
vendored
Normal file
1
dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1083
dist/licenses.txt
generated
vendored
Normal file
1083
dist/licenses.txt
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
dist/sourcemap-register.js
generated
vendored
Normal file
1
dist/sourcemap-register.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,13 +1,3 @@
|
|||||||
variable "NODE_VERSION" {
|
|
||||||
default = "12"
|
|
||||||
}
|
|
||||||
|
|
||||||
target "node-version" {
|
|
||||||
args = {
|
|
||||||
NODE_VERSION = NODE_VERSION
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
group "default" {
|
group "default" {
|
||||||
targets = ["build"]
|
targets = ["build"]
|
||||||
}
|
}
|
||||||
@ -17,51 +7,47 @@ group "pre-checkin" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group "validate" {
|
group "validate" {
|
||||||
targets = ["format-validate", "build-validate", "vendor-validate"]
|
targets = ["lint", "build-validate", "vendor-validate"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "build" {
|
target "build" {
|
||||||
inherits = ["node-version"]
|
dockerfile = "dev.Dockerfile"
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
|
||||||
target = "build-update"
|
target = "build-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "build-validate" {
|
target "build-validate" {
|
||||||
inherits = ["node-version"]
|
dockerfile = "dev.Dockerfile"
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
|
||||||
target = "build-validate"
|
target = "build-validate"
|
||||||
|
output = ["type=cacheonly"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "format" {
|
target "format" {
|
||||||
inherits = ["node-version"]
|
dockerfile = "dev.Dockerfile"
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
|
||||||
target = "format-update"
|
target = "format-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "format-validate" {
|
target "lint" {
|
||||||
inherits = ["node-version"]
|
dockerfile = "dev.Dockerfile"
|
||||||
dockerfile = "./hack/build.Dockerfile"
|
target = "lint"
|
||||||
target = "format-validate"
|
output = ["type=cacheonly"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "vendor-update" {
|
target "vendor-update" {
|
||||||
inherits = ["node-version"]
|
dockerfile = "dev.Dockerfile"
|
||||||
dockerfile = "./hack/vendor.Dockerfile"
|
target = "vendor-update"
|
||||||
target = "update"
|
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "vendor-validate" {
|
target "vendor-validate" {
|
||||||
inherits = ["node-version"]
|
dockerfile = "dev.Dockerfile"
|
||||||
dockerfile = "./hack/vendor.Dockerfile"
|
target = "vendor-validate"
|
||||||
target = "validate"
|
output = ["type=cacheonly"]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "test" {
|
target "test" {
|
||||||
inherits = ["node-version"]
|
dockerfile = "dev.Dockerfile"
|
||||||
dockerfile = "./hack/test.Dockerfile"
|
|
||||||
target = "test-coverage"
|
target = "test-coverage"
|
||||||
output = ["./coverage"]
|
output = ["./coverage"]
|
||||||
}
|
}
|
||||||
|
@ -1,107 +1,3 @@
|
|||||||
# Cache
|
# Cache
|
||||||
|
|
||||||
* [Registry cache](#registry-cache)
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#cache)
|
||||||
* [GitHub cache](#github-cache)
|
|
||||||
|
|
||||||
> More info about buildx cache: https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-from
|
|
||||||
|
|
||||||
## Registry cache
|
|
||||||
|
|
||||||
You can import/export cache from a cache manifest or (special) image configuration on the registry.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: user/app:latest
|
|
||||||
cache-from: type=registry,ref=user/app:latest
|
|
||||||
cache-to: type=inline
|
|
||||||
```
|
|
||||||
|
|
||||||
## GitHub cache
|
|
||||||
|
|
||||||
> :warning: At the moment caches are copied over the existing cache so it [keeps growing](https://github.com/docker/build-push-action/issues/252).
|
|
||||||
> The `Move cache` step is used as a temporary fix (see https://github.com/moby/buildkit/issues/1896).
|
|
||||||
|
|
||||||
> :rocket: There is a new cache backend using GitHub cache being developed that will lighten your workflow.
|
|
||||||
> More info: https://github.com/docker/buildx/pull/535
|
|
||||||
|
|
||||||
You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)
|
|
||||||
using [actions/cache](https://github.com/actions/cache) with this action:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Cache Docker layers
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: /tmp/.buildx-cache
|
|
||||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-buildx-
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: user/app:latest
|
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
|
||||||
-
|
|
||||||
# Temp fix
|
|
||||||
# https://github.com/docker/build-push-action/issues/252
|
|
||||||
# https://github.com/moby/buildkit/issues/1896
|
|
||||||
name: Move cache
|
|
||||||
run: |
|
|
||||||
rm -rf /tmp/.buildx-cache
|
|
||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
|
||||||
```
|
|
||||||
|
@ -1,73 +1,3 @@
|
|||||||
# Copy images between registries
|
# Copy images between registries
|
||||||
|
|
||||||
Multi-platform images built using buildx can be copied from one registry to another without
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#copy-images-between-registries)
|
||||||
changing the image SHA using the [tag-push-action](https://github.com/akhilerm/tag-push-action).
|
|
||||||
|
|
||||||
The following workflow will first push the image to dockerhub, run some tests using the images
|
|
||||||
and then push to quay and ghcr
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
- # quay and ghcr logins for pushing image after testing
|
|
||||||
name: Login to Quay Registry
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: quay.io
|
|
||||||
username: ${{ secrets.QUAY_USERNAME }}
|
|
||||||
password: ${{ secrets.QUAY_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
user/app:latest
|
|
||||||
user/app:1.0.0
|
|
||||||
- # run tests using image from docker hub
|
|
||||||
name: Run Tests
|
|
||||||
run: make tests
|
|
||||||
- # copy multiplatform image from dockerhub to quay and ghcr
|
|
||||||
name: Push Image to multiple registries
|
|
||||||
uses: akhilerm/tag-push-action@v1.0.0
|
|
||||||
with:
|
|
||||||
src: docker.io/user/app:1.0.0
|
|
||||||
dst: |
|
|
||||||
quay.io/user/app:latest
|
|
||||||
quay.io/user/app:1.0.0
|
|
||||||
ghcr.io/user/app:latest
|
|
||||||
ghcr.io/user/app:1.0.0
|
|
||||||
```
|
|
||||||
|
@ -1,48 +1,3 @@
|
|||||||
# Update DockerHub repo description
|
# Update Docker Hub repo description
|
||||||
|
|
||||||
You can update the [DockerHub repository description](https://docs.docker.com/docker-hub/repos/) using
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#update-docker-hub-repository-description)
|
||||||
a third party action called [DockerHub Description](https://github.com/peter-evans/dockerhub-description)
|
|
||||||
with this action:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: user/app:latest
|
|
||||||
-
|
|
||||||
name: Update repo description
|
|
||||||
uses: peter-evans/dockerhub-description@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
repository: user/app
|
|
||||||
```
|
|
||||||
|
@ -1,35 +1,3 @@
|
|||||||
# Export image to Docker
|
# Export image to Docker
|
||||||
|
|
||||||
You may want your build result to be available in the Docker client through `docker images` to be able to use it
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#export-image-to-docker)
|
||||||
in another step of your workflow:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
load: true
|
|
||||||
tags: myimage:latest
|
|
||||||
-
|
|
||||||
name: Inspect
|
|
||||||
run: |
|
|
||||||
docker image inspect myimage:latest
|
|
||||||
```
|
|
||||||
|
@ -1,44 +1,3 @@
|
|||||||
# Isolated builders
|
# Isolated builders
|
||||||
|
|
||||||
```yaml
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/configure-builder/#isolated-builders)
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
id: builder1
|
|
||||||
-
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
id: builder2
|
|
||||||
-
|
|
||||||
name: Builder 1 name
|
|
||||||
run: echo ${{ steps.builder1.outputs.name }}
|
|
||||||
-
|
|
||||||
name: Builder 2 name
|
|
||||||
run: echo ${{ steps.builder2.outputs.name }}
|
|
||||||
-
|
|
||||||
name: Build against builder1
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
builder: ${{ steps.builder1.outputs.name }}
|
|
||||||
context: .
|
|
||||||
target: mytarget1
|
|
||||||
-
|
|
||||||
name: Build against builder2
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
builder: ${{ steps.builder2.outputs.name }}
|
|
||||||
context: .
|
|
||||||
target: mytarget2
|
|
||||||
```
|
|
||||||
|
@ -1,44 +1,3 @@
|
|||||||
# Local registry
|
# Local registry
|
||||||
|
|
||||||
For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into:
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#local-registry)
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
services:
|
|
||||||
registry:
|
|
||||||
image: registry:2
|
|
||||||
ports:
|
|
||||||
- 5000:5000
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
with:
|
|
||||||
driver-opts: network=host
|
|
||||||
-
|
|
||||||
name: Build and push to local registry
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: localhost:5000/name/app:latest
|
|
||||||
-
|
|
||||||
name: Inspect
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools inspect localhost:5000/name/app:latest
|
|
||||||
```
|
|
||||||
|
@ -1,44 +1,3 @@
|
|||||||
# Multi-platform image
|
# Multi-platform image
|
||||||
|
|
||||||
You can build multi-platform images using the [`platforms` input](../../README.md#inputs) as described below.
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#multi-platform-images)
|
||||||
|
|
||||||
> :bulb: List of available platforms will be displayed and available through our [setup-buildx](https://github.com/docker/setup-buildx-action#about) action.
|
|
||||||
|
|
||||||
> :bulb: If you want support for more platforms, you can use QEMU with our [setup-qemu](https://github.com/docker/setup-qemu-action) action.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: user/app:latest
|
|
||||||
```
|
|
||||||
|
3
docs/advanced/named-contexts.md
Normal file
3
docs/advanced/named-contexts.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Named contexts
|
||||||
|
|
||||||
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#named-contexts)
|
@ -1,57 +1,3 @@
|
|||||||
# Push to multi-registries
|
# Push to multi-registries
|
||||||
|
|
||||||
* [Docker Hub and GHCR](#docker-hub-and-ghcr)
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#push-to-multi-registries)
|
||||||
|
|
||||||
## Docker Hub and GHCR
|
|
||||||
|
|
||||||
The following workflow will connect you to [DockerHub](https://github.com/docker/login-action#dockerhub)
|
|
||||||
and [GitHub Container Registry](https://github.com/docker/login-action#github-container-registry) and push the
|
|
||||||
image to these registries.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
user/app:latest
|
|
||||||
user/app:1.0.0
|
|
||||||
ghcr.io/user/app:latest
|
|
||||||
ghcr.io/user/app:1.0.0
|
|
||||||
```
|
|
||||||
|
@ -1,84 +1,3 @@
|
|||||||
# Secrets
|
# Secrets
|
||||||
|
|
||||||
In the following example we will expose and use the [GITHUB_TOKEN secret](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret)
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#secrets)
|
||||||
as provided by GitHub in your workflow.
|
|
||||||
|
|
||||||
First let's create our `Dockerfile` to use our secret:
|
|
||||||
|
|
||||||
```Dockerfile
|
|
||||||
#syntax=docker/dockerfile:1.2
|
|
||||||
|
|
||||||
FROM alpine
|
|
||||||
RUN --mount=type=secret,id=github_token \
|
|
||||||
cat /run/secrets/github_token
|
|
||||||
```
|
|
||||||
|
|
||||||
As you can see we have named our secret `github_token`. Here is the workflow you can use to expose this secret using
|
|
||||||
the [`secrets` input](../../README.md#inputs):
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Build
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
tags: user/app:latest
|
|
||||||
secrets: |
|
|
||||||
"github_token=${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
```
|
|
||||||
|
|
||||||
> :bulb: You can also expose a secret file to the build with [`secret-files`](../../README.md#inputs) input:
|
|
||||||
> ```yaml
|
|
||||||
> secret-files: |
|
|
||||||
> "MY_SECRET=./secret.txt"
|
|
||||||
> ```
|
|
||||||
|
|
||||||
If you're using [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) and need to handle
|
|
||||||
multi-line value, you will need to place the key-value pair between quotes:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
secrets: |
|
|
||||||
"MYSECRET=${{ secrets.GPG_KEY }}"
|
|
||||||
GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789
|
|
||||||
"MYSECRET=aaaaaaaa
|
|
||||||
bbbbbbb
|
|
||||||
ccccccccc"
|
|
||||||
FOO=bar
|
|
||||||
"EMPTYLINE=aaaa
|
|
||||||
|
|
||||||
bbbb
|
|
||||||
ccc"
|
|
||||||
"JSON_SECRET={""key1"":""value1"",""key2"":""value2""}"
|
|
||||||
```
|
|
||||||
|
|
||||||
| Key | Value |
|
|
||||||
|--------------------|--------------------------------------------------|
|
|
||||||
| `MYSECRET` | `***********************` |
|
|
||||||
| `GIT_AUTH_TOKEN` | `abcdefghi,jklmno=0123456789` |
|
|
||||||
| `MYSECRET` | `aaaaaaaa\nbbbbbbb\nccccccccc` |
|
|
||||||
| `FOO` | `bar` |
|
|
||||||
| `EMPTYLINE` | `aaaa\n\nbbbb\nccc` |
|
|
||||||
| `JSON_SECRET` | `{"key1":"value1","key2":"value2"}` |
|
|
||||||
|
|
||||||
> :bulb: All quote signs need to be doubled for escaping.
|
|
||||||
|
@ -1,58 +1,3 @@
|
|||||||
# Share built image between jobs
|
# Share built image between jobs
|
||||||
|
|
||||||
As each job is isolated in its own runner you cannot use your built image between jobs (except for [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners)).
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#share-built-image-between-jobs)
|
||||||
However, you can [pass data between jobs in a workflow](https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts#passing-data-between-jobs-in-a-workflow)
|
|
||||||
using the [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact)
|
|
||||||
actions:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Build and export
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
tags: myimage:latest
|
|
||||||
outputs: type=docker,dest=/tmp/myimage.tar
|
|
||||||
-
|
|
||||||
name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: myimage
|
|
||||||
path: /tmp/myimage.tar
|
|
||||||
|
|
||||||
use:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Download artifact
|
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: myimage
|
|
||||||
path: /tmp
|
|
||||||
-
|
|
||||||
name: Load image
|
|
||||||
run: |
|
|
||||||
docker load --input /tmp/myimage.tar
|
|
||||||
docker image ls -a
|
|
||||||
```
|
|
||||||
|
@ -1,77 +1,3 @@
|
|||||||
# Handle tags and labels
|
# Handle tags and labels
|
||||||
|
|
||||||
If you come from [`v1`](https://github.com/docker/build-push-action/tree/releases/v1#readme) and want an
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#manage-tags-and-labels)
|
||||||
"automatic" tag management and [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
|
|
||||||
for labels, you can do it in a dedicated step. The following workflow will use the [Docker metadata action](https://github.com/docker/metadata-action)
|
|
||||||
to handle tags and labels based on GitHub actions events and Git metadata.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 10 * * *' # everyday at 10am
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '**'
|
|
||||||
tags:
|
|
||||||
- 'v*.*.*'
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v3
|
|
||||||
with:
|
|
||||||
# list of Docker images to use as base name for tags
|
|
||||||
images: |
|
|
||||||
name/app
|
|
||||||
ghcr.io/username/app
|
|
||||||
# generate Docker tags based on the following events/attributes
|
|
||||||
tags: |
|
|
||||||
type=schedule
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=sha
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Login to GHCR
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
```
|
|
||||||
|
3
docs/advanced/test-before-push.md
Normal file
3
docs/advanced/test-before-push.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Test your image before pushing it
|
||||||
|
|
||||||
|
This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/examples/#test-your-image-before-pushing-it)
|
@ -1,42 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.2
|
|
||||||
ARG NODE_VERSION
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
|
||||||
RUN apk add --no-cache cpio findutils git
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
FROM base AS deps
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
FROM deps AS build
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn run build && mkdir /out && cp -Rf dist /out/
|
|
||||||
|
|
||||||
FROM scratch AS build-update
|
|
||||||
COPY --from=build /out /
|
|
||||||
|
|
||||||
FROM build AS build-validate
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
git add -A && cp -rf /out/* .; \
|
|
||||||
if [ -n "$(git status --porcelain -- dist)" ]; then \
|
|
||||||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \
|
|
||||||
git status --porcelain -- dist; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
FROM deps AS format
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn run format \
|
|
||||||
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
|
|
||||||
|
|
||||||
FROM scratch AS format-update
|
|
||||||
COPY --from=format /out /
|
|
||||||
|
|
||||||
FROM deps AS format-validate
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn run format-check \
|
|
@ -1,23 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.2
|
|
||||||
ARG NODE_VERSION
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
|
||||||
RUN apk add --no-cache git
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
FROM base AS deps
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
FROM deps AS test
|
|
||||||
ENV RUNNER_TEMP=/tmp/github_runner
|
|
||||||
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
--mount=type=bind,from=crazymax/docker,source=/usr/libexec/docker/cli-plugins/docker-buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
|
|
||||||
--mount=type=bind,from=crazymax/docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
|
|
||||||
yarn run test --coverageDirectory=/tmp/coverage
|
|
||||||
|
|
||||||
FROM scratch AS test-coverage
|
|
||||||
COPY --from=test /tmp/coverage /
|
|
@ -1,23 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.2
|
|
||||||
ARG NODE_VERSION
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
|
||||||
RUN apk add --no-cache git
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
FROM base AS vendored
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
--mount=type=cache,target=/src/node_modules \
|
|
||||||
yarn install && mkdir /out && cp yarn.lock /out
|
|
||||||
|
|
||||||
FROM scratch AS update
|
|
||||||
COPY --from=vendored /out /
|
|
||||||
|
|
||||||
FROM vendored AS validate
|
|
||||||
RUN --mount=type=bind,target=.,rw \
|
|
||||||
git add -A && cp -rf /out/* .; \
|
|
||||||
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \
|
|
||||||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \
|
|
||||||
git status --porcelain -- yarn.lock; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
@ -1,12 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
clearMocks: false,
|
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
|
||||||
setupFiles: ["dotenv/config"],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
testMatch: ['**/*.test.ts'],
|
|
||||||
testRunner: 'jest-circus/runner',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': 'ts-jest'
|
|
||||||
},
|
|
||||||
verbose: false
|
|
||||||
}
|
|
23
jest.config.ts
Normal file
23
jest.config.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
process.env = Object.assign({}, process.env, {
|
||||||
|
RUNNER_TEMP: '/tmp/github_runner',
|
||||||
|
RUNNER_TOOL_CACHE: '/tmp/github_tool_cache',
|
||||||
|
GITHUB_REPOSITORY: 'docker/build-push-action',
|
||||||
|
GITHUB_RUN_ID: '123456789'
|
||||||
|
}) as {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
clearMocks: false,
|
||||||
|
testEnvironment: 'node',
|
||||||
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
|
setupFiles: ['dotenv/config'],
|
||||||
|
testMatch: ['**/*.test.ts'],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.ts$': 'ts-jest'
|
||||||
|
},
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
||||||
|
},
|
||||||
|
verbose: true
|
||||||
|
};
|
46
package.json
46
package.json
@ -3,11 +3,11 @@
|
|||||||
"description": "Build and push Docker images",
|
"description": "Build and push Docker images",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && ncc build",
|
"build": "ncc build src/main.ts --source-map --minify --license licenses.txt",
|
||||||
"format": "prettier --write **/*.ts",
|
"lint": "eslint src/**/*.ts __tests__/**/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format": "eslint --fix src/**/*.ts __tests__/**/*.ts",
|
||||||
"test": "jest --coverage",
|
"test": "jest --coverage",
|
||||||
"pre-checkin": "yarn run format && yarn run build"
|
"all": "yarn run build && yarn run format && yarn test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -28,26 +28,32 @@
|
|||||||
],
|
],
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.4.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.0.0",
|
"@actions/github": "^5.1.1",
|
||||||
"csv-parse": "^4.16.0",
|
"csv-parse": "^5.3.3",
|
||||||
"semver": "^7.3.5",
|
"handlebars": "^4.7.7",
|
||||||
|
"jwt-decode": "^3.1.2",
|
||||||
|
"semver": "^7.3.7",
|
||||||
"tmp": "^0.2.1"
|
"tmp": "^0.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/csv-parse": "^1.2.2",
|
"@types/csv-parse": "^1.2.2",
|
||||||
"@types/jest": "^26.0.23",
|
"@types/node": "^16.11.26",
|
||||||
"@types/node": "^14.17.4",
|
"@types/semver": "^7.3.9",
|
||||||
"@types/tmp": "^0.2.0",
|
"@types/tmp": "^0.2.3",
|
||||||
"@vercel/ncc": "^0.28.6",
|
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
||||||
"dotenv": "^8.6.0",
|
"@typescript-eslint/parser": "^5.14.0",
|
||||||
"jest": "^26.6.3",
|
"@vercel/ncc": "^0.33.3",
|
||||||
"jest-circus": "^26.6.3",
|
"dotenv": "^16.0.0",
|
||||||
"jest-runtime": "^26.6.3",
|
"eslint": "^8.11.0",
|
||||||
|
"eslint-config-prettier": "^8.5.0",
|
||||||
|
"eslint-plugin-jest": "^26.1.1",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"jest": "^27.2.5",
|
||||||
"prettier": "^2.3.1",
|
"prettier": "^2.3.1",
|
||||||
"ts-jest": "^26.5.6",
|
"ts-jest": "^27.1.2",
|
||||||
"typescript": "^4.3.4",
|
"ts-node": "^10.7.0",
|
||||||
"typescript-formatter": "^7.2.2"
|
"typescript": "^4.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
192
src/buildx.ts
192
src/buildx.ts
@ -1,11 +1,26 @@
|
|||||||
import csvparse from 'csv-parse/lib/sync';
|
import {parse} from 'csv-parse/sync';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
import * as context from './context';
|
import * as context from './context';
|
||||||
|
|
||||||
|
export type Builder = {
|
||||||
|
name?: string;
|
||||||
|
driver?: string;
|
||||||
|
nodes: Node[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Node = {
|
||||||
|
name?: string;
|
||||||
|
endpoint?: string;
|
||||||
|
'driver-opts'?: Array<string>;
|
||||||
|
status?: string;
|
||||||
|
'buildkitd-flags'?: string;
|
||||||
|
buildkit?: string;
|
||||||
|
platforms?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export async function getImageIDFile(): Promise<string> {
|
export async function getImageIDFile(): Promise<string> {
|
||||||
return path.join(context.tmpDir(), 'iidfile').split(path.sep).join(path.posix.sep);
|
return path.join(context.tmpDir(), 'iidfile').split(path.sep).join(path.posix.sep);
|
||||||
}
|
}
|
||||||
@ -15,7 +30,34 @@ export async function getImageID(): Promise<string | undefined> {
|
|||||||
if (!fs.existsSync(iidFile)) {
|
if (!fs.existsSync(iidFile)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return fs.readFileSync(iidFile, {encoding: 'utf-8'});
|
return fs.readFileSync(iidFile, {encoding: 'utf-8'}).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMetadataFile(): Promise<string> {
|
||||||
|
return path.join(context.tmpDir(), 'metadata-file').split(path.sep).join(path.posix.sep);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getMetadata(): Promise<string | undefined> {
|
||||||
|
const metadataFile = await getMetadataFile();
|
||||||
|
if (!fs.existsSync(metadataFile)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const content = fs.readFileSync(metadataFile, {encoding: 'utf-8'}).trim();
|
||||||
|
if (content === 'null') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getDigest(metadata: string | undefined): Promise<string | undefined> {
|
||||||
|
if (metadata === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const metadataJSON = JSON.parse(metadata);
|
||||||
|
if (metadataJSON['containerimage.digest']) {
|
||||||
|
return metadataJSON['containerimage.digest'];
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSecretString(kvp: string): Promise<string> {
|
export async function getSecretString(kvp: string): Promise<string> {
|
||||||
@ -49,19 +91,20 @@ export async function getSecret(kvp: string, file: boolean): Promise<string> {
|
|||||||
return `id=${key},src=${secretFile}`;
|
return `id=${key},src=${secretFile}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isLocalOrTarExporter(outputs: string[]): Boolean {
|
export function isLocalOrTarExporter(outputs: string[]): boolean {
|
||||||
for (let output of csvparse(outputs.join(`\n`), {
|
const records = parse(outputs.join(`\n`), {
|
||||||
delimiter: ',',
|
delimiter: ',',
|
||||||
trim: true,
|
trim: true,
|
||||||
columns: false,
|
columns: false,
|
||||||
relaxColumnCount: true
|
relaxColumnCount: true
|
||||||
})) {
|
});
|
||||||
|
for (const record of records) {
|
||||||
// Local if no type is defined
|
// Local if no type is defined
|
||||||
// https://github.com/docker/buildx/blob/d2bf42f8b4784d83fde17acb3ed84703ddc2156b/build/output.go#L29-L43
|
// https://github.com/docker/buildx/blob/d2bf42f8b4784d83fde17acb3ed84703ddc2156b/build/output.go#L29-L43
|
||||||
if (output.length == 1 && !output[0].startsWith('type=')) {
|
if (record.length == 1 && !record[0].startsWith('type=')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (let [key, value] of output.map(chunk => chunk.split('=').map(item => item.trim()))) {
|
for (const [key, value] of record.map(chunk => chunk.split('=').map(item => item.trim()))) {
|
||||||
if (key == 'type' && (value == 'local' || value == 'tar')) {
|
if (key == 'type' && (value == 'local' || value == 'tar')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -70,8 +113,8 @@ export function isLocalOrTarExporter(outputs: string[]): Boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasGitAuthToken(secrets: string[]): Boolean {
|
export function hasGitAuthToken(secrets: string[]): boolean {
|
||||||
for (let secret of secrets) {
|
for (const secret of secrets) {
|
||||||
if (secret.startsWith('GIT_AUTH_TOKEN=')) {
|
if (secret.startsWith('GIT_AUTH_TOKEN=')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -79,9 +122,10 @@ export function hasGitAuthToken(secrets: string[]): Boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isAvailable(): Promise<Boolean> {
|
export async function isAvailable(standalone?: boolean): Promise<boolean> {
|
||||||
|
const cmd = getCommand([], standalone);
|
||||||
return await exec
|
return await exec
|
||||||
.getExecOutput('docker', ['buildx'], {
|
.getExecOutput(cmd.command, cmd.args, {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
})
|
})
|
||||||
@ -90,12 +134,35 @@ export async function isAvailable(): Promise<Boolean> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return res.exitCode == 0;
|
return res.exitCode == 0;
|
||||||
|
})
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
.catch(error => {
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getVersion(): Promise<string> {
|
export async function satisfiesBuildKitVersion(builderName: string, range: string, standalone?: boolean): Promise<boolean> {
|
||||||
|
const builderInspect = await inspect(builderName, standalone);
|
||||||
|
for (const node of builderInspect.nodes) {
|
||||||
|
if (!node.buildkit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// BuildKit version reported by moby is in the format of `v0.11.0-moby`
|
||||||
|
if (builderInspect.driver == 'docker' && !node.buildkit.endsWith('-moby')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const version = node.buildkit.replace(/-moby$/, '');
|
||||||
|
if (!semver.satisfies(version, range)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function inspect(name: string, standalone?: boolean): Promise<Builder> {
|
||||||
|
const cmd = getCommand(['inspect', name], standalone);
|
||||||
return await exec
|
return await exec
|
||||||
.getExecOutput('docker', ['buildx', 'version'], {
|
.getExecOutput(cmd.command, cmd.args, {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
silent: true
|
silent: true
|
||||||
})
|
})
|
||||||
@ -103,7 +170,95 @@ export async function getVersion(): Promise<string> {
|
|||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
throw new Error(res.stderr.trim());
|
throw new Error(res.stderr.trim());
|
||||||
}
|
}
|
||||||
return parseVersion(res.stdout);
|
return parseInspect(res.stdout);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function parseInspect(data: string): Promise<Builder> {
|
||||||
|
const builder: Builder = {
|
||||||
|
nodes: []
|
||||||
|
};
|
||||||
|
let node: Node = {};
|
||||||
|
for (const line of data.trim().split(`\n`)) {
|
||||||
|
const [key, ...rest] = line.split(':');
|
||||||
|
const value = rest.map(v => v.trim()).join(':');
|
||||||
|
if (key.length == 0 || value.length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (key.toLowerCase()) {
|
||||||
|
case 'name': {
|
||||||
|
if (builder.name == undefined) {
|
||||||
|
builder.name = value;
|
||||||
|
} else {
|
||||||
|
if (Object.keys(node).length > 0) {
|
||||||
|
builder.nodes.push(node);
|
||||||
|
node = {};
|
||||||
|
}
|
||||||
|
node.name = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'driver': {
|
||||||
|
builder.driver = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'endpoint': {
|
||||||
|
node.endpoint = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'driver options': {
|
||||||
|
node['driver-opts'] = (value.match(/(\w+)="([^"]*)"/g) || []).map(v => v.replace(/^(.*)="(.*)"$/g, '$1=$2'));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'status': {
|
||||||
|
node.status = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'flags': {
|
||||||
|
node['buildkitd-flags'] = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'buildkit': {
|
||||||
|
node.buildkit = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'platforms': {
|
||||||
|
let platforms: Array<string> = [];
|
||||||
|
// if a preferred platform is being set then use only these
|
||||||
|
// https://docs.docker.com/engine/reference/commandline/buildx_inspect/#get-information-about-a-builder-instance
|
||||||
|
if (value.includes('*')) {
|
||||||
|
for (const platform of value.split(', ')) {
|
||||||
|
if (platform.includes('*')) {
|
||||||
|
platforms.push(platform.replace('*', ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// otherwise set all platforms available
|
||||||
|
platforms = value.split(', ');
|
||||||
|
}
|
||||||
|
node.platforms = platforms.join(',');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Object.keys(node).length > 0) {
|
||||||
|
builder.nodes.push(node);
|
||||||
|
}
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getVersion(standalone?: boolean): Promise<string> {
|
||||||
|
const cmd = getCommand(['version'], standalone);
|
||||||
|
return await exec
|
||||||
|
.getExecOutput(cmd.command, cmd.args, {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr.trim());
|
||||||
|
}
|
||||||
|
return parseVersion(res.stdout.trim());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,3 +273,10 @@ export function parseVersion(stdout: string): string {
|
|||||||
export function satisfies(version: string, range: string): boolean {
|
export function satisfies(version: string, range: string): boolean {
|
||||||
return semver.satisfies(version, range) || /^[0-9a-f]{7}$/.exec(version) !== null;
|
return semver.satisfies(version, range) || /^[0-9a-f]{7}$/.exec(version) !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCommand(args: Array<string>, standalone?: boolean) {
|
||||||
|
return {
|
||||||
|
command: standalone ? 'buildx' : 'docker',
|
||||||
|
args: standalone ? args : ['buildx', ...args]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
234
src/context.ts
234
src/context.ts
@ -1,39 +1,45 @@
|
|||||||
import csvparse from 'csv-parse/lib/sync';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as semver from 'semver';
|
|
||||||
import * as tmp from 'tmp';
|
import * as tmp from 'tmp';
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import {issueCommand} from '@actions/core/lib/command';
|
|
||||||
import * as github from '@actions/github';
|
|
||||||
|
|
||||||
import * as buildx from './buildx';
|
import * as buildx from './buildx';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as github from '@actions/github';
|
||||||
|
import {parse} from 'csv-parse/sync';
|
||||||
|
import * as handlebars from 'handlebars';
|
||||||
|
|
||||||
let _defaultContext, _tmpDir: string;
|
let _defaultContext, _tmpDir: string;
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
|
addHosts: string[];
|
||||||
allow: string[];
|
allow: string[];
|
||||||
|
attests: string[];
|
||||||
buildArgs: string[];
|
buildArgs: string[];
|
||||||
|
buildContexts: string[];
|
||||||
builder: string;
|
builder: string;
|
||||||
cacheFrom: string[];
|
cacheFrom: string[];
|
||||||
cacheTo: string[];
|
cacheTo: string[];
|
||||||
|
cgroupParent: string;
|
||||||
context: string;
|
context: string;
|
||||||
file: string;
|
file: string;
|
||||||
labels: string[];
|
labels: string[];
|
||||||
load: boolean;
|
load: boolean;
|
||||||
network: string;
|
network: string;
|
||||||
noCache: boolean;
|
noCache: boolean;
|
||||||
|
noCacheFilters: string[];
|
||||||
outputs: string[];
|
outputs: string[];
|
||||||
platforms: string[];
|
platforms: string[];
|
||||||
|
provenance: string;
|
||||||
pull: boolean;
|
pull: boolean;
|
||||||
push: boolean;
|
push: boolean;
|
||||||
|
sbom: string;
|
||||||
secrets: string[];
|
secrets: string[];
|
||||||
secretFiles: string[];
|
secretFiles: string[];
|
||||||
|
shmSize: string;
|
||||||
ssh: string[];
|
ssh: string[];
|
||||||
tags: string[];
|
tags: string[];
|
||||||
target: string;
|
target: string;
|
||||||
|
ulimit: string[];
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,65 +68,75 @@ export function tmpNameSync(options?: tmp.TmpNameOptions): string {
|
|||||||
return tmp.tmpNameSync(options);
|
return tmp.tmpNameSync(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function provenanceBuilderID(): string {
|
||||||
|
return `${process.env.GITHUB_SERVER_URL || 'https://github.com'}/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}`;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getInputs(defaultContext: string): Promise<Inputs> {
|
export async function getInputs(defaultContext: string): Promise<Inputs> {
|
||||||
return {
|
return {
|
||||||
|
addHosts: await getInputList('add-hosts'),
|
||||||
allow: await getInputList('allow'),
|
allow: await getInputList('allow'),
|
||||||
|
attests: await getInputList('attests', true),
|
||||||
buildArgs: await getInputList('build-args', true),
|
buildArgs: await getInputList('build-args', true),
|
||||||
|
buildContexts: await getInputList('build-contexts', true),
|
||||||
builder: core.getInput('builder'),
|
builder: core.getInput('builder'),
|
||||||
cacheFrom: await getInputList('cache-from', true),
|
cacheFrom: await getInputList('cache-from', true),
|
||||||
cacheTo: await getInputList('cache-to', true),
|
cacheTo: await getInputList('cache-to', true),
|
||||||
|
cgroupParent: core.getInput('cgroup-parent'),
|
||||||
context: core.getInput('context') || defaultContext,
|
context: core.getInput('context') || defaultContext,
|
||||||
file: core.getInput('file'),
|
file: core.getInput('file'),
|
||||||
labels: await getInputList('labels', true),
|
labels: await getInputList('labels', true),
|
||||||
load: core.getBooleanInput('load'),
|
load: core.getBooleanInput('load'),
|
||||||
network: core.getInput('network'),
|
network: core.getInput('network'),
|
||||||
noCache: core.getBooleanInput('no-cache'),
|
noCache: core.getBooleanInput('no-cache'),
|
||||||
|
noCacheFilters: await getInputList('no-cache-filters'),
|
||||||
outputs: await getInputList('outputs', true),
|
outputs: await getInputList('outputs', true),
|
||||||
platforms: await getInputList('platforms'),
|
platforms: await getInputList('platforms'),
|
||||||
|
provenance: getProvenanceInput('provenance'),
|
||||||
pull: core.getBooleanInput('pull'),
|
pull: core.getBooleanInput('pull'),
|
||||||
push: core.getBooleanInput('push'),
|
push: core.getBooleanInput('push'),
|
||||||
|
sbom: core.getInput('sbom'),
|
||||||
secrets: await getInputList('secrets', true),
|
secrets: await getInputList('secrets', true),
|
||||||
secretFiles: await getInputList('secret-files', true),
|
secretFiles: await getInputList('secret-files', true),
|
||||||
|
shmSize: core.getInput('shm-size'),
|
||||||
ssh: await getInputList('ssh'),
|
ssh: await getInputList('ssh'),
|
||||||
tags: await getInputList('tags'),
|
tags: await getInputList('tags'),
|
||||||
target: core.getInput('target'),
|
target: core.getInput('target'),
|
||||||
|
ulimit: await getInputList('ulimit', true),
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
|
export async function getArgs(inputs: Inputs, defaultContext: string, buildxVersion: string, standalone?: boolean): Promise<Array<string>> {
|
||||||
let args: Array<string> = ['buildx'];
|
const context = handlebars.compile(inputs.context)({defaultContext});
|
||||||
args.push.apply(args, await getBuildArgs(inputs, defaultContext, buildxVersion));
|
// prettier-ignore
|
||||||
args.push.apply(args, await getCommonArgs(inputs));
|
return [
|
||||||
args.push(inputs.context);
|
...await getBuildArgs(inputs, defaultContext, context, buildxVersion, standalone),
|
||||||
return args;
|
...await getCommonArgs(inputs, buildxVersion),
|
||||||
|
context
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
|
async function getBuildArgs(inputs: Inputs, defaultContext: string, context: string, buildxVersion: string, standalone?: boolean): Promise<Array<string>> {
|
||||||
let args: Array<string> = ['build'];
|
const args: Array<string> = ['build'];
|
||||||
await asyncForEach(inputs.buildArgs, async buildArg => {
|
await asyncForEach(inputs.addHosts, async addHost => {
|
||||||
args.push('--build-arg', buildArg);
|
args.push('--add-host', addHost);
|
||||||
});
|
});
|
||||||
await asyncForEach(inputs.labels, async label => {
|
|
||||||
args.push('--label', label);
|
|
||||||
});
|
|
||||||
await asyncForEach(inputs.tags, async tag => {
|
|
||||||
args.push('--tag', tag);
|
|
||||||
});
|
|
||||||
if (inputs.target) {
|
|
||||||
args.push('--target', inputs.target);
|
|
||||||
}
|
|
||||||
if (inputs.allow.length > 0) {
|
if (inputs.allow.length > 0) {
|
||||||
args.push('--allow', inputs.allow.join(','));
|
args.push('--allow', inputs.allow.join(','));
|
||||||
}
|
}
|
||||||
if (inputs.platforms.length > 0) {
|
if (buildx.satisfies(buildxVersion, '>=0.10.0')) {
|
||||||
args.push('--platform', inputs.platforms.join(','));
|
await asyncForEach(inputs.attests, async attest => {
|
||||||
|
args.push('--attest', attest);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
await asyncForEach(inputs.outputs, async output => {
|
await asyncForEach(inputs.buildArgs, async buildArg => {
|
||||||
args.push('--output', output);
|
args.push('--build-arg', buildArg);
|
||||||
});
|
});
|
||||||
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
|
if (buildx.satisfies(buildxVersion, '>=0.8.0')) {
|
||||||
args.push('--iidfile', await buildx.getImageIDFile());
|
await asyncForEach(inputs.buildContexts, async buildContext => {
|
||||||
|
args.push('--build-context', buildContext);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
await asyncForEach(inputs.cacheFrom, async cacheFrom => {
|
await asyncForEach(inputs.cacheFrom, async cacheFrom => {
|
||||||
args.push('--cache-from', cacheFrom);
|
args.push('--cache-from', cacheFrom);
|
||||||
@ -128,6 +144,44 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
|
|||||||
await asyncForEach(inputs.cacheTo, async cacheTo => {
|
await asyncForEach(inputs.cacheTo, async cacheTo => {
|
||||||
args.push('--cache-to', cacheTo);
|
args.push('--cache-to', cacheTo);
|
||||||
});
|
});
|
||||||
|
if (inputs.cgroupParent) {
|
||||||
|
args.push('--cgroup-parent', inputs.cgroupParent);
|
||||||
|
}
|
||||||
|
if (inputs.file) {
|
||||||
|
args.push('--file', inputs.file);
|
||||||
|
}
|
||||||
|
if (!buildx.isLocalOrTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || buildx.satisfies(buildxVersion, '>=0.4.2'))) {
|
||||||
|
args.push('--iidfile', await buildx.getImageIDFile());
|
||||||
|
}
|
||||||
|
await asyncForEach(inputs.labels, async label => {
|
||||||
|
args.push('--label', label);
|
||||||
|
});
|
||||||
|
await asyncForEach(inputs.noCacheFilters, async noCacheFilter => {
|
||||||
|
args.push('--no-cache-filter', noCacheFilter);
|
||||||
|
});
|
||||||
|
await asyncForEach(inputs.outputs, async output => {
|
||||||
|
args.push('--output', output);
|
||||||
|
});
|
||||||
|
if (inputs.platforms.length > 0) {
|
||||||
|
args.push('--platform', inputs.platforms.join(','));
|
||||||
|
}
|
||||||
|
if (buildx.satisfies(buildxVersion, '>=0.10.0')) {
|
||||||
|
if (inputs.provenance) {
|
||||||
|
args.push('--provenance', inputs.provenance);
|
||||||
|
} else if ((await buildx.satisfiesBuildKitVersion(inputs.builder, '>=0.11.0', standalone)) && !hasDockerExport(inputs)) {
|
||||||
|
// If provenance not specified but BuildKit version compatible for
|
||||||
|
// attestation, disable provenance anyway. Also needs to make sure user
|
||||||
|
// doesn't want to explicitly load the image to docker.
|
||||||
|
// While this action successfully pushes OCI compliant images to
|
||||||
|
// well-known registries, some runtimes (e.g. Google Cloud Run and AWS
|
||||||
|
// Lambda) are not able to pull resulting image from their own registry...
|
||||||
|
// See also https://github.com/docker/buildx/issues/1533
|
||||||
|
args.push('--provenance', 'false');
|
||||||
|
}
|
||||||
|
if (inputs.sbom) {
|
||||||
|
args.push('--sbom', inputs.sbom);
|
||||||
|
}
|
||||||
|
}
|
||||||
await asyncForEach(inputs.secrets, async secret => {
|
await asyncForEach(inputs.secrets, async secret => {
|
||||||
try {
|
try {
|
||||||
args.push('--secret', await buildx.getSecretString(secret));
|
args.push('--secret', await buildx.getSecretString(secret));
|
||||||
@ -142,35 +196,47 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
|
|||||||
core.warning(err.message);
|
core.warning(err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
|
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && context.startsWith(defaultContext)) {
|
||||||
args.push('--secret', await buildx.getSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
args.push('--secret', await buildx.getSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
||||||
}
|
}
|
||||||
|
if (inputs.shmSize) {
|
||||||
|
args.push('--shm-size', inputs.shmSize);
|
||||||
|
}
|
||||||
await asyncForEach(inputs.ssh, async ssh => {
|
await asyncForEach(inputs.ssh, async ssh => {
|
||||||
args.push('--ssh', ssh);
|
args.push('--ssh', ssh);
|
||||||
});
|
});
|
||||||
if (inputs.file) {
|
await asyncForEach(inputs.tags, async tag => {
|
||||||
args.push('--file', inputs.file);
|
args.push('--tag', tag);
|
||||||
|
});
|
||||||
|
if (inputs.target) {
|
||||||
|
args.push('--target', inputs.target);
|
||||||
}
|
}
|
||||||
|
await asyncForEach(inputs.ulimit, async ulimit => {
|
||||||
|
args.push('--ulimit', ulimit);
|
||||||
|
});
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
|
async function getCommonArgs(inputs: Inputs, buildxVersion: string): Promise<Array<string>> {
|
||||||
let args: Array<string> = [];
|
const args: Array<string> = [];
|
||||||
if (inputs.noCache) {
|
|
||||||
args.push('--no-cache');
|
|
||||||
}
|
|
||||||
if (inputs.builder) {
|
if (inputs.builder) {
|
||||||
args.push('--builder', inputs.builder);
|
args.push('--builder', inputs.builder);
|
||||||
}
|
}
|
||||||
if (inputs.pull) {
|
|
||||||
args.push('--pull');
|
|
||||||
}
|
|
||||||
if (inputs.load) {
|
if (inputs.load) {
|
||||||
args.push('--load');
|
args.push('--load');
|
||||||
}
|
}
|
||||||
|
if (buildx.satisfies(buildxVersion, '>=0.6.0')) {
|
||||||
|
args.push('--metadata-file', await buildx.getMetadataFile());
|
||||||
|
}
|
||||||
if (inputs.network) {
|
if (inputs.network) {
|
||||||
args.push('--network', inputs.network);
|
args.push('--network', inputs.network);
|
||||||
}
|
}
|
||||||
|
if (inputs.noCache) {
|
||||||
|
args.push('--no-cache');
|
||||||
|
}
|
||||||
|
if (inputs.pull) {
|
||||||
|
args.push('--pull');
|
||||||
|
}
|
||||||
if (inputs.push) {
|
if (inputs.push) {
|
||||||
args.push('--push');
|
args.push('--push');
|
||||||
}
|
}
|
||||||
@ -178,27 +244,29 @@ async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
|
export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
|
||||||
let res: Array<string> = [];
|
const res: Array<string> = [];
|
||||||
|
|
||||||
const items = core.getInput(name);
|
const items = core.getInput(name);
|
||||||
if (items == '') {
|
if (items == '') {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let output of (await csvparse(items, {
|
const records = await parse(items, {
|
||||||
columns: false,
|
columns: false,
|
||||||
relax: true,
|
relaxQuotes: true,
|
||||||
relaxColumnCount: true,
|
relaxColumnCount: true,
|
||||||
skipLinesWithEmptyValues: true
|
skipEmptyLines: true
|
||||||
})) as Array<string[]>) {
|
});
|
||||||
if (output.length == 1) {
|
|
||||||
res.push(output[0]);
|
for (const record of records as Array<string[]>) {
|
||||||
|
if (record.length == 1) {
|
||||||
|
res.push(record[0]);
|
||||||
continue;
|
continue;
|
||||||
} else if (!ignoreComma) {
|
} else if (!ignoreComma) {
|
||||||
res.push(...output);
|
res.push(...record);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
res.push(output.join(','));
|
res.push(record.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.filter(item => item).map(pat => pat.trim());
|
return res.filter(item => item).map(pat => pat.trim());
|
||||||
@ -210,7 +278,63 @@ export const asyncForEach = async (array, callback) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
function getProvenanceInput(name: string): string {
|
||||||
export function setOutput(name: string, value: any): void {
|
const input = core.getInput(name);
|
||||||
issueCommand('set-output', {name}, value);
|
if (!input) {
|
||||||
|
// if input is not set, default values will be set later.
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
const builderID = provenanceBuilderID();
|
||||||
|
try {
|
||||||
|
return core.getBooleanInput(name) ? `builder-id=${builderID}` : 'false';
|
||||||
|
} catch (err) {
|
||||||
|
// not a valid boolean, so we assume it's a string
|
||||||
|
return getProvenanceAttrs(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProvenanceAttrs(input: string): string {
|
||||||
|
const builderID = provenanceBuilderID();
|
||||||
|
// parse attributes from input
|
||||||
|
const fields = parse(input, {
|
||||||
|
relaxColumnCount: true,
|
||||||
|
skipEmptyLines: true
|
||||||
|
})[0];
|
||||||
|
// check if builder-id attribute exists in the input
|
||||||
|
for (const field of fields) {
|
||||||
|
const parts = field
|
||||||
|
.toString()
|
||||||
|
.split(/(?<=^[^=]+?)=/)
|
||||||
|
.map(item => item.trim());
|
||||||
|
if (parts[0] == 'builder-id') {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if not add builder-id attribute
|
||||||
|
return `${input},builder-id=${builderID}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasDockerExport(inputs: Inputs): boolean {
|
||||||
|
if (inputs.load) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (const output of inputs.outputs) {
|
||||||
|
const fields = parse(output, {
|
||||||
|
relaxColumnCount: true,
|
||||||
|
skipEmptyLines: true
|
||||||
|
})[0];
|
||||||
|
for (const field of fields) {
|
||||||
|
const parts = field
|
||||||
|
.toString()
|
||||||
|
.split(/(?<=^[^=]+?)=/)
|
||||||
|
.map(item => item.trim());
|
||||||
|
if (parts.length != 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (parts[0] == 'type' && parts[1] == 'docker') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
19
src/docker.ts
Normal file
19
src/docker.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
|
export async function isAvailable(): Promise<boolean> {
|
||||||
|
return await exec
|
||||||
|
.getExecOutput('docker', undefined, {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return res.exitCode == 0;
|
||||||
|
})
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
.catch(error => {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
9
src/github.ts
Normal file
9
src/github.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import jwt_decode, {JwtPayload} from 'jwt-decode';
|
||||||
|
|
||||||
|
interface Jwt extends JwtPayload {
|
||||||
|
ac?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const parseRuntimeToken = (token: string): Jwt => {
|
||||||
|
return jwt_decode<Jwt>(token);
|
||||||
|
};
|
73
src/main.ts
73
src/main.ts
@ -1,44 +1,89 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as buildx from './buildx';
|
import * as buildx from './buildx';
|
||||||
import * as context from './context';
|
import * as context from './context';
|
||||||
|
import * as docker from './docker';
|
||||||
|
import * as github from './github';
|
||||||
import * as stateHelper from './state-helper';
|
import * as stateHelper from './state-helper';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
const defContext = context.defaultContext();
|
||||||
|
const inputs: context.Inputs = await context.getInputs(defContext);
|
||||||
|
|
||||||
|
// standalone if docker cli not available
|
||||||
|
const standalone = !(await docker.isAvailable());
|
||||||
|
|
||||||
|
await core.group(`GitHub Actions runtime token access controls`, async () => {
|
||||||
|
const actionsRuntimeToken = process.env['ACTIONS_RUNTIME_TOKEN'];
|
||||||
|
if (actionsRuntimeToken) {
|
||||||
|
core.info(JSON.stringify(JSON.parse(github.parseRuntimeToken(actionsRuntimeToken).ac as string), undefined, 2));
|
||||||
|
} else {
|
||||||
|
core.info(`ACTIONS_RUNTIME_TOKEN not set`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
core.startGroup(`Docker info`);
|
core.startGroup(`Docker info`);
|
||||||
await exec.exec('docker', ['version']);
|
if (standalone) {
|
||||||
await exec.exec('docker', ['info']);
|
core.info(`Docker info skipped in standalone mode`);
|
||||||
|
} else {
|
||||||
|
await exec.exec('docker', ['version'], {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
await exec.exec('docker', ['info'], {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
if (!(await buildx.isAvailable())) {
|
if (!(await buildx.isAvailable(standalone))) {
|
||||||
core.setFailed(`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
|
core.setFailed(`Docker buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stateHelper.setTmpDir(context.tmpDir());
|
stateHelper.setTmpDir(context.tmpDir());
|
||||||
|
|
||||||
const buildxVersion = await buildx.getVersion();
|
const buildxVersion = await buildx.getVersion(standalone);
|
||||||
const defContext = context.defaultContext();
|
await core.group(`Buildx version`, async () => {
|
||||||
let inputs: context.Inputs = await context.getInputs(defContext);
|
const versionCmd = buildx.getCommand(['version'], standalone);
|
||||||
|
await exec.exec(versionCmd.command, versionCmd.args, {
|
||||||
|
failOnStdErr: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const args: string[] = await context.getArgs(inputs, defContext, buildxVersion);
|
const args: string[] = await context.getArgs(inputs, defContext, buildxVersion, standalone);
|
||||||
|
const buildCmd = buildx.getCommand(args, standalone);
|
||||||
await exec
|
await exec
|
||||||
.getExecOutput('docker', args, {
|
.getExecOutput(buildCmd.command, buildCmd.args, {
|
||||||
ignoreReturnCode: true
|
ignoreReturnCode: true
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.stderr.length > 0 && res.exitCode != 0) {
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
throw new Error(`buildx bake failed with: ${res.stderr.match(/(.*)\s*$/)![0].trim()}`);
|
throw new Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const imageID = await buildx.getImageID();
|
const imageID = await buildx.getImageID();
|
||||||
|
const metadata = await buildx.getMetadata();
|
||||||
|
const digest = await buildx.getDigest(metadata);
|
||||||
|
|
||||||
if (imageID) {
|
if (imageID) {
|
||||||
core.startGroup(`Extracting digest`);
|
await core.group(`ImageID`, async () => {
|
||||||
core.info(`${imageID}`);
|
core.info(imageID);
|
||||||
context.setOutput('digest', imageID);
|
core.setOutput('imageid', imageID);
|
||||||
core.endGroup();
|
});
|
||||||
|
}
|
||||||
|
if (digest) {
|
||||||
|
await core.group(`Digest`, async () => {
|
||||||
|
core.info(digest);
|
||||||
|
core.setOutput('digest', digest);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (metadata) {
|
||||||
|
await core.group(`Metadata`, async () => {
|
||||||
|
core.info(metadata);
|
||||||
|
core.setOutput('metadata', metadata);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@ -48,7 +93,7 @@ async function run(): Promise<void> {
|
|||||||
async function cleanup(): Promise<void> {
|
async function cleanup(): Promise<void> {
|
||||||
if (stateHelper.tmpDir.length > 0) {
|
if (stateHelper.tmpDir.length > 0) {
|
||||||
core.startGroup(`Removing temp folder ${stateHelper.tmpDir}`);
|
core.startGroup(`Removing temp folder ${stateHelper.tmpDir}`);
|
||||||
fs.rmdirSync(stateHelper.tmpDir, {recursive: true});
|
fs.rmSync(stateHelper.tmpDir, {recursive: true});
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
RUN echo "Hello world!"
|
RUN echo "Hello world!"
|
||||||
|
3
test/addhost.Dockerfile
Normal file
3
test/addhost.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM busybox
|
||||||
|
RUN cat /etc/hosts
|
3
test/buildcontext.Dockerfile
Normal file
3
test/buildcontext.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM alpine
|
||||||
|
RUN cat /etc/*release
|
3
test/cgroup.Dockerfile
Normal file
3
test/cgroup.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM alpine
|
||||||
|
RUN cat /proc/self/cgroup
|
16
test/go/Dockerfile
Normal file
16
test/go/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM golang:1.19-alpine AS base
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
RUN apk add --no-cache file git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base as build
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download -x
|
||||||
|
COPY . .
|
||||||
|
RUN go build -ldflags "-s -w" -o /usr/bin/app .
|
||||||
|
|
||||||
|
FROM scratch AS binary
|
||||||
|
COPY --from=build /usr/bin/app /bin/app
|
||||||
|
|
||||||
|
FROM alpine:3.17 AS image
|
||||||
|
COPY --from=build /usr/bin/app /bin/app
|
19
test/go/go.mod
Normal file
19
test/go/go.mod
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
module github.com/docker/build-push-action/test/go
|
||||||
|
|
||||||
|
go 1.18
|
||||||
|
|
||||||
|
require github.com/labstack/echo/v4 v4.9.1
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||||
|
github.com/labstack/gommon v0.4.0 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.11 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
|
github.com/valyala/fasttemplate v1.2.1 // indirect
|
||||||
|
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
|
||||||
|
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
|
||||||
|
golang.org/x/text v0.3.7 // indirect
|
||||||
|
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
|
||||||
|
)
|
38
test/go/go.sum
Normal file
38
test/go/go.sum
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||||
|
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
|
github.com/labstack/echo/v4 v4.9.1 h1:GliPYSpzGKlyOhqIbG8nmHBo3i1saKWFOgh41AN3b+Y=
|
||||||
|
github.com/labstack/echo/v4 v4.9.1/go.mod h1:Pop5HLc+xoc4qhTZ1ip6C0RtP7Z+4VzRLWZZFKqbbjo=
|
||||||
|
github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
|
||||||
|
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||||
|
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
|
||||||
|
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
|
github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=
|
||||||
|
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
|
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
|
||||||
|
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY=
|
||||||
|
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b h1:1VkfZQv42XQlA/jchYumAnv1UPo6RgF9rJFkTgZIxO4=
|
||||||
|
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE=
|
||||||
|
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
31
test/go/main.go
Normal file
31
test/go/main.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"github.com/labstack/echo/v4/middleware"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
e := echo.New()
|
||||||
|
|
||||||
|
e.Use(middleware.Logger())
|
||||||
|
e.Use(middleware.Recover())
|
||||||
|
|
||||||
|
e.GET("/", func(c echo.Context) error {
|
||||||
|
return c.HTML(http.StatusOK, "Hello World")
|
||||||
|
})
|
||||||
|
|
||||||
|
e.GET("/ping", func(c echo.Context) error {
|
||||||
|
return c.JSON(http.StatusOK, struct{ Status string }{Status: "OK"})
|
||||||
|
})
|
||||||
|
|
||||||
|
httpPort := os.Getenv("HTTP_PORT")
|
||||||
|
if httpPort == "" {
|
||||||
|
httpPort = "8080"
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Logger.Fatal(e.Start(":" + httpPort))
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log
|
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" > /log
|
||||||
|
|
||||||
RUN apk --update --no-cache add \
|
RUN apk --update --no-cache add \
|
||||||
shadow \
|
shadow \
|
||||||
sudo \
|
sudo \
|
||||||
@ -17,6 +16,5 @@ RUN sudo chown buildx. /log
|
|||||||
USER root
|
USER root
|
||||||
|
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
COPY --from=build /log /log
|
COPY --from=build /log /log
|
||||||
RUN ls -al /log
|
RUN ls -al /log
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
9
test/nocachefilter.Dockerfile
Normal file
9
test/nocachefilter.Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM busybox AS base
|
||||||
|
RUN echo "Hello world!" > /hello
|
||||||
|
|
||||||
|
FROM alpine AS build
|
||||||
|
COPY --from=base /hello /hello
|
||||||
|
RUN uname -a
|
||||||
|
|
||||||
|
FROM build
|
4
test/secret.Dockerfile
Normal file
4
test/secret.Dockerfile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM busybox
|
||||||
|
RUN --mount=type=secret,id=MYSECRET \
|
||||||
|
echo "MYSECRET=$(cat /run/secrets/MYSECRET)"
|
3
test/shmsize.Dockerfile
Normal file
3
test/shmsize.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM busybox
|
||||||
|
RUN mount | grep /dev/shm
|
3
test/ulimit.Dockerfile
Normal file
3
test/ulimit.Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM busybox
|
||||||
|
RUN ulimit -a
|
@ -2,20 +2,18 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"lib": [
|
|
||||||
"es6",
|
|
||||||
"dom"
|
|
||||||
],
|
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"esModuleInterop": true,
|
"useUnknownInCatchVariables": false,
|
||||||
"sourceMap": true
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"**/*.test.ts"
|
"**/*.test.ts",
|
||||||
|
"jest.config.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user