tools/docker: Add python targets

This commit is contained in:
Corentin Le Molgat
2022-05-27 18:19:54 +02:00
committed by Mizux Seiha
parent f058079f1a
commit f76a7c5ffb
15 changed files with 248 additions and 2 deletions

View File

@@ -484,6 +484,7 @@ define build_lang_distro =
$$(foreach stage,${LANG_STAGES},$$(eval $$(call build_lang_stage,$1,$2,cpp,$${stage})))
$$(foreach stage,${LANG_STAGES},$$(eval $$(call build_lang_stage,$1,$2,dotnet,$${stage})))
$$(foreach stage,${LANG_STAGES},$$(eval $$(call build_lang_stage,$1,$2,java,$${stage})))
$$(foreach stage,${LANG_STAGES},$$(eval $$(call build_lang_stage,$1,$2,python,$${stage})))
endef
define build_lang_platform =
@@ -554,18 +555,24 @@ $$(foreach stage,${STAGES} export,$$(eval $$(call merge_stage,$1,$${stage})))
$$(foreach stage,${LANG_STAGES} export,$$(eval $$(call merge_stage,$1,cpp_$${stage})))
$$(foreach stage,${LANG_STAGES} export,$$(eval $$(call merge_stage,$1,dotnet_$${stage})))
$$(foreach stage,${LANG_STAGES} export,$$(eval $$(call merge_stage,$1,java_$${stage})))
$$(foreach stage,${LANG_STAGES} export,$$(eval $$(call merge_stage,$1,python_$${stage})))
build_targets := $(addprefix $1_, ${STAGES} export) \
$(addprefix $1_cpp_, ${LANG_STAGES} export) \
$(addprefix $1_dotnet_, ${LANG_STAGES} export) \
$(addprefix $1_java_, ${LANG_STAGES} export)
$(addprefix $1_java_, ${LANG_STAGES} export) \
$(addprefix $1_python_, ${LANG_STAGES} export)
.PHONY: $${build_targets}
$${build_targets}: $1_%: $(addprefix $1_, $(addsuffix _%, ${DISTROS}))
.PHONY: $1_export
$1_export: $1_cpp_export $1_dotnet_export $1_java_export $1_python_export
clean_targets := $(addprefix clean_$1_, ${STAGES} export) \
$(addprefix clean_$1_cpp_, ${LANG_STAGES} export) \
$(addprefix clean_$1_dotnet_, ${LANG_STAGES} export) \
$(addprefix clean_$1_java_, ${LANG_STAGES} export)
$(addprefix clean_$1_java_, ${LANG_STAGES} export) \
$(addprefix clean_$1_python_, ${LANG_STAGES} export)
.PHONY: $${clean_targets}
$${clean_targets}: clean_$1_%: $(addprefix clean_$1_, $(addsuffix _%, ${DISTROS}))

View File

