forked from distribution/distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request distribution#3315 from crazy-max/ghactions
Native cross-compilation, artifacts and multi-platform image
- Loading branch information
Showing
6 changed files
with
211 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'release/*' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
env: | ||
DOCKERHUB_SLUG: distribution/distribution | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: | | ||
${{ env.DOCKERHUB_SLUG }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=ref,event=pr | ||
type=edge | ||
labels: | | ||
org.opencontainers.image.title=Distribution | ||
org.opencontainers.image.description=The toolkit to pack, ship, store, and deliver container content | ||
- | ||
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: Build artifacts | ||
uses: docker/bake-action@v1 | ||
with: | ||
targets: artifact-all | ||
- | ||
name: Move artifacts | ||
run: | | ||
mv ./bin/**/* ./bin/ | ||
- | ||
name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: registry | ||
path: ./bin/* | ||
if-no-files-found: error | ||
- | ||
name: Build image | ||
uses: docker/bake-action@v1 | ||
with: | ||
files: | | ||
./docker-bake.hcl | ||
${{ steps.meta.outputs.bake-file }} | ||
targets: image-all | ||
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} | ||
- | ||
name: GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
draft: true | ||
files: | | ||
bin/*.tar.gz | ||
bin/*.zip | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,27 +8,26 @@ jobs: | |
run-conformance-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: set up docker | ||
uses: docker-practice/[email protected] | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
docker_version: 18.09 | ||
docker_channel: stable | ||
|
||
- uses: actions/checkout@v2 | ||
fetch-depth: 0 | ||
- | ||
name: Build image | ||
uses: docker/bake-action@v1 | ||
with: | ||
path: src/github.com/distribution/distribution | ||
|
||
- name: start distribution server | ||
working-directory: ./src/github.com/distribution/distribution | ||
targets: image-local | ||
- | ||
name: Start distribution server | ||
run: | | ||
IP=`hostname -I | awk '{print $1}'` | ||
echo "IP=$IP" >> $GITHUB_ENV | ||
echo "OCI_ROOT_URL=http://$IP:5000" >> $GITHUB_ENV | ||
DISTRIBUTION_REF="local-distribution:v$(date +%Y%m%d%H%M%S)" | ||
docker build -f ./Dockerfile -t "${DISTRIBUTION_REF}" . | ||
docker run --rm -p 5000:5000 -e REGISTRY_STORAGE_DELETE_ENABLED=true -idt "${DISTRIBUTION_REF}" | ||
- name: Run OCI Distribution Spec conformance tests | ||
DISTRIBUTION_REF="registry:local" | ||
docker run --rm -p 5000:5000 -e REGISTRY_STORAGE_DELETE_ENABLED=true -idt "registry:local" | ||
- | ||
name: Run OCI Distribution Spec conformance tests | ||
uses: opencontainers/distribution-spec@main | ||
env: | ||
OCI_ROOT_URL: ${{ env.OCI_ROOT_URL }} | ||
|
@@ -38,3 +37,13 @@ jobs: | |
OCI_TEST_CONTENT_DISCOVERY: 1 | ||
OCI_TEST_CONTENT_MANAGEMENT: 1 | ||
OCI_HIDE_SKIPPED_WORKFLOWS: 1 | ||
- | ||
name: Move test results | ||
run: mkdir -p .out/ && mv {report.html,junit.xml} .out/ | ||
- | ||
name: Upload test results | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: oci-test-results-${{ github.sha }} | ||
path: .out/ | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,28 +12,25 @@ jobs: | |
run-e2e-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: set up docker | ||
uses: docker-practice/[email protected] | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
docker_version: 18.09 | ||
docker_channel: stable | ||
|
||
- name: checkout distribution | ||
uses: actions/checkout@master | ||
fetch-depth: 0 | ||
- | ||
name: Build image | ||
uses: docker/bake-action@v1 | ||
with: | ||
path: main | ||
|
||
- name: start distribution server | ||
targets: image-local | ||
- | ||
name: Start distribution server | ||
run: | | ||
IP=`hostname -I | awk '{print $1}'` | ||
echo "IP=$IP" >> $GITHUB_ENV | ||
echo '{"insecure-registries" : ["'$IP':5000"]}' | sudo tee /etc/docker/daemon.json | ||
sudo service docker restart | ||
DISTRIBUTION_REF="local-distribution:v$(date +%Y%m%d%H%M%S)" | ||
cd ./main | ||
docker build -f ./Dockerfile -t "${DISTRIBUTION_REF}" . | ||
docker run --rm -p 5000:5000 -p 5001:5001 -idt "${DISTRIBUTION_REF}" | ||
- name: script | ||
docker run --rm -p 5000:5000 -p 5001:5001 -idt "registry:local" | ||
- | ||
name: Tests | ||
run: | | ||
bash ./main/tests/push.sh $IP | ||
bash ./tests/push.sh $IP |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
group "default" { | ||
targets = ["image-local"] | ||
} | ||
|
||
// Special target: https://github.com/docker/metadata-action#bake-definition | ||
target "docker-metadata-action" { | ||
tags = ["registry:local"] | ||
} | ||
|
||
target "binary" { | ||
target = "binary" | ||
output = ["./bin"] | ||
} | ||
|
||
target "artifact" { | ||
target = "artifacts" | ||
output = ["./bin"] | ||
} | ||
|
||
target "artifact-all" { | ||
inherits = ["artifact"] | ||
platforms = [ | ||
"darwin/amd64", | ||
"darwin/arm64", | ||
"linux/amd64", | ||
"linux/arm/v5", | ||
"linux/arm/v6", | ||
"linux/arm/v7", | ||
"linux/arm64", | ||
"linux/ppc64le", | ||
"linux/s390x" | ||
] | ||
} | ||
|
||
target "image" { | ||
inherits = ["docker-metadata-action"] | ||
} | ||
|
||
target "image-local" { | ||
inherits = ["image"] | ||
output = ["type=docker"] | ||
} | ||
|
||
target "image-all" { | ||
inherits = ["image"] | ||
platforms = [ | ||
"linux/amd64", | ||
"linux/arm/v6", | ||
"linux/arm/v7", | ||
"linux/arm64", | ||
"linux/ppc64le", | ||
"linux/s390x" | ||
] | ||
} |