From ea8ac9e982648f90a28edd762c744ab395112374 Mon Sep 17 00:00:00 2001 From: Daniel Nata Nugraha Date: Thu, 16 Nov 2023 09:34:58 +0100 Subject: [PATCH 1/2] Remove existing dockerfiles (#2600) Co-authored-by: Taner Topal --- src/docker/README.md | 6 ------ src/docker/build.sh | 26 -------------------------- src/docker/default.Dockerfile | 8 -------- src/docker/ssh_key | 27 --------------------------- src/docker/ssh_key.pub | 1 - src/docker/sshd.Dockerfile | 32 -------------------------------- 6 files changed, 100 deletions(-) delete mode 100644 src/docker/README.md delete mode 100755 src/docker/build.sh delete mode 100644 src/docker/default.Dockerfile delete mode 100644 src/docker/ssh_key delete mode 100644 src/docker/ssh_key.pub delete mode 100644 src/docker/sshd.Dockerfile diff --git a/src/docker/README.md b/src/docker/README.md deleted file mode 100644 index 0cebf9a6d737..000000000000 --- a/src/docker/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Docker - -We provide two docker images. They can be built using the build.sh script in the ./src/docker directory. -The default image will contain the installed flower library with all dependencies to enable easily -trying out flower. The second image is used in tests as well as local runs of baselines using the -FlowerOps package. diff --git a/src/docker/build.sh b/src/docker/build.sh deleted file mode 100755 index ea6b643c1fb2..000000000000 --- a/src/docker/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Copyright 2020 Flower Labs GmbH. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - -set -e -cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../../ - -HASH=$(printf "$(git rev-parse HEAD)\n$(git diff | sha1sum)" | sha1sum | cut -c1-7) - -rm -rf dist -python -m poetry build -docker build -f src/docker/default.Dockerfile -t flower:latest -t flower:$HASH . -docker build -f src/docker/sshd.Dockerfile --build-arg SSH_PUBLIC_KEY="$(cat docker/ssh_key.pub)" -t flower-sshd:latest -t flower-sshd:$HASH . diff --git a/src/docker/default.Dockerfile b/src/docker/default.Dockerfile deleted file mode 100644 index 0ebd803fbd9c..000000000000 --- a/src/docker/default.Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM python:3.7.15-slim-buster - -# Install the biggest dependencies before copying the wheel -RUN pip install tensorflow-cpu==2.6.2 numpy==1.19.5 - -COPY dist/flwr-1.6.0-py3-none-any.whl flwr-1.6.0-py3-none-any.whl -RUN python3.7 -m pip install --no-cache-dir 'flwr-1.6.0-py3-none-any.whl[examples-pytorch,examples-tensorflow,http-logger,baseline,ops]' -RUN rm flwr-1.6.0-py3-none-any.whl diff --git a/src/docker/ssh_key b/src/docker/ssh_key deleted file mode 100644 index c6fd85ac4bf5..000000000000 --- a/src/docker/ssh_key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAvp7rW7/QCAlXeM/U1QESOKD6aBJkLYLyjzD0A/E+rDz5FBV0 -O9gVhIzIwHYznEV9uWbwJfh5GhE5pb2Om2keERRy56/xoxc2LhMvt4fKf+CKoKYU -fl7QYOHmmT6j4vcZX4Ao0ntHBgX6wk2z2F3Ma1lKmRgh8jHPFVRNHsTLV0WArfWS -zegHsGeRN5aLwWjYZ3RIVzCNXsvDozyf88VUn75E2kwBhtg5OH0y5Rvkvm7oqzxt -u4sNLEdcpIhdTSx8lOGqqaBBP4JcFIA1u8dDqSb3qnhOwW6D2rGloKKMkWCYI0RC -IyXOTFWca/rQKBP9gkd4FSxTMNByF5DSpWm4awIDAQABAoIBAGxK/IrzPcxTAk6w -Q8l/AksJqTjWufLhIcwXk4lp1KElQpwWVCJrcE4NbT9p54gwMmzR/jyUHLiicI2o -UwwXe+1YIK9fVXfCCBXE8K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nXt1PmvS0ih19cY -ckpB+gFPXpgR1GwBi8GEcsWX2aNrYhCMvqD38bI2W8f23xciaSm4wg== ------END RSA PRIVATE KEY----- diff --git a/src/docker/ssh_key.pub b/src/docker/ssh_key.pub deleted file mode 100644 index 302b15494f93..000000000000 --- a/src/docker/ssh_key.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+nutbv9AICVd4z9TVARI4oPpoEmQtgvKPMPQD8T6sPPkUFXQ72BWEjMjAdjOcRX25ZvAl+HkaETmlvY6baR4RFHLnr/GjFzYuEy+3h8p/4IqgphR+XtBg4eaZPqPi9xlfgCjSe0cGBfrCTbPYXcxrWUqZGCHyMc8VVE0exMtXRYCt9ZLN6AewZ5E3lovBaNhndEhXMI1ey8OjPJ/zxVSfvkTaTAGG2Dk4fTLlG+S+buirPG27iw0sR1ykiF1NLHyU4aqpoEE/glwUgDW7x0OpJveqeE7BboPasaWgooyRYJgjREIjJc5MVZxr+tAoE/2CR3gVLFMw0HIXkNKlabhr tanto@R2U2 diff --git a/src/docker/sshd.Dockerfile b/src/docker/sshd.Dockerfile deleted file mode 100644 index fc310dc5e1ce..000000000000 --- a/src/docker/sshd.Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM python:3.7.15-slim-buster - -RUN apt-get update -RUN apt-get install -y openssh-server screen -RUN mkdir /var/run/sshd - -RUN echo 'root:root' | chpasswd - -RUN sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config -RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config - -RUN mkdir /root/.ssh - -ARG SSH_PUBLIC_KEY -RUN echo $SSH_PUBLIC_KEY > /root/.ssh/authorized_keys - -RUN apt-get clean && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -WORKDIR /root - -RUN python3.7 -m pip install tensorflow-cpu==2.6.0 torch==1.7.1 torchvision==0.8.2 numpy==1.19.5 -COPY dist/flwr-1.6.0-py3-none-any.whl flwr-1.6.0-py3-none-any.whl -RUN python3.7 -m pip install --no-cache-dir 'flwr-1.6.0-py3-none-any.whl[examples-pytorch,examples-tensorflow,http-logger,baseline,ops]' && \ - rm flwr-1.6.0-py3-none-any.whl - -RUN python3.7 -m flwr_experimental.baseline.tf_fashion_mnist.download -RUN python3.7 -m flwr_experimental.baseline.tf_cifar.download - -EXPOSE 22 - -CMD ["/usr/sbin/sshd", "-D"] From 7ae14a28c1b7e6751da45aa4a194f8e30ccad6f1 Mon Sep 17 00:00:00 2001 From: Daniel Nata Nugraha Date: Thu, 16 Nov 2023 09:47:23 +0100 Subject: [PATCH 2/2] Add server dockerfile (#2602) Co-authored-by: Taner Topal --- src/docker/server/Dockerfile | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/docker/server/Dockerfile diff --git a/src/docker/server/Dockerfile b/src/docker/server/Dockerfile new file mode 100644 index 000000000000..d294013faefa --- /dev/null +++ b/src/docker/server/Dockerfile @@ -0,0 +1,49 @@ +# Copyright 2023 Flower Labs GmbH. All Rights Reserved. + +FROM ubuntu:22.04 as base + +ENV DEBIAN_FRONTEND noninteractive + +# Install system dependencies +RUN apt-get update \ + && apt-get -y --no-install-recommends install \ + clang-format git unzip ca-certificates openssh-client liblzma-dev \ + build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev wget\ + libsqlite3-dev curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev \ + libxmlsec1-dev libffi-dev liblzma-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install PyEnv and Python +ARG PYTHON_VERSION +ENV PYENV_ROOT /root/.pyenv +ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH +RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash +RUN pyenv install ${PYTHON_VERSION} \ + && pyenv global ${PYTHON_VERSION} \ + && pyenv rehash + +# Install specific version of pip +ARG PIP_VERSION +RUN python -m pip install 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 + +# 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()"] + +# Test if Flower can be successfully installed and imported +FROM server as test +RUN python -c "from flwr.server import run_server"