From 9d182cebbb2ca6acacd3cac7a16e9657de7506b1 Mon Sep 17 00:00:00 2001 From: Robert Steiner Date: Mon, 4 Dec 2023 14:00:18 +0100 Subject: [PATCH 1/2] Small improvements to the current Docker image (#2680) --- src/docker/server/Dockerfile | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/docker/server/Dockerfile b/src/docker/server/Dockerfile index d294013faefa..37f1ea91f33c 100644 --- a/src/docker/server/Dockerfile +++ b/src/docker/server/Dockerfile @@ -1,8 +1,20 @@ # Copyright 2023 Flower Labs GmbH. All Rights Reserved. -FROM ubuntu:22.04 as base +ARG UBUNTU_VERSION=22.04 +FROM ubuntu:$UBUNTU_VERSION as base ENV DEBIAN_FRONTEND noninteractive +# Send stdout and stderr stream directly to the terminal. Ensures that no +# output is retained in a buffer if the application crashes. +ENV PYTHONUNBUFFERED 1 +# Typically, bytecode is created on the first invocation to speed up following invocation. +# However, in Docker we only make a single invocation (when we start the container). +# Therefore, we can disable bytecode writing. +ENV PYTHONDONTWRITEBYTECODE 1 +# Ensure that python encoding is always UTF-8. +ENV PYTHONIOENCODING UTF-8 +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 # Install system dependencies RUN apt-get update \ @@ -17,6 +29,8 @@ RUN apt-get update \ ARG PYTHON_VERSION ENV PYENV_ROOT /root/.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH +# https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash RUN pyenv install ${PYTHON_VERSION} \ && pyenv global ${PYTHON_VERSION} \ @@ -24,25 +38,19 @@ RUN pyenv install ${PYTHON_VERSION} \ # Install specific version of pip ARG PIP_VERSION -RUN python -m pip install pip==$PIP_VERSION +RUN python -m pip install --no-cache-dir pip==$PIP_VERSION # Install specific version of setuptools ARG SETUPTOOLS_VERSION -RUN python -m pip install setuptools==$SETUPTOOLS_VERSION - -# Install poetry as all examples use it and therefore it should be available for custom images -ARG POETRY_VERSION -RUN curl -sSL https://install.python-poetry.org | python3 - --version ${POETRY_VERSION} -ENV PATH /root/.local/bin:$PATH -RUN poetry config virtualenvs.create false +RUN python -m pip install --no-cache-dir setuptools==$SETUPTOOLS_VERSION # Server image FROM base as server WORKDIR /app ARG FLWR_VERSION -RUN python -m pip install -U flwr[rest]==${FLWR_VERSION} -ENTRYPOINT ["python", "-c", "from flwr.server import run_server\nrun_server()"] +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 server as test From f10e3858a27aa1dcf4fcf2bef95db3be830eaafd Mon Sep 17 00:00:00 2001 From: Robert Steiner Date: Mon, 4 Dec 2023 14:38:28 +0100 Subject: [PATCH 2/2] Fix RST links (#2676) --- datasets/doc/source/how-to-use-with-tensorflow.rst | 2 +- ...butor-how-to-develop-in-vscode-dev-containers.rst | 2 +- .../contributor-how-to-write-documentation.rst | 2 +- ...ributor-tutorial-get-started-as-a-contributor.rst | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/datasets/doc/source/how-to-use-with-tensorflow.rst b/datasets/doc/source/how-to-use-with-tensorflow.rst index a63145d9dffa..3dc8474b726a 100644 --- a/datasets/doc/source/how-to-use-with-tensorflow.rst +++ b/datasets/doc/source/how-to-use-with-tensorflow.rst @@ -25,7 +25,7 @@ In case of CIFAR10, you should see the following output. 'label': ClassLabel(names=['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck'], id=None)} -We will use the keys in the partition features in order to construct a `tf.data.Dataset _`. Let's move to the transformations. +We will use the keys in the partition features in order to construct a `tf.data.Dataset `_. Let's move to the transformations. NumPy ----- diff --git a/doc/source/contributor-how-to-develop-in-vscode-dev-containers.rst b/doc/source/contributor-how-to-develop-in-vscode-dev-containers.rst index d9a4cf6b7c82..19d46c5753c6 100644 --- a/doc/source/contributor-how-to-develop-in-vscode-dev-containers.rst +++ b/doc/source/contributor-how-to-develop-in-vscode-dev-containers.rst @@ -14,7 +14,7 @@ Source: `Official VSCode documentation `_. +Configuring and setting up the :code:`Dockerfile` as well the configuration for the devcontainer can be a bit more involved. The good thing is you don't have to do it. Usually it should be enough to install `Docker `_ on your system and ensure its available on your command line. Additionally, install the `VSCode Containers Extension `_. Now you should be good to go. When starting VSCode, it will ask you to run in the container environment and - if you confirm - automatically build the container and use it. To manually instruct VSCode to use the devcontainer, you can, after installing the extension, click the green area in the bottom left corner of your VSCode window and select the option *(Re)Open Folder in Container*. diff --git a/doc/source/contributor-how-to-write-documentation.rst b/doc/source/contributor-how-to-write-documentation.rst index 232c37f06e1b..fcd8c5bb18c6 100644 --- a/doc/source/contributor-how-to-write-documentation.rst +++ b/doc/source/contributor-how-to-write-documentation.rst @@ -7,7 +7,7 @@ Project layout The Flower documentation lives in the ``doc`` directory. The Sphinx-based documentation system supports both reStructuredText (``.rst`` files) and Markdown (``.md`` files). -Note that, in order to build the documentation locally (with ``poetry run make html``, like described below), `Pandoc _` needs to be installed on the system. +Note that, in order to build the documentation locally (with ``poetry run make html``, like described below), `Pandoc `_ needs to be installed on the system. Edit an existing page diff --git a/doc/source/contributor-tutorial-get-started-as-a-contributor.rst b/doc/source/contributor-tutorial-get-started-as-a-contributor.rst index 3fdb52b5ddb1..e035d1b9867d 100644 --- a/doc/source/contributor-tutorial-get-started-as-a-contributor.rst +++ b/doc/source/contributor-tutorial-get-started-as-a-contributor.rst @@ -30,8 +30,8 @@ but you can change it by providing a specific :code:``):: $ ./dev/venv-create.sh -If you don't have :code:`pyenv` installed, -you can use the following script that will install pyenv, +If you don't have :code:`pyenv` installed, +you can use the following script that will install pyenv, set it up and create the virtual environment (with :code:`Python 3.8.17` by default):: $ ./dev/setup-defaults.sh @@ -83,7 +83,7 @@ Run Github Actions (CI) locally ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Developers could run the full set of Github Actions workflows under their local -environment by using `Act _`. Please refer to +environment by using `Act `_. Please refer to the installation instructions under the linked repository and run the next command under Flower main cloned repository folder:: @@ -116,6 +116,6 @@ convenience script to re-build the documentation yet, but it's pretty easy:: This will generate HTML documentation in ``doc/build/html``. -Note that, in order to build the documentation locally -(with ``poetry run make html``, like described below), -`Pandoc _` needs to be installed on the system. +Note that, in order to build the documentation locally +(with ``poetry run make html``, like described below), +`Pandoc `_ needs to be installed on the system.