@@ -0,0 +1,20 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/alpine
FROM alpine:edge AS env
#############
## SETUP ##
#############
ENV PATH=/usr/local/bin:$PATH
RUN apk add --no-cache make
# Install Python
RUN apk add --no-cache python3-dev py3-pip py3-wheel py3-numpy
RUN python3 -m pip install absl-py mypy-protobuf
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/bin/sh"]
WORKDIR /root
ADD or-tools_amd64_alpine-edge_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,20 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/archlinux/
FROM archlinux:latest AS env
#############
## SETUP ##
#############
ENV PATH=/usr/local/bin:$PATH
RUN pacman -Syu --noconfirm make
ENTRYPOINT ["/bin/bash", "-c"]
CMD [ "/bin/bash" ]
# Install Python
RUN pacman -Syu --noconfirm python python-pip python-numpy
RUN python -m pip install absl-py mypy-protobuf
WORKDIR /root
ADD or-tools_amd64_alpine-edge_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,21 @@
# ref: https://hub.docker.com/_/centos
FROM centos:7
#############
## SETUP ##
#############
RUN yum -y update \
&& yum -y groupinstall 'Development Tools' \
&& yum clean all \
&& rm -rf /var/cache/yum
# Install Python
RUN yum -y update \
&& yum -y install python3 python3-devel python3-pip numpy \
&& yum clean all \
&& rm -rf /var/cache/yum
WORKDIR /root
ADD or-tools_amd64_centos-7_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,18 @@
# ref: https://quay.io/repository/centos/centos
FROM quay.io/centos/centos:stream8
RUN dnf -y update \
&& dnf -y groupinstall 'Development Tools' \
&& dnf clean all \
&& rm -rf /var/cache/dnf
# Install Python
RUN dnf -y update \
&& dnf -y install python3 python3-devel python3-pip \
&& dnf clean all \
&& rm -rf /var/cache/dnf
WORKDIR /root
ADD or-tools_amd64_centos-8_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,21 @@
# ref: https://hub.docker.com/_/debian
FROM debian:10
RUN apt-get update \
&& apt-get install -y -q build-essential zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/bin/bash"]
# Install CMake 3.21.1
RUN ARCH=$(uname -m) \
&& wget -q "https://cmake.org/files/v3.21/cmake-3.21.1-linux-${ARCH}.sh" \
&& chmod a+x cmake-3.21.1-linux-${ARCH}.sh \
&& ./cmake-3.21.1-linux-${ARCH}.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.21.1-linux-${ARCH}.sh
WORKDIR /root
ADD or-tools_amd64_debian-10_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,21 @@
# ref: https://hub.docker.com/_/debian
FROM debian:11
RUN apt-get update \
&& apt-get install -y -q build-essential zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/bin/bash"]
# Install CMake 3.21.1
RUN ARCH=$(uname -m) \
&& wget -q "https://cmake.org/files/v3.21/cmake-3.21.1-linux-${ARCH}.sh" \
&& chmod a+x cmake-3.21.1-linux-${ARCH}.sh \
&& ./cmake-3.21.1-linux-${ARCH}.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.21.1-linux-${ARCH}.sh
WORKDIR /root
ADD or-tools_amd64_debian-11_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,14 @@
# ref: https://hub.docker.com/_/fedora
FROM fedora:33
RUN dnf -y update \
&& dnf -y install git \
wget which redhat-lsb-core pkgconfig autoconf libtool zlib-devel \
&& dnf -y groupinstall "Development Tools" \
&& dnf -y install gcc-c++ cmake \
&& dnf clean all
WORKDIR /root
ADD or-tools_amd64_fedora-33_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,14 @@
# ref: https://hub.docker.com/_/fedora
FROM fedora:34
RUN dnf -y update \
&& dnf -y install git \
wget which redhat-lsb-core pkgconfig autoconf libtool zlib-devel \
&& dnf -y groupinstall "Development Tools" \
&& dnf -y install gcc-c++ cmake \
&& dnf clean all
WORKDIR /root
ADD or-tools_amd64_fedora-34_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,14 @@
# ref: https://hub.docker.com/_/fedora
FROM fedora:35
RUN dnf -y update \
&& dnf -y install git \
wget which redhat-lsb-core pkgconfig autoconf libtool zlib-devel \
&& dnf -y groupinstall "Development Tools" \
&& dnf -y install gcc-c++ cmake \
&& dnf clean all
WORKDIR /root
ADD or-tools_amd64_fedora-35_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,14 @@
# ref: https://hub.docker.com/_/fedora
FROM fedora:36
RUN dnf -y update \
&& dnf -y install git \
wget which redhat-lsb-core pkgconfig autoconf libtool zlib-devel \
&& dnf -y groupinstall "Development Tools" \
&& dnf -y install gcc-c++ cmake \
&& dnf clean all
WORKDIR /root
ADD or-tools_amd64_fedora-36_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,22 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/r/opensuse/leap
FROM opensuse/leap
# Install system build dependencies
ENV PATH=/usr/local/bin:$PATH
RUN zypper refresh \
&& zypper install -y make \
&& zypper clean -a
ENV CC=gcc-11 CXX=g++-11
ENTRYPOINT ["/usr/bin/bash", "-c"]
CMD ["/usr/bin/bash"]
# Python Install
RUN zypper install -y python3-devel python3-pip python3-wheel \
&& zypper clean -a
RUN python3 -m pip install absl-py mypy-protobuf
WORKDIR /root
ADD or-tools_amd64_opensuse-leap_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,12 @@
# ref: https://hub.docker.com/_/ubuntu
FROM ubuntu:18.04
RUN apt-get update \
&& apt-get install -yq make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /root
ADD or-tools_amd64_ubuntu-18.04_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,15 @@
# ref: https://hub.docker.com/_/ubuntu
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -yq make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["/bin/bash"]
WORKDIR /root
ADD or-tools_amd64_ubuntu-20.04_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test

View File

@@ -0,0 +1,13 @@
# ref: https://hub.docker.com/_/ubuntu
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get install -yq make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /root
ADD or-tools_amd64_ubuntu-22.04_python_v*.tar.gz .
RUN cd or-tools_*_v* && make test