Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #124 from lukaszstolarczuk/improve-docker-images
Browse files Browse the repository at this point in the history
Improve docker images
  • Loading branch information
igchor authored Mar 1, 2021
2 parents 3a41adc + 511b6a9 commit acd56d4
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 25 deletions.
10 changes: 9 additions & 1 deletion utils/docker/images/Dockerfile.fedora-32
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ENV JAVA_HOME /usr/lib/jvm/java-openjdk/
ARG SKIP_PMDK_BUILD
ARG SKIP_LIBPMEMOBJ_CPP_BUILD
ARG SKIP_PMEMKV_BUILD
ARG SKIP_DEPENDENCIES_BUILD
ARG SKIP_MAVEN_RUNTIME_SETUP

ARG LIBPMEMOBJ_CPP_DEPS="\
libatomic"
Expand Down Expand Up @@ -73,7 +75,13 @@ RUN ./install-libpmemobj-cpp.sh RPM
COPY prepare-pmemkv.sh prepare-pmemkv.sh
RUN ./prepare-pmemkv.sh RPM

# Install dependencies for the java binding that it can be built offline
# Prepare extra maven params
# It's executed and its result is exported within 'install-dependencies.sh'
# To avoid setting this script up also in users' .bashrc,
# for a container runtime, set 'SKIP_MAVEN_RUNTIME_SETUP'
COPY setup-maven-settings.sh /opt/setup-maven-settings.sh

# Install dependencies for the java binding so it can be built offline
COPY install-dependencies.sh install-dependencies.sh
RUN ./install-dependencies.sh RPM

Expand Down
12 changes: 10 additions & 2 deletions utils/docker/images/Dockerfile.ubuntu-20.04
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
# Copyright 2016-2021, Intel Corporation

#
# Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based
Expand All @@ -21,6 +21,8 @@ ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
ARG SKIP_PMDK_BUILD
ARG SKIP_LIBPMEMOBJ_CPP_BUILD
ARG SKIP_PMEMKV_BUILD
ARG SKIP_DEPENDENCIES_BUILD
ARG SKIP_MAVEN_RUNTIME_SETUP

# Update the Apt cache and install basic tools
RUN apt-get update
Expand Down Expand Up @@ -69,7 +71,13 @@ RUN ./install-libpmemobj-cpp.sh DEB
COPY prepare-pmemkv.sh prepare-pmemkv.sh
RUN ./prepare-pmemkv.sh DEB

# Install dependencies
# Prepare extra maven params
# It's executed and its result is exported within 'install-dependencies.sh'
# To avoid setting this script up also in users' .bashrc,
# for a container runtime, set 'SKIP_MAVEN_RUNTIME_SETUP'
COPY setup-maven-settings.sh /opt/setup-maven-settings.sh

# Install dependencies for the java binding so it can be built offline
COPY install-dependencies.sh install-dependencies.sh
RUN ./install-dependencies.sh DEB

Expand Down
52 changes: 33 additions & 19 deletions utils/docker/images/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019-2020, Intel Corporation
# Copyright 2019-2021, Intel Corporation

#
# install-dependencies.sh - install Java dependencies
# so that it can be built offline
# install-dependencies.sh - install binding's dependencies
# so it can be built offline
#

set -e

PREFIX=/usr
if [ "${SKIP_DEPENDENCIES_BUILD}" ]; then
echo "Variable 'SKIP_DEPENDENCIES_BUILD' is set; skipping building dependencies"
exit
fi

# Include setup of extra maven parameters...
source /opt/setup-maven-settings.sh

# ...and set the same script as an entrypoint for all users (newly defined in future)
if [ -z "${SKIP_MAVEN_RUNTIME_SETUP}" ]; then
echo "source /opt/setup-maven-settings.sh" >> /etc/skel/.bashrc
fi

MVN_PARAMS="${PMEMKV_MVN_PARAMS}"
echo "Extra mvn params (taken from env): ${MVN_PARAMS}"

PREFIX=/usr
# common: release 1.2, 29.05.2020
PMEMKV_VERSION="1.2"

# common: release 1.0, 30.06.2020
JAVA_VERSION="1.0"

#
# Build and install PMEMKV - JNI will need it
#
echo "Build and install PMEMKV (JNI needs it)"
git clone https://github.com/pmem/pmemkv.git
cd pmemkv
git checkout $PMEMKV_VERSION
git checkout ${PMEMKV_VERSION}
mkdir build
cd build

cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DENGINE_CMAP=OFF \
-DENGINE_CSMAP=OFF \
-DENGINE_VCMAP=OFF \
Expand All @@ -42,26 +54,28 @@ make -j$(nproc) install
# project's dependencies - all of the dependencies needed to run pmemkv-java will
# be saved in the /opt/java directory. It makes building
# of this project independent of network connection.
echo "Save binding's dependencies in /opt/java"
mkdir /opt/java/

