Skip to content

Commit

Permalink
update server image build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Steiner committed Dec 6, 2023
1 parent 1fb648c commit 684ee32
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/_docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Reusable docker server image build workflow
on:
workflow_call:
inputs:
namespace_repository:
namespace-repository:
description: "The namespace and repository in the following format `namespace/repository` e.g. (flwr/base)."
required: true
type: string
file:
description: "Path to the Dockerfile."
file-dir:
description: "Path of the directory that contains the Dockerfile."
required: true
type: string
build-args:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
with:
images: ${{ inputs.namespace_repository }}
images: ${{ inputs.namespace-repository }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
Expand All @@ -74,9 +74,9 @@ jobs:
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
platforms: ${{ matrix.platform.docker }}
context: "{{defaultContext}}:${{ inputs.file }}"
context: "{{defaultContext}}:${{ inputs.file-dir }}"
build-args: ${{ inputs.build-args }}
outputs: type=image,name=${{ inputs.namespace_repository }},push-by-digest=true,name-canonical=true,push=true
outputs: type=image,name=${{ inputs.namespace-repository }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
id: meta
uses: docker/metadata-action@31cebacef4805868f9ce9a0cb03ee36c32df2ac4 # v5.3.0
with:
images: ${{ inputs.namespace_repository }}
images: ${{ inputs.namespace-repository }}
tags: ${{ inputs.tags }}

- name: Set up Docker Buildx
Expand All @@ -126,6 +126,6 @@ jobs:
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ inputs.namespace_repository }}@sha256:%s ' *)
$(printf '${{ inputs.namespace-repository }}@sha256:%s ' *)
- name: Inspect image
run: docker buildx imagetools inspect ${{ inputs.namespace_repository }}:${{ steps.meta.outputs.version }}
run: docker buildx imagetools inspect ${{ inputs.namespace-repository }}:${{ steps.meta.outputs.version }}
12 changes: 7 additions & 5 deletions .github/workflows/docker-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build docker base image

on:
push:
# paths:
# - src/docker/base
branches: ["main"]
paths: ["src/docker/base/**"]

permissions:
contents: read
Expand Down Expand Up @@ -33,15 +33,17 @@ jobs:
echo "setuptools-version=${{ steps.bootstrap.outputs.setuptools-version }}" >> "$GITHUB_OUTPUT"
echo "ubuntu-version=${{ env.DEFAULT_UBUNTU }}" >> "$GITHUB_OUTPUT"
build-server-images:
build-base-images:
name: Build images
uses: ./.github/workflows/_docker-build.yml
needs: parameters
strategy:
fail-fast: true
matrix:
python-version: [3.11]
with:
namespace_repository: flwr/base
file: src/docker/base
namespace-repository: flwr/base
file-dir: src/docker/base
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
PIP_VERSION=${{ needs.parameters.outputs.pip-version }}
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/docker-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ on:
required: true
type: string
base-image-version:
description: "Version of Flower base image."
description: "Version of the Flower base image."
required: false
type: string
default: "22.04"
default: "py3.11-ubuntu22.04"

permissions:
contents: read

jobs:
build-server-images:
name: Build images
uses: ./.github/workflows/_docker-build.yml
with:
namespace_repository: flwr/server
file: src/docker/server
namespace-repository: flwr/server
file-dir: src/docker/server
build-args: |
FLWR_VERSION=${{ github.event.inputs.flwr-version }}
BASE_IMAGE_VERSION=${{ github.event.inputs.base-image-version }}
Expand All @@ -34,8 +35,10 @@ jobs:
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}

summary:
name: Summary
runs-on: ubuntu-22.04
needs: build-server-images
timeout-minutes: 5
steps:
- run: |
echo "### Images" >> $GITHUB_STEP_SUMMARY
Expand Down
6 changes: 3 additions & 3 deletions src/docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright 2023 Flower Labs GmbH. All Rights Reserved.

ARG BASE_IMAGE_VERSION=22.04
FROM flwr/base:$BASE_IMAGE_VERSION
ARG BASE_IMAGE_VERSION=py3.11-ubuntu22.04
FROM flwr/base:$BASE_IMAGE_VERSION as server

WORKDIR /app
ARG FLWR_VERSION
RUN python -m pip install -U --no-cache-dir flwr[rest]==${FLWR_VERSION}
ENTRYPOINT ["python", "-c", "from flwr.server import run_server; run_server()"]

# Test if Flower can be successfully installed and imported
FROM flwr/base:$BASE_VERSION
FROM server as test
RUN python -c "from flwr.server import run_server"

0 comments on commit 684ee32

Please sign in to comment.