# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2021, Intel Corporation

#
# Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based
#				environment prepared for executing build and tests
#				of pmemkv-* bindings repositories.
#

# Pull base image
FROM ubuntu:20.04
MAINTAINER igor.chorazewicz@intel.com

# Set required environment variables
ENV OS ubuntu
ENV OS_VER 20.04_bindings
ENV PACKAGE_MANAGER deb
ENV NOTTY 1
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64

# Additional parameters to build docker without building components
ARG SKIP_VALGRIND_BUILD
ARG SKIP_PMDK_BUILD
ARG SKIP_LIBPMEMOBJCPP_BUILD

# Update the Apt cache and install basic tools
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
	autoconf \
	automake \
	build-essential \
	clang \
	clang-format-9 \
	cmake \
	curl \
	debhelper \
	devscripts \
	doxygen \
	fakeroot \
	gdb \
	git \
	graphviz \
	libc6-dbg \
	libdaxctl-dev \
	libgtest-dev \
	libndctl-dev \
	libnode-dev \
	libnuma-dev \
	libmemkind-dev \
	libtbb-dev \
	libtext-diff-perl \
	libtool \
	libunwind8-dev \
	maven \
	npm \
	numactl \
	openjdk-8-jdk \
	pandoc \
	pkg-config \
	python3-dev \
	python3-distutils \
	python3-pip \
	ruby-dev \
	sudo \
	wget \
	whois \
 && rm -rf /var/lib/apt/lists/*

# Install rapidjson from sources
COPY install-rapidjson.sh install-rapidjson.sh
RUN ./install-rapidjson.sh

# Install valgrind
COPY install-valgrind.sh install-valgrind.sh
RUN ./install-valgrind.sh

# Install pmdk
COPY install-pmdk.sh install-pmdk.sh
RUN ./install-pmdk.sh dpkg

# Install pmdk c++ bindings
COPY install-libpmemobj-cpp.sh install-libpmemobj-cpp.sh
RUN ./install-libpmemobj-cpp.sh DEB

# Bindings
RUN pip3 install pytest setuptools wheel
COPY install-bindings-dependencies.sh install-bindings-dependencies.sh
RUN ./install-bindings-dependencies.sh

# Add user
ENV USER user
ENV USERPASS pass
RUN useradd -m $USER -g sudo -p `mkpasswd $USERPASS`
USER $USER
