Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Python 3.10 from deadsnakes PPA #937

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 64 additions & 6 deletions openfl-docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,74 @@

# If your machine is behind a proxy, make sure you set it up in ~/.docker/config.json

FROM ubuntu:22.04
ARG IMAGE_NAME=ubuntu
ARG IMAGE_TAG=22.04

# Base image to be used everywhere
FROM ${IMAGE_NAME}:${IMAGE_TAG} as base
RUN apt-get clean && \
apt-get update && \
apt-get upgrade -y && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

# Python image
FROM base as python-dev

ARG PYTHON=python3.10
ARG PYTHON_VER=3.10.13

RUN apt-get update && \
apt-get install --no-install-recommends --fix-missing -y \
build-essential \
ca-certificates \
curl \
libbz2-dev \
libffi-dev \
libgdbm-dev \
liblzma-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
make \
pkg-config \
zlib1g-dev

RUN curl https://www.python.org/ftp/python/${PYTHON_VER}/Python-${PYTHON_VER}.tar.xz -o /tmp/Python-${PYTHON_VER}.tar.xz && \
cd /tmp/ && \
tar -xf Python-${PYTHON_VER}.tar.xz && \
rm -rf Python-${PYTHON_VER}.tar.xz

RUN cd /tmp/Python-${PYTHON_VER} && \
./configure --enable-optimizations && \
make -s -j${nproc} && \
make altinstall && \
ldconfig /opt/Python${PYTHON_VER}

RUN ln -sf /usr/local/bin/${PYTHON} /usr/local/bin/python && \
ln -sf /usr/local/bin/${PYTHON} /usr/local/bin/python3

FROM base as python-base

ARG PYTHON=python3.10

COPY --from=python-dev /usr/local/lib/${PYTHON} /usr/local/lib/${PYTHON}
COPY --from=python-dev /usr/local/bin/${PYTHON} /usr/local/bin/${PYTHON}
COPY --from=python-dev /usr/local/bin/python3 /usr/local/bin/python3
COPY --from=python-dev /usr/local/bin/python /usr/local/bin/python

FROM python-base as openfl

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG INSTALL_SOURCES="yes"

WORKDIR /zlib
#zlib install to 1.2.13
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing wget build-essential
RUN apt-get update && \
apt-get install -y --no-install-recommends --fix-missing wget build-essential
RUN wget --no-check-certificate https://github.com/madler/zlib/archive/refs/tags/v1.2.13.tar.gz && tar -xvf ./v1.2.13.tar.gz && cd zlib-1.2.13 && ./configure --prefix=/usr && make && make install
RUN rm -rf zlib-1.2.13 && rm -rf v1.2.13.tar.gz
RUN apt-get remove --purge -y wget build-essential && \
Expand All @@ -25,8 +85,6 @@ RUN dpkg --get-selections | grep -v deinstall | awk '{print $1}' > base_packages
RUN apt-get update && \
apt-get install -y --no-install-recommends --fix-missing \
openssh-server=\* \
python3.10=\* \
python3-distutils=\* \
curl=\* \
ca-certificates=\* && \
if [ "$INSTALL_SOURCES" = "yes" ]; then \
Expand All @@ -53,9 +111,9 @@ WORKDIR /openfl
COPY . .

# Install pip
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py && rm -rf get-pip.py
RUN pip install --no-cache-dir .
RUN pip install --no-cache-dir . && \
pip uninstall -y setuptools
psfoley marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /thirdparty
RUN if [ "$INSTALL_SOURCES" = "yes" ]; then \
pip install --no-cache-dir pip-licenses; \
Expand Down
Loading