deps_dir=$(mktemp -d)
git clone https://github.com/pmem/pmemkv-java.git ${deps_dir}
pushd ${deps_dir}
git checkout $JAVA_VERSION
mvn install -Dmaven.test.skip=true
mvn dependency:go-offline
git checkout ${JAVA_VERSION}

mvn install -Dmaven.test.skip=true ${MVN_PARAMS}
mvn javadoc:javadoc ${MVN_PARAMS}
mvn dependency:go-offline ${MVN_PARAMS}
mv -v ~/.m2/repository /opt/java/

popd
rm -r ${deps_dir}

#
# Uninstall all installed stuff
#
cd $WORKDIR/pmemkv/build
echo "Uninstall pmemkv"
cd ${WORKDIR}/pmemkv/build
make uninstall
# remove any installed pmemkv-java's libs

echo "Remove installed binding files (from local mvn repository)"
rm -r /opt/java/repository/io/pmem/*

# make the /opt/java directory world-readable
echo "Make the /opt/java directory world-readable"
chmod -R a+r /opt/java
31 changes: 31 additions & 0 deletions utils/docker/images/setup-maven-settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2021, Intel Corporation

#
# setup-maven-settings.sh - setup some extra settings for maven
# It's executed in 'install-dependencies.sh', but it can also be
# run locally (or in a custom docker container) to setup
# these extra params for run-*.sh scripts.
#

set -e

# Split proxies into host & port; remove possible leftover "/"
if [[ -n "${http_proxy}" ]]; then
http_proxy_ip=$(echo ${http_proxy} | cut -d: -f2 | sed 's/\///g')
http_proxy_port=$(echo ${http_proxy} | cut -d: -f3 | sed 's/\///g')
fi
if [[ -n "${https_proxy}" ]]; then
https_proxy_ip=$(echo ${https_proxy} | cut -d: -f2 | sed 's/\///g')
https_proxy_port=$(echo ${https_proxy} | cut -d: -f3 | sed 's/\///g')
fi

mvn_params=''
[ -n "${http_proxy_ip}" ] && mvn_params="${mvn_params} -Dhttp.proxyHost=${http_proxy_ip}"
[ -n "${http_proxy_port}" ] && mvn_params="${mvn_params} -Dhttp.proxyPort=${http_proxy_port}"
[ -n "${https_proxy_ip}" ] && mvn_params="${mvn_params} -Dhttps.proxyHost=${https_proxy_ip}"
[ -n "${https_proxy_port}" ] && mvn_params="${mvn_params} -Dhttps.proxyPort=${https_proxy_port}"

# Export for current user/current shell
export PMEMKV_MVN_PARAMS="${mvn_params}"
3 changes: 2 additions & 1 deletion utils/docker/run-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
set -e

source `dirname $0`/prepare-for-build.sh
MVN_PARAMS="${PMEMKV_MVN_PARAMS}"

function run_example() {
example_name=$1
Expand Down Expand Up @@ -38,7 +39,7 @@ echo "###########################################################"
cd $WORKDIR
mkdir -p ~/.m2/repository
cp -r /opt/java/repository ~/.m2/
mvn install -e
mvn install -e ${MVN_PARAMS}

echo
echo "###########################################################"
Expand Down
5 changes: 3 additions & 2 deletions utils/docker/run-doc-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ REPO_NAME=${REPO:-"pmemkv-java"}
export GITHUB_TOKEN=${DOC_UPDATE_GITHUB_TOKEN} # export for hub command
REPO_DIR=$(mktemp -d -t pmemkvjava-XXX)
ARTIFACTS_DIR=$(mktemp -d -t ARTIFACTS-XXX)
MVN_PARAMS="${PMEMKV_MVN_PARAMS}"

# Only 'master' or 'stable-*' branches are valid; determine docs location dir on gh-pages branch
TARGET_BRANCH=${CI_BRANCH}
Expand Down Expand Up @@ -58,8 +59,8 @@ git remote update
git checkout -B ${TARGET_BRANCH} upstream/${TARGET_BRANCH}

echo "Build docs:"
mvn install -Dmaven.test.skip=true -e
mvn javadoc:javadoc -e
mvn install -Dmaven.test.skip=true -e ${MVN_PARAMS}
mvn javadoc:javadoc -e ${MVN_PARAMS}
cp -r ${REPO_DIR}/pmemkv-binding/target/site/apidocs ${ARTIFACTS_DIR}/

# Checkout gh-pages and copy docs
Expand Down

0 comments on commit acd56d4

Please sign in to comment.