-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32b9913
commit a633113
Showing
2 changed files
with
164 additions
and
164 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 |
---|---|---|
@@ -1,170 +1,170 @@ | ||
name: Docker server image build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
flwr-version: | ||
description: "Version of Flower." | ||
required: true | ||
type: string | ||
python-version: | ||
description: "Version of Python e.g. (3.11.0 or 3.11)." | ||
default: "3.11" | ||
required: false | ||
type: string | ||
pip-version: | ||
description: "Version of pip." | ||
required: false | ||
type: string | ||
setuptools-version: | ||
description: "Version of setuptools." | ||
required: false | ||
type: string | ||
ubuntu-version: | ||
description: "Version of Ubuntu." | ||
default: "22.04" | ||
required: false | ||
type: string | ||
secrets: | ||
docker-username: | ||
required: true | ||
docker-user: | ||
required: true | ||
workflow_call: | ||
inputs: | ||
flwr-version: | ||
description: "Version of Flower." | ||
required: true | ||
type: string | ||
python-version: | ||
description: "Version of Python e.g. (3.11.0 or 3.11)." | ||
default: "3.11" | ||
required: false | ||
type: string | ||
pip-version: | ||
description: "Version of pip." | ||
required: false | ||
type: string | ||
setuptools-version: | ||
description: "Version of setuptools." | ||
required: false | ||
type: string | ||
ubuntu-version: | ||
description: "Version of Ubuntu." | ||
default: "22.04" | ||
required: false | ||
type: string | ||
secrets: | ||
dockerhub-user: | ||
required: true | ||
dockerhub-token: | ||
required: true | ||
|
||
env: | ||
REGISTRY_IMAGE: flwr/server | ||
REGISTRY_IMAGE: flwr/server | ||
|
||
# based on https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners | ||
jobs: | ||
parameters: | ||
name: Collect build parameters | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 10 | ||
outputs: | ||
pip-version: ${{ steps.versions.outputs.pip-version }} | ||
setuptools-version: ${{ steps.versions.outputs.setuptools-version }} | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- uses: ./.github/actions/bootstrap | ||
if: inputs.pip-version != '' || inputs.setuptools-version != '' | ||
id: bootstrap | ||
|
||
- id: versions | ||
run: | | ||
if [[ "${{ inputs.pip-version }}" = "" ]]; then | ||
echo "pip-version=${{ steps.bootstrap.outputs.pip-version }}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "pip-version=${{ inputs.pip-version }}" >> "$GITHUB_OUTPUT" | ||
fi | ||
if [[ "${{ inputs.setuptools-version }}" = "" ]]; then | ||
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "setuptools-version=${{ inputs.setuptools-version }}" >> "$GITHUB_OUTPUT" | ||
fi | ||
build: | ||
name: Build server image | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 120 | ||
needs: parameters | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [ | ||
# build-push action and qemu use different platform names | ||
# therefore we create a map | ||
{ qemu: "", docker: "linux/amd64" }, | ||
{ qemu: "arm64", docker: "linux/arm64" }, | ||
] | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Set up QEMU | ||
if: matrix.platform.qemu != '' | ||
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 | ||
with: | ||
platforms: ${{ matrix.platform.qemu }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0 | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
id: build | ||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 | ||
with: | ||
platforms: ${{ matrix.platform.docker }} | ||
context: src/docker/server | ||
build-args: | | ||
PYTHON_VERSION=${{ inputs.python-version }} | ||
PIP_VERSION=${{ needs.parameters.outputs.pip-version }} | ||
SETUPTOOLS_VERSION=${{ needs.parameters.outputs.setuptools-version }} | ||
FLWR_VERSION=${{ inputs.flwr-version }} | ||
UBUNTU_VERSION=${{ inputs.ubuntu-version }} | ||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | ||
|
||
- name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | ||
with: | ||
name: digests | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
build-manifest: | ||
name: Build and push docker manifest for all platforms | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 10 | ||
needs: build | ||
steps: | ||
- name: Download digests | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: digests | ||
path: /tmp/digests | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0 | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
tags: | | ||
${{ inputs.flwr-version }}-py${{ inputs.python-version }}-ubuntu${{ inputs.ubuntu-version }} | ||
${{ inputs.flwr-version }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
run: | | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | ||
- name: Inspect image | ||
run: docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | ||
parameters: | ||
name: Collect build parameters | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 10 | ||
outputs: | ||
pip-version: ${{ steps.versions.outputs.pip-version }} | ||
setuptools-version: ${{ steps.versions.outputs.setuptools-version }} | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- uses: ./.github/actions/bootstrap | ||
if: inputs.pip-version == '' && inputs.setuptools-version == '' | ||
id: bootstrap | ||
|
||
- id: versions | ||
run: | | ||
if [[ "${{ inputs.pip-version }}" = "" ]]; then | ||
echo "pip-version=${{ steps.bootstrap.outputs.pip-version }}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "pip-version=${{ inputs.pip-version }}" >> "$GITHUB_OUTPUT" | ||
fi | ||
if [[ "${{ inputs.setuptools-version }}" = "" ]]; then | ||
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "setuptools-version=${{ inputs.setuptools-version }}" >> "$GITHUB_OUTPUT" | ||
fi | ||
build: | ||
name: Build server image | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 120 | ||
needs: parameters | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [ | ||
# build-push action and qemu use different platform names | ||
# therefore we create a map | ||
{ qemu: "", docker: "linux/amd64" }, | ||
{ qemu: "arm64", docker: "linux/arm64" }, | ||
] | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Set up QEMU | ||
if: matrix.platform.qemu != '' | ||
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 | ||
with: | ||
platforms: ${{ matrix.platform.qemu }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0 | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
username: ${{ secrets.dockerhub-user }} | ||
password: ${{ secrets.dockerhub-token }} | ||
|
||
- name: Build and push | ||
id: build | ||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 | ||
with: | ||
platforms: ${{ matrix.platform.docker }} | ||
context: src/docker/server | ||
build-args: | | ||
PYTHON_VERSION=${{ inputs.python-version }} | ||
PIP_VERSION=${{ needs.parameters.outputs.pip-version }} | ||
SETUPTOOLS_VERSION=${{ needs.parameters.outputs.setuptools-version }} | ||
FLWR_VERSION=${{ inputs.flwr-version }} | ||
UBUNTU_VERSION=${{ inputs.ubuntu-version }} | ||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | ||
|
||
- name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | ||
with: | ||
name: digests | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
build-manifest: | ||
name: Build and push docker manifest for all platforms | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 10 | ||
needs: build | ||
steps: | ||
- name: Download digests | ||
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | ||
with: | ||
name: digests | ||
path: /tmp/digests | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0 | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
tags: | | ||
${{ inputs.flwr-version }}-py${{ inputs.python-version }}-ubuntu${{ inputs.ubuntu-version }} | ||
${{ inputs.flwr-version }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
username: ${{ secrets.dockerhub-user }} | ||
password: ${{ secrets.dockerhub-token }} | ||
|
||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
run: | | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | ||
- name: Inspect image | ||
run: docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
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