Files
ortools-clone/tools/docker/alpine.Dockerfile
2020-12-02 15:11:48 +01:00

47 lines
1.3 KiB
Docker

# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/alpine
FROM alpine:edge AS env
LABEL maintainer="corentinl@google.com"
# Install system build dependencies
ENV PATH=/usr/local/bin:$PATH
RUN apk add --no-cache git build-base linux-headers cmake xfce4-dev-tools
# SWIG
RUN apk add --no-cache swig
# Python
RUN apk add --no-cache python3-dev py3-pip py3-wheel
RUN python3 -m pip install absl-py mypy-protobuf
################
## OR-TOOLS ##
################
FROM env AS devel
ARG SRC_GIT_BRANCH
ENV SRC_GIT_BRANCH ${SRC_GIT_BRANCH:-master}
ARG SRC_GIT_SHA1
ENV SRC_GIT_SHA1 ${SRC_GIT_SHA1:-unknown}
# Download sources
# use SRC_GIT_SHA1 to modify the command
# i.e. avoid docker reusing the cache when new commit is pushed
WORKDIR /root
RUN git clone -b "${SRC_GIT_BRANCH}" --single-branch https://github.com/google/or-tools \
&& echo "sha1: $(cd or-tools && git rev-parse --verify HEAD)" \
&& echo "expected sha1: ${SRC_GIT_SHA1}"
# Build third parties
FROM devel AS third_party
WORKDIR /root/or-tools
RUN make detect && make third_party
# Build project
FROM third_party AS build
RUN make detect_cc && make cc
RUN make detect_python && make package_python
# Rename wheel package ortools-version+musl-....
RUN cp temp_python*/ortools/dist/*.whl .
RUN NAME=$(ls *.whl | sed -e "s/\(ortools-[0-9\.]\+\)/\1+musl/") \
&& mv *.whl "${NAME}"