ci: rework CMake Docker/Makefile

This commit is contained in:
Corentin Le Molgat
2020-02-25 11:26:59 +01:00
parent 4c7456b175
commit 91e3670214
15 changed files with 1246 additions and 161 deletions

50
.dockerignore Normal file
View File

@@ -0,0 +1,50 @@
# Project Files unneeded by docker
.dockerignore
ci/cache
ci/docker
ci/Makefile
.git
.gitignore
.travis.yml
.appveyor.yml
.github
.clang-format
binder
tools
cmake/cache
cmake/docker
cmake/Makefile
makefiles
Makefile
Makefile.local
bazel
WORKSPACE
docs
Dependencies.txt
README.md
CONTRIBUTING.md
LICENSE-2.0.txt
# Native cmake build
classes
dependencies
objs
lib
bin
packages
build/
examples/data
# Editor directories and files
*.user
*.swp

View File

@@ -1,143 +1,342 @@
PROJECT := ortools
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
SHA1 := $(shell git rev-parse --verify HEAD)
# General commands
.PHONY: help
BOLD=\e[1m
RESET=\e[0m
help:
@echo "usage:"
@echo "make docker: generate docker images"
@echo "make configure: cmake configure"
@echo "make build: cmake build"
@echo "make test: run unit tests"
@echo "make install: cmake install"
@echo "make test_install: configure a sample project against an installation"
@echo "make clean: call cmake \"make clean\""
@echo "make distclean: clean and also remove all docker images"
@echo -e "${BOLD}SYNOPSIS${RESET}"
@echo -e "\tmake <target> [NOCACHE=1]"
@echo
@echo -e "${BOLD}DESCRIPTION${RESET}"
@echo -e "\ttest build inside docker container to have a reproductible build."
@echo
@echo -e "${BOLD}MAKE TARGETS${RESET}"
@echo -e "\t${BOLD}help${RESET}: display this help and exit."
@echo
@echo -e "\t${BOLD}env${RESET}: build a virtual env image."
@echo -e "\t${BOLD}sh_env_<distro>${RESET}: run a container using the virtual env image (debug purpose)."
@echo
@echo -e "\t${BOLD}devel${RESET}: build the library for all LANGUAGES and all DISTROS."
@echo -e "\t${BOLD}devel_<distro>${RESET}: build the library for all LANGUAGES using a specific distro."
@echo -e "\t${BOLD}devel_<lang>${RESET}: build the library for all DISTROS using a specific language."
@echo -e "\t${BOLD}devel_<distro>_<lang>${RESET}: build the library using a specific distro and language."
@echo
@echo -e "\t${BOLD}test_<distro>${RESET}: auto test using the devel image."
@echo -e "\t${BOLD}test_<distro>_<lang>${RESET}: auto test using the devel image."
@echo -e "\t${BOLD}sh_<distro>_<lang>${RESET}: run a container using the devel image (debug purpose)."
@echo
@echo -e "\t${BOLD}install${RESET}: execute the cmake target ${BOLD}install${RESET} using all devel image container, then create an install image with it."
@echo -e "\t${BOLD}install_<distro>${RESET}: execute the cmake target ${BOLD}install${RESET} using the devel image container specified, then create an install image with it."
@echo -e "\t${BOLD}test_install${RESET}: configure, build, install then test a sample project against it using all ${BOLD}install${RESET} image containers."
@echo -e "\t${BOLD}test_install_<distro>${RESET}: configure, build, install then test a sample project against it using the ${BOLD}install${RESET} image container specified."
@echo -e "\t${BOLD}sh_install_<distro>_<lang>${RESET}: run a container using the install image (debug purpose)."
@echo
@echo -e "\t${BOLD}clean${RESET}: Remove cache and docker image."
@echo -e "\t${BOLD}clean_<distro>${RESET}: Remove cache and docker image for the specified distro."
@echo
@echo -e "\t${BOLD}<lang>${RESET}:"
@echo -e "\t\t${BOLD}cpp${RESET} (C++)"
@echo -e "\t\t${BOLD}python${RESET} (Python >= 3)"
@echo -e "\t\t${BOLD}java${RESET} (Java >= 8)"
@echo -e "\t\t${BOLD}dotnet${RESET} (.Net Core >= 2.1)"
@echo -e "\te.g. 'make devel_cpp'"
@echo
@echo -e "\t${BOLD}<distro>${RESET}:"
@echo -e "\t\t${BOLD}alpine${RESET} (latest)"
@echo -e "\t\t${BOLD}archlinux${RESET} (latest)"
@echo -e "\t\t${BOLD}centos${RESET} (latest)"
@echo -e "\t\t${BOLD}debian${RESET} (latest)"
@echo -e "\t\t${BOLD}fedora${RESET} (latest)"
@echo -e "\t\t${BOLD}opensuse${RESET} (tumbleweed)"
@echo -e "\t\t${BOLD}ubuntu${RESET} (latest)"
@echo -e "\te.g. 'make devel_alpine'"
@echo
@echo -e "\tYou can also mix both using: ${BOLD}<distro>_<lang>${RESET}"
@echo -e "\te.g. 'make devel_alpine_cpp'"
@echo
@echo -e "\t${BOLD}NOCACHE=1${RESET}: use 'docker build --no-cache' when building container (default use cache)."
@echo
@echo -e "branch: $(BRANCH)"
@echo -e "sha1: $(SHA1)"
# Need to add cmd_distro to PHONY otherwise target are ignored since they don't
# contain recipe (using FORCE don't work here)
.PHONY: help all
all: build
# Need to add cmd_distro to PHONY otherwise target are ignored since they do not
# contain recipe (using FORCE do not work here)
.PHONY: all
all: devel
IMAGE := ortools
#UID := $(shell id -u)
#GID := $(shell id -g)
#DOCKER_DEVEL_CMD := docker run --rm -it -v ${PWD}:/project -w /project --user ${UID}:${GID}
DOCKER_DEVEL_CMD := docker run --rm -it -v ${PWD}:/project -w /project
DOCKER_INSTALL_CMD := docker run --rm -it -v ${PWD}/cmake/sample:/project -w /project
# Delete all implicit rules to speed up makefile
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
# Keep all intermediate files
# ToDo: try to remove it later
.SECONDARY:
# Docker image name prefix.
IMAGE := ${PROJECT}
ifdef NOCACHE
DOCKER_BUILD_CMD := docker build --no-cache
else
DOCKER_BUILD_CMD := docker build
endif
DOCKER_RUN_CMD := docker run --rm --init --net=host
# Currently supported distro
DISTROS = alpine archlinux centos debian fedora opensuse ubuntu
LANGUAGES = cpp python java dotnet
# $* stem
# $< first prerequist
# $@ target name
# DOCKER
.PHONY: docker docker_alpine docker_ubuntu
docker: docker_alpine docker_ubuntu
docker_alpine: cache/alpine/docker_devel.tar
docker_ubuntu: cache/ubuntu/docker_devel.tar
cache/%/docker_devel.tar: cmake/docker/%/Dockerfile cmake/docker/%/setup.sh
# ENV
targets = $(addprefix env_, $(DISTROS))
.PHONY: env $(targets)
env: $(targets)
$(targets): env_%: cache/%/docker_env.tar
cache/%/docker_env.tar: docker/%/Dockerfile
@docker image rm -f ${IMAGE}:$*_env 2>/dev/null
${DOCKER_BUILD_CMD} --target=env --tag ${IMAGE}:$*_env -f $< docker/$*
@rm -f $@
mkdir -p cache/$*
@docker image rm -f ${IMAGE}_$*:devel 2>/dev/null
docker build --no-cache -t ${IMAGE}_$*:devel -f $< cmake/docker/$*
docker save ${IMAGE}_$*:devel -o $@
docker save ${IMAGE}:$*_env -o $@
# DOCKER BASH
.PHONY: bash_alpine bash_ubuntu
bash_alpine: cache/alpine/docker_devel.tar
${DOCKER_DEVEL_CMD} ${IMAGE}_alpine:devel /bin/sh
bash_ubuntu: cache/ubuntu/docker_devel.tar
${DOCKER_DEVEL_CMD} ${IMAGE}_ubuntu:devel /bin/bash
# Run a container using the env image.
targets = $(addprefix sh_env_, $(DISTROS))
.PHONY: $(targets)
$(targets): sh_env_%: cache/%/docker_env.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$* ${IMAGE}:$*_env /bin/sh
# CONFIGURE
.PHONY: configure configure_alpine configure_ubuntu
configure: configure_alpine configure_ubuntu
configure_alpine: cache/alpine/configure.log
configure_ubuntu: cache/ubuntu/configure.log
cache/%/configure.log: cache/%/docker_devel.tar \
CMakeLists.txt cmake/external/CMakeLists.txt ortools/*/CMakeLists.txt \
cmake/*.cmake cmake/*Config.cmake.in patches
@docker load -i $<
${DOCKER_DEVEL_CMD} ${IMAGE}_$*:devel /bin/sh -c \
"cmake -H. -Bcache/$*"
@date > $@
# DEVEL
.PHONY: devel
devel: $(addprefix devel_, $(DISTROS))
# BUILD
.PHONY: build build_alpine build_ubuntu
build: build_alpine build_ubuntu
build_alpine: cache/alpine/build.log
build_ubuntu: cache/ubuntu/build.log
cache/%/build.log: cache/%/configure.log ortools examples
${DOCKER_DEVEL_CMD} ${IMAGE}_$*:devel /bin/sh -c \
"cmake --build cache/$* --target all"
@date > $@
distro_targets = $(addprefix devel_, $(DISTROS))
.PHONY: $(distro_targets)
$(distro_targets): devel_%: $(addprefix devel_%_, $(LANGUAGES))
# TEST
.PHONY: test test_alpine test_ubuntu
test: test_alpine test_ubuntu
test_alpine: cache/alpine/test.log
test_ubuntu: cache/ubuntu/test.log
cache/%/test.log: cache/%/build.log
${DOCKER_DEVEL_CMD} ${IMAGE}_$*:devel /bin/sh -c \
"cmake --build cache/$* --target test -- CTEST_OUTPUT_ON_FAILURE=1"
@date > $@
lang_targets = $(addprefix devel_, $(LANGUAGES))
.PHONY: $(lang_targets)
$(lang_targets): devel_%: $(addsuffix _%, $(addprefix devel_, $(DISTROS)))
distro_cpp_targets = $(addprefix devel_, $(addsuffix _cpp, $(DISTROS)))
distro_python_targets = $(addprefix devel_, $(addsuffix _python, $(DISTROS)))
distro_java_targets = $(addprefix devel_, $(addsuffix _java, $(DISTROS)))
distro_dotnet_targets = $(addprefix devel_, $(addsuffix _dotnet, $(DISTROS)))
.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets)
$(distro_cpp_targets): devel_%_cpp: cache/%/docker_cpp.tar
$(distro_python_targets): devel_%_python: cache/%/docker_python.tar
$(distro_java_targets): devel_%_java: cache/%/docker_java.tar
$(distro_dotnet_targets): devel_%_dotnet: cache/%/docker_dotnet.tar
cache/%/docker_cpp.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake
@echo building $@...
@docker image rm -f ${IMAGE}:$*_cpp 2>/dev/null
${DOCKER_BUILD_CMD} --target=cpp --tag ${IMAGE}:$*_cpp -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_cpp -o $@
cache/%/docker_python.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake
@echo building $@...
@docker image rm -f ${IMAGE}:$*_python 2>/dev/null
${DOCKER_BUILD_CMD} --target=python --tag ${IMAGE}:$*_python -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_python -o $@
cache/%/docker_java.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake
@echo building $@...
@docker image rm -f ${IMAGE}:$*_java 2>/dev/null
${DOCKER_BUILD_CMD} --target=java --tag ${IMAGE}:$*_java -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_java -o $@
cache/%/docker_dotnet.tar: docker/%/Dockerfile ../CMakeLists.txt ../cmake
@echo building $@...
@docker image rm -f ${IMAGE}:$*_dotnet 2>/dev/null
${DOCKER_BUILD_CMD} --target=dotnet --tag ${IMAGE}:$*_dotnet -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_dotnet -o $@
# DOCKER BASH INSTALL (debug)
distro_cpp_targets = $(addprefix sh_, $(addsuffix _cpp, $(DISTROS)))
distro_python_targets = $(addprefix sh_, $(addsuffix _python, $(DISTROS)))
distro_java_targets = $(addprefix sh_, $(addsuffix _java, $(DISTROS)))
distro_dotnet_targets = $(addprefix sh_, $(addsuffix _dotnet, $(DISTROS)))
.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets)
$(distro_cpp_targets): sh_%_cpp: cache/%/docker_cpp.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_cpp ${IMAGE}:$*_cpp /bin/sh
$(distro_python_targets): sh_%_python: cache/%/docker_python.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_python ${IMAGE}:$*_python /bin/sh
$(distro_java_targets): sh_%_java: cache/%/docker_java.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_java ${IMAGE}:$*_java /bin/sh
$(distro_dotnet_targets): sh_%_dotnet: cache/%/docker_dotnet.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_dotnet ${IMAGE}:$*_dotnet /bin/sh
# TEST DEVEL
.PHONY: test
test: $(addprefix test_, $(DISTROS))
distro_targets = $(addprefix test_, $(DISTROS))
.PHONY: $(distro_targets)
$(distro_targets): test_%: $(addprefix test_%_, $(LANGUAGES))
lang_targets = $(addprefix test_, $(LANGUAGES))
.PHONY: $(lang_targets)
$(lang_targets): test_%: $(addsuffix _%, $(addprefix test_, $(DISTROS)))
distro_cpp_targets = $(addprefix test_, $(addsuffix _cpp, $(DISTROS)))
distro_python_targets = $(addprefix test_, $(addsuffix _python, $(DISTROS)))
distro_java_targets = $(addprefix test_, $(addsuffix _java, $(DISTROS)))
distro_dotnet_targets = $(addprefix test_, $(addsuffix _dotnet, $(DISTROS)))
.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets)
$(distro_cpp_targets): test_%_cpp: cache/%/docker_cpp.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_cpp ${IMAGE}:$*_cpp cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1
$(distro_python_targets): test_%_python: cache/%/docker_python.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_python ${IMAGE}:$*_python cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1
$(distro_java_targets): test_%_java: cache/%/docker_java.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_java ${IMAGE}:$*_java cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1
$(distro_dotnet_targets): test_%_dotnet: cache/%/docker_dotnet.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_dotnet ${IMAGE}:$*_dotnet cmake --build build --target test -- CTEST_OUTPUT_ON_FAILURE=1
# INSTALL
.PHONY: install install_alpine install_ubuntu
install: install_alpine install_ubuntu
install_alpine: cache/alpine/install.log
install_ubuntu: cache/ubuntu/install.log
cache/%/install.log: cmake/docker/%/InstallDockerfile cache/%/build.log
${DOCKER_DEVEL_CMD} ${IMAGE}_$*:devel /bin/sh -c \
"cmake --build cache/$* --target install -- DESTDIR=install"
@docker image rm -f ${IMAGE}_$*:install 2>/dev/null
docker build --no-cache -t ${IMAGE}_$*:install -f $< .
docker save ${IMAGE}_$*:install -o cache/$*/docker_install.tar
@date > $@
.PHONY: install
install: $(addprefix install_, $(DISTROS))
# DOCKER BASH INSTALL
.PHONY: bash_install_alpine bash_install_ubuntu
bash_install_alpine: cache/alpine/install.log
@docker load -i cache/alpine/docker_install.tar
${DOCKER_INSTALL_CMD} ${IMAGE}_alpine:install /bin/sh
bash_install_ubuntu: cache/ubuntu/install.log
@docker load -i cache/ubuntu/docker_install.tar
${DOCKER_INSTALL_CMD} ${IMAGE}_ubuntu:install /bin/bash
distro_targets = $(addprefix install_, $(DISTROS))
.PHONY: $(distro_targets)
$(distro_targets): install_%: $(addprefix install_%_, $(LANGUAGES))
# TEST INSTALL of ProjectConfigs.cmake
.PHONY: test_install test_install_alpine bash_isntall_ubuntu
test_install: test_install_alpine test_install_ubuntu
test_install_alpine: cache/alpine/test_install.log
test_install_ubuntu: cache/ubuntu/test_install.log
cache/%/test_install.log: cache/%/install.log cmake/sample
@docker load -i cache/$*/docker_install.tar
${DOCKER_INSTALL_CMD} ${IMAGE}_$*:install /bin/sh -c \
"cmake -H. -B/cache; \
cmake --build /cache; \
cmake --build /cache --target test; \
cmake --build /cache --target install"
@date > $@
lang_targets = $(addprefix install_, $(LANGUAGES))
.PHONY: $(lang_targets)
$(lang_targets): install_%: $(addsuffix _%, $(addprefix install_, $(DISTROS)))
distro_cpp_targets = $(addprefix install_, $(addsuffix _cpp, $(DISTROS)))
distro_python_targets = $(addprefix install_, $(addsuffix _python, $(DISTROS)))
distro_java_targets = $(addprefix install_, $(addsuffix _java, $(DISTROS)))
distro_dotnet_targets = $(addprefix install_, $(addsuffix _dotnet, $(DISTROS)))
.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets)
$(distro_cpp_targets): install_%_cpp: cache/%/docker_install_cpp.tar
$(distro_python_targets): install_%_python: cache/%/docker_install_python.tar
$(distro_java_targets): install_%_java: cache/%/docker_install_java.tar
$(distro_dotnet_targets): install_%_dotnet: cache/%/docker_install_dotnet.tar
cache/%/docker_install_cpp.tar: docker/%/Dockerfile sample_cpp
@docker image rm -f ${IMAGE}:$*_install_cpp 2>/dev/null
${DOCKER_BUILD_CMD} --target=install_cpp --tag ${IMAGE}:$*_install_cpp -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_install_cpp -o $@
cache/%/docker_install_python.tar: docker/%/Dockerfile sample_python
@docker image rm -f ${IMAGE}:$*_install_python 2>/dev/null
${DOCKER_BUILD_CMD} --target=install_python --tag ${IMAGE}:$*_install_python -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_install_python -o $@
cache/%/docker_install_java.tar: docker/%/Dockerfile sample_java
@docker image rm -f ${IMAGE}:$*_install_java 2>/dev/null
${DOCKER_BUILD_CMD} --target=install_java --tag ${IMAGE}:$*_install_java -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_install_java -o $@
cache/%/docker_install_dotnet.tar: docker/%/Dockerfile sample_dotnet
@docker image rm -f ${IMAGE}:$*_install_dotnet 2>/dev/null
${DOCKER_BUILD_CMD} --target=install_dotnet --tag ${IMAGE}:$*_install_dotnet -f $< ..
@rm -f $@
mkdir -p cache/$*
docker save ${IMAGE}:$*_install_dotnet -o $@
# DOCKER BASH INSTALL (debug)
distro_cpp_targets = $(addprefix sh_install_, $(addsuffix _cpp, $(DISTROS)))
.PHONY: $(distro_cpp_targets)
distro_python_targets = $(addprefix sh_install_, $(addsuffix _python, $(DISTROS)))
.PHONY: $(distro_python_targets)
distro_java_targets = $(addprefix sh_install_, $(addsuffix _java, $(DISTROS)))
.PHONY: $(distro_java_targets)
distro_dotnet_targets = $(addprefix sh_install_, $(addsuffix _dotnet, $(DISTROS)))
.PHONY: $(distro_dotnet_targets)
$(distro_cpp_targets): sh_install_%_cpp: cache/%/docker_install_cpp.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_cpp ${IMAGE}:$*_install_cpp /bin/sh
$(distro_python_targets): sh_install_%_python: cache/%/docker_install_python.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_python ${IMAGE}:$*_install_python /bin/sh
$(distro_java_targets): sh_install_%_java: cache/%/docker_install_java.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_java ${IMAGE}:$*_install_java /bin/sh
$(distro_dotnet_targets): sh_install_%_dotnet: cache/%/docker_install_dotnet.tar
${DOCKER_RUN_CMD} -it --name ${IMAGE}_$*_install_dotnet ${IMAGE}:$*_install_dotnet /bin/sh
# TEST INSTALL#
.PHONY: test_install
test_install: $(addprefix test_install, $(DISTROS))
distro_targets = $(addprefix test_install_, $(DISTROS))
.PHONY: $(distro_targets)
$(distro_targets): test_install_%: $(addprefix test_install_%_, cpp)
distro_cpp_targets = $(addprefix test_install_, $(addsuffix _cpp, $(DISTROS)))
distro_python_targets = $(addprefix test_install_, $(addsuffix _python, $(DISTROS)))
distro_java_targets = $(addprefix test_install_, $(addsuffix _java, $(DISTROS)))
distro_dotnet_targets = $(addprefix test_install_, $(addsuffix _dotnet, $(DISTROS)))
.PHONY: $(distro_cpp_targets) $(distro_python_targets) $(distro_java_targets) $(distro_dotnet_targets)
$(distro_cpp_targets): test_install_%_cpp: cache/%/docker_install_cpp.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_cpp ${IMAGE}:$*_install_cpp /bin/sh -c \
"cmake -H. -Bbuild; \
cmake --build build --target all; \
cmake --build build --target test; \
cmake --build build --target install"
$(distro_python_targets): test_install_%_python: cache/%/docker_install_python.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_python ${IMAGE}:$*_install_python /bin/sh -c \
"./sample.py"
$(distro_java_targets): test_install_%_java: cache/%/docker_install_java.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_java ${IMAGE}:$*_install_java /bin/sh -c \
"java sample.java"
$(distro_dotnet_targets): test_install_%_dotnet: cache/%/docker_install_dotnet.tar
${DOCKER_RUN_CMD} -t --name ${IMAGE}_$*_install_dotnet ${IMAGE}:$*_install_dotnet /bin/sh -c \
"dotnet build; \
dotnet run --project sample.csproj"
# CLEAN
.PHONY: clean clean_alpine clean_ubuntu
clean: clean_alpine clean_ubuntu
clean_alpine: clean-alpine
clean_ubuntu: clean-ubuntu
clean-%:: cache/%/docker_devel.tar
@docker load -i $<
${DOCKER_DEVEL_CMD} ${IMAGE}_$*:devel /bin/sh -c \
"cmake --build cache/$* --target clean"
${DOCKER_DEVEL_CMD} ${IMAGE}_$*:devel /bin/sh -c \
"rm -rf cache/$*/install"
@rm -f cache/$*/test.log
@rm -f cache/$*/build.log
@rm -f cache/$*/configure.log
@rm -f cache/$*/install.log
@rm -f cache/$*/test_install.log
# DISTCLEAN
.PHONY: distclean distclean_alpine distclean_ubuntu
distclean: distclean_alpine distclean_ubuntu
targets = $(addprefix clean_, $(DISTROS))
.PHONY: clean $(targets)
clean: $(targets)
-rmdir cache
$(targets): clean_%:
docker container prune -f
docker image prune -f
rmdir cache
distclean_alpine: distclean-alpine
distclean_ubuntu: distclean-ubuntu
distclean-%::
${DOCKER_DEVEL_CMD} ${IMAGE}_$*:devel /bin/sh -c \
"rm -rf cache/$*"
docker image rm -f ${IMAGE}_$*:devel 2>/dev/null
docker image rm -f ${IMAGE}_$*:install 2>/dev/null
-docker image rm -f ${IMAGE}:$*_install_cpp 2>/dev/null
-docker image rm -f ${IMAGE}:$*_dotnet 2>/dev/null
-docker image rm -f ${IMAGE}:$*_java 2>/dev/null
-docker image rm -f ${IMAGE}:$*_python 2>/dev/null
-docker image rm -f ${IMAGE}:$*_cpp 2>/dev/null
-docker image rm -f ${IMAGE}:$*_env 2>/dev/null
-rm -f cache/$*/docker_install_cpp.tar
-rm -f cache/$*/docker_dotnet.tar
-rm -f cache/$*/docker_java.tar
-rm -f cache/$*/docker_python.tar
-rm -f cache/$*/docker_cpp.tar
-rm -f cache/$*/docker_env.tar
-rmdir cache/$*
.PHONY: distclean
distclean: clean
-docker container rm -f $$(docker container ls -aq)
-docker image rm -f $$(docker image ls -aq)

View File

@@ -1,5 +1,102 @@
FROM alpine:latest
LABEL maintainer="corentinl@google.com"
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/alpine
FROM alpine:edge AS env
LABEL maintainer="mizux.dev@gmail.com"
# Install system build dependencies
ENV PATH=$PATH:/usr/local/bin
RUN apk add --no-cache git build-base linux-headers cmake
CMD [ "/bin/sh" ]
ADD setup.sh .
RUN ./setup.sh
# Add the library src to our build env
FROM env AS cpp
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake version
RUN cmake -version
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS python
# Swig install
RUN apk add --no-cache swig
# Python install
RUN apk add --no-cache python3-dev
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS java
# Swig install
RUN apk add --no-cache swig
# Java install
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
RUN apk add --no-cache openjdk8
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS dotnet
# Swig install
RUN apk add --no-cache swig
# Add dependencies for disabling invariant mode (set in base image)
RUN apk add --no-cache wget icu-libs libintl
# .NET install
RUN dotnet_sdk_version=3.1.101 \
&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \
&& dotnet_sha512='ce386da8bc07033957fd404909fc230e8ab9e29929675478b90f400a1838223379595a4459056c6c2251ab5c722f80858b9ca536db1a2f6d1670a97094d0fe55' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
# Create an install image
FROM env AS install_cpp
# Copy lib from devel to prod
COPY --from=cpp /usr/local /usr/local/
# Copy sample
WORKDIR /home/sample
COPY ci/sample .

View File

@@ -1,5 +0,0 @@
FROM alpine:latest
LABEL maintainer="corentinl@google.com"
RUN apk add --no-cache git build-base cmake
COPY cache/alpine/install /

View File

@@ -1,6 +0,0 @@
#!/usr/bin/env sh
set -x
apk add --no-cache git build-base linux-headers cmake swig \
python3-dev py3-virtualenv
python3 -m pip install wheel

View File

@@ -0,0 +1,92 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/archlinux/
FROM archlinux/base AS env
LABEL maintainer="mizux.dev@gmail.com"
# Install system build dependencies
ENV PATH=$PATH:/usr/local/bin
RUN pacman -Syu --noconfirm git base-devel cmake
CMD [ "/bin/sh" ]
# Add the library src to our build env
FROM env AS cpp
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake version
RUN cmake -version
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
# Add the library src to our build env
FROM env AS python
# Swig install
RUN pacman -Syu --noconfirm swig
# Python install
RUN pacman -Syu --noconfirm python python-pip
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
# Add the library src to our build env
FROM env AS java
# Swig install
RUN pacman -Syu --noconfirm swig
# Java install
RUN pacman -Syu --noconfirm jdk-openjdk
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
# Add the library src to our build env
FROM env AS dotnet
# Swig install
RUN pacman -Syu --noconfirm swig
# .Net install
RUN pacman -Syu --noconfirm dotnet-sdk
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
# Create an install image
FROM env AS install_cpp
# Copy lib from devel to prod
COPY --from=cpp /usr/local /usr/local/
# Copy sample
WORKDIR /home/sample
COPY ci/sample .

View File

@@ -0,0 +1,148 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/centos
FROM centos:latest AS env
LABEL maintainer="mizux.dev@gmail.com"
# Install system build dependencies
ENV PATH=$PATH:/usr/local/bin
RUN yum -y update \
&& yum -y install git wget openssl-devel \
&& yum -y groupinstall "Development Tools" \
&& yum clean all \
&& rm -rf /var/cache/yum
# Install CMake 3.16.4
RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4-Linux-x86_64.sh" \
&& chmod a+x cmake-3.16.4-Linux-x86_64.sh \
&& ./cmake-3.16.4-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.16.4-Linux-x86_64.sh
CMD [ "/bin/sh" ]
# Add the library src to our build env
FROM env AS cpp
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake version
RUN cmake -version
# CMake configure
RUN cmake -H. -Bbuild -DBUILD_DEPS=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
# Add the library src to our build env
FROM env AS python
# Swig install
RUN yum -y update \
&& yum -y install pcre-devel \
&& yum clean all \
&& rm -rf /var/cache/yum \
&& wget "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz" \
&& tar xvf swig-4.0.1.tar.gz \
&& rm swig-4.0.1.tar.gz \
&& cd swig-4.0.1 \
&& ./configure --prefix=/usr \
&& make -j 4 \
&& make install \
&& cd .. \
&& rm -rf swig-4.0.1
# Python install
RUN yum -y update \
&& yum -y install python36-devel \
&& yum clean all \
&& rm -rf /var/cache/yum
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
# Add the library src to our build env
FROM env AS java
# Swig install
RUN yum -y update \
&& yum -y install pcre-devel \
&& yum clean all \
&& rm -rf /var/cache/yum \
&& wget "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz" \
&& tar xvf swig-4.0.1.tar.gz \
&& rm swig-4.0.1.tar.gz \
&& cd swig-4.0.1 \
&& ./configure --prefix=/usr \
&& make -j 4 \
&& make install \
&& cd .. \
&& rm -rf swig-4.0.1
# Java install
RUN yum -y update \
&& yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel \
&& yum clean all \
&& rm -rf /var/cache/yum
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
# Add the library src to our build env
FROM env AS dotnet
# Swig install
RUN yum -y update \
&& yum -y install pcre-devel \
&& yum clean all \
&& rm -rf /var/cache/yum \
&& wget "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz" \
&& tar xvf swig-4.0.1.tar.gz \
&& rm swig-4.0.1.tar.gz \
&& cd swig-4.0.1 \
&& ./configure --prefix=/usr \
&& make -j 4 \
&& make install \
&& cd .. \
&& rm -rf swig-4.0.1
# .Net install
# see https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-centos7
RUN rpm -Uvh "https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm" \
&& yum -y update \
&& yum -y install dotnet-sdk-3.1 \
&& yum clean all \
&& rm -rf /var/cache/yum
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
# Create an install image
FROM env AS install_cpp
# Copy lib from devel to prod
COPY --from=cpp /usr/local /usr/local/
# Copy sample
WORKDIR /home/sample
COPY ci/sample .

View File

@@ -0,0 +1,126 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/debian
FROM debian:latest AS env
LABEL maintainer="mizux.dev@gmail.com"
# Install system build dependencies
ENV PATH=$PATH:/usr/local/bin
RUN apt-get update -qq \
&& apt-get install -yq git wget libssl-dev build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install CMake 3.16.4
RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4-Linux-x86_64.sh" \
&& chmod a+x cmake-3.16.4-Linux-x86_64.sh \
&& ./cmake-3.16.4-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.16.4-Linux-x86_64.sh
CMD [ "/bin/sh" ]
# Add the library src to our build env
FROM env AS cpp
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake version
RUN cmake -version
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
FROM env AS python
# Swig install
RUN apt-get update -qq \
&& apt-get install -yq swig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Python install
RUN apt-get update -qq \
&& apt-get install -yq python3-dev python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
FROM env AS java
# Swig install
RUN apt-get update -qq \
&& apt-get install -yq swig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Java install
RUN apt-get update -qq \
&& apt-get install -yq default-jdk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
FROM env AS dotnet
# Swig install
RUN apt-get update -qq \
&& apt-get install -yq swig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# .Net install
# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-debian10
RUN apt-get update -qq \
&& apt-get install -yq wget gpg apt-transport-https \
&& wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg \
&& mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ \
&& wget -q https://packages.microsoft.com/config/debian/10/prod.list \
&& mv prod.list /etc/apt/sources.list.d/microsoft-prod.list \
&& apt-get update -qq \
&& apt-get install -yq dotnet-sdk-3.1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
# Create an install image
FROM env AS install
# Copy lib from devel to prod
COPY --from=cpp /usr/local /usr/local/
# Copy sample
WORKDIR /home/sample
COPY ci/sample .

View File

@@ -0,0 +1,111 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/fedora
FROM fedora:latest AS env
LABEL maintainer="mizux.dev@gmail.com"
# Install system build dependencies
ENV PATH=$PATH:/usr/local/bin
RUN dnf -y update \
&& dnf -y install git wget \
&& dnf -y groupinstall "Development Tools" \
&& dnf -y install gcc-c++ cmake \
&& dnf clean all
CMD [ "/bin/sh" ]
# Add the library src to our build env
FROM env AS cpp
# Create lib directory
WORKDIR /home/liBundle lib source
COPY . .
# CMake version
RUN cmake -version
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS python
# Swig install
RUN dnf -y update \
&& dnf -y install swig \
&& dnf clean all
# Python install
RUN dnf -y update \
&& dnf -y install python3 python3-devel \
&& dnf clean all
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS java
# Swig install
RUN dnf -y update \
&& dnf -y install swig \
&& dnf clean all
# Java install
ENV JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk
RUN dnf -y update \
&& dnf -y install java-1.8.0-openjdk-devel \
&& dnf clean all
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS dotnet
# Swig install
RUN dnf -y update \
&& dnf -y install swig \
&& dnf clean all
# .Net install
# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-fedora31
RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc \
&& wget -q -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/31/prod.repo \
&& dnf -y update \
&& dnf -y install dotnet-sdk-3.1 \
&& dnf clean all
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
# Create an install image
FROM env AS install
# Copy lib from devel to prod
COPY --from=cpp /usr/local /usr/local/
# Copy sample
WORKDIR /home/sample
COPY ci/sample .

View File

@@ -0,0 +1,33 @@
FROM quay.io/pypa/manylinux2010_x86_64:latest
LABEL maintainer="mizux.dev@gmail.com"
# Base install
ENV PATH=$PATH:/usr/local/bin
RUN yum -y update \
&& yum -y groupinstall 'Development Tools' \
&& yum -y install wget pcre-devel which redhat-lsb-core \
&& yum clean all \
&& rm -rf /var/cache/yum
# Install CMake 3.16.4
RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4-Linux-x86_64.sh" \
&& chmod a+x cmake-3.16.4-Linux-x86_64.sh \
&& ./cmake-3.16.4-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \
&& rm cmake-3.16.4-Linux-x86_64.sh
CMD [ "/bin/sh" ]
# CMake version
RUN cmake -version
# Swig install
RUN wget "https://downloads.sourceforge.net/project/swig/swig/swig-4.0.1/swig-4.0.1.tar.gz" \
&& tar xvf swig-4.0.1.tar.gz \
&& rm swig-4.0.1.tar.gz \
&& cd swig-4.0.1 \
&& ./configure --prefix=/usr \
&& make -j 4 \
&& make install \
&& cd .. \
&& rm -rf swig-4.0.1
COPY build_manylinux.sh .
RUN chmod a+x build_manylinux.sh

View File

@@ -0,0 +1,21 @@
#!/bin/bash
set -x
set -e
PATH_BCKP=$PATH
echo "PATH: $PATH_BCKP"
for PYROOT in /opt/python/*
do
PYTAG=$(basename "${PYROOT}")
echo "$PYTAG"
# Clean the build dir
rm -rf cache/manylinux/build_$PYTAG
PATH=${PYROOT}/bin:${PATH_BCKP}
python -m pip install --user virtualenv
cmake -H. -Bcache/manylinux/build_$PYTAG \
-DBUILD_PYTHON=ON -DPYTHON_LIBRARY=${PYROOT}/lib/ -DPYTHON_INCLUDE_DIR=${PYROOT}/include/
done

View File

@@ -0,0 +1,114 @@
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/r/opensuse/tumbleweed
FROM opensuse/tumbleweed AS env
LABEL maintainer="mizux.dev@gmail.com"
# Install system build dependencies
ENV PATH=$PATH:/usr/local/bin
RUN zypper update -y \
&& zypper install -y git gcc gcc-c++ cmake \
&& zypper clean -a
ENV CC=gcc CXX=g++
CMD [ "/bin/sh" ]
# Add the library src to our build env
FROM env AS cpp
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake version
RUN cmake -version
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS python
# Swig install
RUN zypper update -y \
&& zypper install -y swig \
&& zypper clean -a
# Python install
RUN zypper update -y \
&& zypper install -y python3 python3-pip python3-devel \
&& zypper clean -a
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS java
# Swig install
RUN zypper update -y \
&& zypper install -y swig \
&& zypper clean -a
# Java install
RUN zypper update -y \
&& zypper install -y java-1_8_0-openjdk-devel \
&& zypper clean -a
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
FROM env AS dotnet
# Swig install
RUN zypper update -y \
&& zypper install -y swig \
&& zypper clean -a
# .Net install
RUN zypper update -y \
&& zypper install -y wget tar libicu-devel
RUN dotnet_sdk_version=3.1.102 \
&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-x64.tar.gz \
&& dotnet_sha512='9cacdc9700468a915e6fa51a3e5539b3519dd35b13e7f9d6c4dd0077e298baac0e50ad1880181df6781ef1dc64a232e9f78ad8e4494022987d12812c4ca15f29' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& rm dotnet.tar.gz
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -S. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON
# CMake build
RUN cmake --build build --target all -v
# CMake build
RUN cmake --build build --target install
# Create an install image
FROM env AS install
# Copy lib from devel to prod
COPY --from=cpp /usr/local /usr/local/
# Copy sample
WORKDIR /home/sample
COPY ci/sample .

View File

@@ -1,5 +1,129 @@
FROM ubuntu:latest
LABEL maintainer="corentinl@google.com"
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/ubuntu
FROM ubuntu:rolling AS env
LABEL maintainer="mizux.dev@gmail.com"
# Install system build dependencies
ENV PATH=$PATH:/usr/local/bin
RUN apt-get update -qq \
&& apt-get install -yq git wget libssl-dev build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install CMake 3.16.4
RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4.tar.gz" \
&& tar xzf cmake-3.16.4.tar.gz \
&& rm cmake-3.16.4.tar.gz \
&& cd cmake-3.16.4 \
&& ./bootstrap --prefix=/usr \
&& make \
&& make install \
&& cd .. \
&& rm -rf cmake-3.16.4
CMD [ "/bin/sh" ]
ADD setup.sh .
RUN ./setup.sh && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Add the library src to our build env
FROM env AS cpp
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake version
RUN cmake -version
# CMake configure
RUN cmake -H. -Bbuild -DBUILD_DEPS=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
FROM env AS python
# Swig
RUN apt-get update -qq \
&& apt-get install -yq swig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Python install
RUN apt-get update -qq \
&& apt-get install -yq python3-dev python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
FROM env AS java
# Swig install
RUN apt-get update -qq \
&& apt-get install -yq swig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Java install
RUN apt-get update -qq \
&& apt-get install -yq default-jdk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_JAVA=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
FROM env AS dotnet
# Swig install
RUN apt-get update -qq \
&& apt-get install -yq swig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# .Net install
# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-ubuntu-1910
RUN apt-get update -qq \
&& apt-get install -yq wget apt-transport-https \
&& wget -q https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& apt-get update -qq \
&& apt-get install -yq dotnet-sdk-3.1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info
# Create lib directory
WORKDIR /home/lib
# Bundle lib source
COPY . .
# CMake configure
RUN cmake -H. -Bbuild -DBUILD_DEPS=ON -DBUILD_DOTNET=ON
# CMake build
RUN cmake --build build --target all
# CMake build
RUN cmake --build build --target install
# Create an install image
FROM env AS install
# Copy lib from devel to prod
COPY --from=cpp /usr/local /usr/local/
# Copy sample
WORKDIR /home/sample
COPY ci/sample .

View File

@@ -1,8 +0,0 @@
FROM ubuntu:devel
LABEL maintainer="corentinl@google.com"
RUN apt-get update -qq && \
apt-get install -qq build-essential cmake && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY cache/ubuntu/install /

View File

@@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -x
apt-get update -qq
apt-get install -qq git wget build-essential swig python3-dev python3-pip
python3 -m pip install virtualenv
wget https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.sh && \
chmod a+x cmake-3.10.2-Linux-x86_64.sh && \
./cmake-3.10.2-Linux-x86_64.sh --prefix=/usr/local/ --skip-license && \
rm cmake-3.10.2-Linux-x86_64.sh