Skip to content

Commit

Permalink
create base images ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Steiner committed Dec 6, 2023
1 parent 8604512 commit 1fb648c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 107 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/_docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ jobs:
# build-push action and qemu use different platform names
# therefore we create a map
{ qemu: "", docker: "linux/amd64" },
# { qemu: "arm64", docker: "linux/arm64" },
{ 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
Expand All @@ -76,7 +74,7 @@ jobs:
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
platforms: ${{ matrix.platform.docker }}
context: ${{ inputs.file }}
context: "{{defaultContext}}:${{ inputs.file }}"
build-args: ${{ inputs.build-args }}
outputs: type=image,name=${{ inputs.namespace_repository }},push-by-digest=true,name-canonical=true,push=true

Expand Down
68 changes: 18 additions & 50 deletions .github/workflows/docker-base.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
name: Build docker base image

on:
workflow_dispatch:
inputs:
python-version:
description: "Version of Python e.g. (3.11.7 or 3.11)"
required: false
type: string
default: "3.11"
pip-version:
description: "Version of pip. Defaults to the version defined in actions/bootstrap."
required: false
type: string
setuptools-version:
description: "Version of setuptools. Defaults to the version defined in actions/bootstrap."
required: false
type: string
ubuntu-version:
description: "Version of Ubuntu. Defaults to the version defined in _docker-server.yaml."
required: false
type: string
default: "22.04"
push:
# paths:
# - src/docker/base

permissions:
contents: read

env:
DEFAULT_UBUNTU: 22.04

jobs:
parameters:
name: Collect build parameters
Expand All @@ -33,53 +19,35 @@ jobs:
outputs:
pip-version: ${{ steps.versions.outputs.pip-version }}
setuptools-version: ${{ steps.versions.outputs.setuptools-version }}
ubuntu-version: ${{ steps.versions.outputs.ubuntu-version }}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: ./.github/actions/bootstrap
if: ${{ !(github.event.inputs.pip-version != '' && github.event.inputs.setuptools-version != '') }}
id: bootstrap

- id: versions
run: |
if [[ "${{ github.event.inputs.pip-version }}" = "" ]]; then
echo "pip-version=${{ steps.bootstrap.outputs.pip-version }}" >> "$GITHUB_OUTPUT"
else
echo "pip-version=${{ github.event.inputs.pip-version }}" >> "$GITHUB_OUTPUT"
fi
if [[ "${{ github.event.inputs.setuptools-version }}" = "" ]]; then
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
else
echo "setuptools-version=${{ github.event.inputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
fi
echo "pip-version=${{ steps.bootstrap.outputs.pip-version }}" >> "$GITHUB_OUTPUT"
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
echo "ubuntu-version=${{ env.DEFAULT_UBUNTU }}" >> "$GITHUB_OUTPUT"
build-server-images:
uses: ./.github/workflows/_docker-server.yml
uses: ./.github/workflows/_docker-build.yml
needs: parameters
strategy:
matrix:
python-version: [3.11]
with:
namespace_repository: flwr/base
file: src/docker/server
file: src/docker/base
build-args: |
PYTHON_VERSION=${{ github.event.inputs.python-version }}
PYTHON_VERSION=${{ matrix.python-version }}
PIP_VERSION=${{ needs.parameters.outputs.pip-version }}
SETUPTOOLS_VERSION=${{ needs.parameters.outputs.setuptools-version }}
UBUNTU_VERSION=${{ github.event.inputs.ubuntu-version }}
tags: |
py${{ github.event.inputs.python-version }}-ubuntu${{ github.event.inputs.ubuntu-version }}
test
UBUNTU_VERSION=${{ needs.parameters.outputs.ubuntu-version }}
tags: py${{ matrix.python-version }}-ubuntu${{ needs.parameters.outputs.ubuntu-version }}
secrets:
dockerhub-user: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}

summary:
runs-on: ubuntu-22.04
needs: build-server-images
steps:
- run: |
echo "### Images" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
for IMAGE in $(echo ${{ toJson(needs.build-server-images.outputs.metadata) }} | jq -r '.tags[]' ); do
echo "- $IMAGE" >> $GITHUB_STEP_SUMMARY
done
57 changes: 6 additions & 51 deletions .github/workflows/docker-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,8 @@ on:
description: "Version of Flower e.g. (1.6.0)."
required: true
type: string
python-version:
description: "Version of Python e.g. (3.11.7 or 3.11)"
required: false
type: string
default: "3.11"
pip-version:
description: "Version of pip. Defaults to the version defined in actions/bootstrap."
required: false
type: string
setuptools-version:
description: "Version of setuptools. Defaults to the version defined in actions/bootstrap."
required: false
type: string
ubuntu-version:
description: "Version of Ubuntu. Defaults to the version defined in _docker-server.yaml."
base-image-version:
description: "Version of Flower base image."
required: false
type: string
default: "22.04"
Expand All @@ -30,50 +17,18 @@ permissions:
contents: read

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: ${{ !(github.event.inputs.pip-version != '' && github.event.inputs.setuptools-version != '') }}
id: bootstrap

- id: versions
run: |
if [[ "${{ github.event.inputs.pip-version }}" = "" ]]; then
echo "pip-version=${{ steps.bootstrap.outputs.pip-version }}" >> "$GITHUB_OUTPUT"
else
echo "pip-version=${{ github.event.inputs.pip-version }}" >> "$GITHUB_OUTPUT"
fi
if [[ "${{ github.event.inputs.setuptools-version }}" = "" ]]; then
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
else
echo "setuptools-version=${{ github.event.inputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
fi
build-server-images:
uses: ./.github/workflows/_docker-server.yml
needs: parameters
uses: ./.github/workflows/_docker-build.yml
with:
namespace_repository: flwr/server
file: src/docker/server
build-args: |
PYTHON_VERSION=${{ github.event.inputs.python-version }}
PIP_VERSION=${{ needs.parameters.outputs.pip-version }}
SETUPTOOLS_VERSION=${{ needs.parameters.outputs.setuptools-version }}
FLWR_VERSION=${{ github.event.inputs.flwr-version }}
UBUNTU_VERSION=${{ github.event.inputs.ubuntu-version }}
BASE_IMAGE_VERSION=${{ github.event.inputs.base-image-version }}
tags: |
${{ github.event.inputs.flwr-version }}-py${{ github.event.inputs.python-version }}-ubuntu${{ github.event.inputs.ubuntu-version }}
${{ github.event.inputs.flwr-version }}-${{ github.event.inputs.base-image-version }}
${{ github.event.inputs.flwr-version }}
latest
secrets:
dockerhub-user: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions src/docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 Flower Labs GmbH. All Rights Reserved.

ARG BASE_VERSION=22.04
FROM flwr/base:$BASE_VERSION
ARG BASE_IMAGE_VERSION=22.04
FROM flwr/base:$BASE_IMAGE_VERSION

WORKDIR /app
ARG FLWR_VERSION
Expand Down

0 comments on commit 1fb648c

Please sign in to comment.