Skip to content

Commit

Permalink
#82 upgrade compiler to C++17 - docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbald committed Sep 30, 2018
1 parent 9e831c0 commit c2965fd
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ install:
BOOST_URL="https://dl.bintray.com/boostorg/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION//\./_}.tar.gz"
BOOST_DIR="${DEPS_DIR}/boost-${BOOST_VERSION}"
BOOST_TOOLSET=gcc
BOOST_LIBS='program_options,system,regex,serialization,log,date_time,test'
BOOST_LIBS='program_options,system,regex,serialization,log,date_time,test,filesystem'
mkdir -p "${BOOST_DIR}"
if [[ -z "$(ls -A ${BOOST_DIR})" ]]; then
Expand Down
62 changes: 44 additions & 18 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,78 @@
VanillaRTB Docker images have two layers (optionally three) of hierarchy:

* #0.0 VanillaRTB Base - VanillaRTB unified runtime environment
* #1.1 VanillaRTB Dev (extends #0.0) - VanillaRTB development environment with preinstalled G++, CMake, Boost (selected libraries)
* #1.2 VanillaRTB Bld (extends #0.0) - VanillaRTB package builder image (!TODO!)
* #1.1 VanillaRTB Deps (extends #0.0) - VanillaRTB dependencies builder image
* #1.2 VanillaRTB Dev (extends #0.0) - VanillaRTB development environment with preinstalled G++, CMake, Boost (selected libraries)
* #1.3 VanillaRTB Prod (extends #0.0) - VanillaRTB pre-built ready to run package
* #2.x (extends #1.3) - Specialized container preconfigured to run particular VanillaRTB component or subsystem

## Creating and Updating
### ( instructions for vanilla-rtb stack contributors only !!!! )
!!! instructions for vanilla-rtb stack contributors only !!!

Base package:
All steps below require the same pre-steps:

```bash
$ vanilla_env_ver=x.y.z
$ cd vanilla-rtb/docker
```

### 0.0 Base Package

```bash
$ docker build --tag vanillartb/vanilla-base:${vanilla_env_ver} --file vanilla-base.Dockerfile ${PWD}
$ docker login
$ docker push vanillartb/vanilla-base:${vanilla_env_ver}
```

Development environment package : built automatically on hub.docker.com everytime we tag our git push
### 1.1 Dependencies & Runtime

This is a side-package required to build boost and other dependencies keeping the production chain clean of build tools.
```bash
$ vanilla_env_ver=x.y.z
$ cd vanilla-rtb/docker
$ docker build --tag vanillartb/vanilla-dev:${vanilla_env_ver} --file vanilla-dev.Dockerfile ${PWD}
$ docker tag vanillartb/vanilla-dev:${vanilla_env_ver} vanillartb/vanilla-dev:latest
$ docker build --tag vanillartb/vanilla-deps:${vanilla_env_ver} --file vanilla-deps.Dockerfile $PWD
```

```bash
$ docker container run -a STDOUT --name vanilla-depsbox vanillartb/vanilla-deps:${vanilla_env_ver}
$ docker cp vanilla-depsbox:/root/deps ./deps
$ docker container rm vanilla-depsbox
$
$ docker login
$ docker push vanillartb/vanilla-dev:${vanilla_env_ver} vanillartb/vanilla-dev:latest
$ docker build --tag vanillartb/vanilla-runtime:${vanilla_env_ver} --file vanilla-runtime.Dockerfile $PWD
$ /bin/rm -rf ./deps
```

### 1.2 Development Environment
Built automatically on hub.docker.com everytime we tag our git push.

```bash
$ docker build --tag vanillartb/vanilla-dev:${vanilla_env_ver} --file vanilla-dev.Dockerfile ${PWD}
```

Production package :
### 1.3 Production

```bash
$ vanilla_env_ver=a.b.c
$ vanilla_ver=x.y.z
$ cd vanilla-rtb/docker
$
$ docker container run -a STDOUT --name vanilla-buildbox vanillartb/vanilla-dev:${vanilla_env_ver}
$ docker cp vanilla-buildbox:/root/pkg/vanilla-rtb/snapshot ./vanilla
$ docker cp vanilla-buildbox:/root/pkg ./pkg
$ docker container rm vanilla-buildbox
$
$ docker build --tag vanillartb/vanilla-prod:${vanilla_ver} --file vanilla-prod.Dockerfile ${PWD}
$ /bin/rm -rf ./vanilla
$ docker tag vanillartb/vanilla-prod:${vanilla_ver} vanillartb/vanilla-prod:latest
$
$ /bin/rm -rf ./pkg
```

### Upload to the Docker Hub

```bash
$ vanilla_env_ver=x.y.z
$ docker login
$ docker push vanillartb/vanilla-base:${vanilla_env_ver}
$ docker push vanillartb/vanilla-deps:${vanilla_env_ver}
$ docker push vanillartb/vanilla-dev:${vanilla_env_ver}
$ docker tag vanillartb/vanilla-dev:${vanilla_env_ver} vanillartb/vanilla-dev:latest
$ docker push vanillartb/vanilla-prod:${vanilla_env_ver}
$ docker tag vanillartb/vanilla-prod:${vanilla_ver} vanillartb/vanilla-prod:latest
$ docker push vanillartb/vanilla-prod:latest

```

# Running
Expand Down
29 changes: 29 additions & 0 deletions docker/build-boost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -eu

if [[ ${BOOST_VERSION} != 'default' ]]; then
readonly BOOST_URL="https://dl.bintray.com/boostorg/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION//\./_}.tar.gz"
readonly BOOST_DEPS_DIR="${DEPS_DIR}/boost-${BOOST_VERSION}"
readonly BOOST_BUILD_DIR="${BUILD_DIR}/boost-${BOOST_VERSION}"
readonly BOOST_TOOLSET=gcc
readonly BOOST_LIBS='program_options,system,regex,serialization,log,date_time,test,filesystem'

$(type -P rm) -rf "${BOOST_BUILD_DIR}"
$(type -P mkdir) -p "${BOOST_BUILD_DIR}"

$(type -P wget) --no-check-certificate --quiet -O - "${BOOST_URL}" | $(type -P tar) --strip-components=1 -xz -C "${BOOST_BUILD_DIR}"

cd "${BOOST_BUILD_DIR}"
./bootstrap.sh --with-libraries="${BOOST_LIBS}" --with-toolset="${BOOST_TOOLSET}" || { cat bootstrap.log; exit 1; }
./b2 -d0 -q toolset="${BOOST_TOOLSET}" variant=release link=shared threading=multi runtime-link=shared install --prefix="${BOOST_DEPS_DIR}"

$(type -P rm) -rf "${BOOST_BUILD_DIR}"
$(type -P rmdir) --ignore-fail-on-non-empty "${BUILD_DIR}"

export CMAKE_OPTIONS+=" -DBOOST_ROOT='${BOOST_DEPS_DIR}'"

echo "Boost v${BOOST_VERSION} installed to ${BOOST_DEPS_DIR}"
else
echo "Nothing done - using the default Boost installation"
fi
25 changes: 17 additions & 8 deletions docker/build-vanilla.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

set -eu

[[ ! -d vanilla-rtb ]] && git clone --recursive https://github.com/venediktov/vanilla-rtb.git
readonly VANILLA_RTB_PKG_DIR="${PKG_DIR}/vanilla-rtb-${VANILLA_RTB_VERSION}"
readonly VANILLA_RTB_BUILD_DIR="${BUILD_DIR}/vanilla-rtb-${VANILLA_RTB_VERSION}"

[[ ! -d ../build/vanilla-rtb ]] && mkdir -p ../build/vanilla-rtb
[[ ! -d ../pkg/vanilla-rtb/snapshot ]] && mkdir -p ../pkg/vanilla-rtb/snapshot
cd ../build/vanilla-rtb
$(type -P rm) -rf ${VANILLA_RTB_BUILD_DIR} ${VANILLA_RTB_PKG_DIR}

cmake -G 'Unix Makefiles'\
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$(readlink -f ../../pkg/vanilla-rtb/snapshot)" \
"$(readlink -f ../../code/vanilla-rtb)"
git -c http.sslVerify=false clone --recursive https://github.com/venediktov/vanilla-rtb.git ${VANILLA_RTB_BUILD_DIR}

$(type -P mkdir) ${VANILLA_RTB_BUILD_DIR}/Release
cd ${VANILLA_RTB_BUILD_DIR}/Release

CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX='${VANILLA_RTB_PKG_DIR}'"
if [[ ${BOOST_VERSION} != 'default' ]]; then
readonly BOOST_DEPS_DIR="${DEPS_DIR}/boost-${BOOST_VERSION}"
export CMAKE_OPTIONS+=" -DBOOST_ROOT='${BOOST_DEPS_DIR}'"
fi

cmake .. -G 'Unix Makefiles' ${CMAKE_OPTIONS}
cmake --build . --target install -- -j$(nproc) -l$(nproc)

cd ${BUILD_DIR}
$(type -P rm) -rf ${VANILLA_RTB_BUILD_DIR}

16 changes: 2 additions & 14 deletions docker/vanilla-base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
FROM debian:unstable
FROM ubuntu:latest
LABEL Description="VanillaRTB Base" Vendor="ForkBid" Maintainer="mrbald@github"
RUN apt-get update && apt-get install -y apt-utils
RUN apt-get install -yq\
libboost-atomic1.67\
libboost-chrono1.67\
libboost-date-time1.67\
libboost-filesystem1.67\
libboost-log1.67\
libboost-program-options1.67\
libboost-regex1.67\
libboost-serialization1.67\
libboost-system1.67\
libboost-thread1.67

RUN apt-get update && apt-get -yq --no-install-suggests --no-install-recommends install -y apt-utils
CMD ["bash"]
16 changes: 16 additions & 0 deletions docker/vanilla-deps.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM vanillartb/vanilla-base:0.0.2
ARG BOOST_VERSION=1.67.0
ARG WORK_ROOT=/root
LABEL Description="VanillaRTB Dependencies Builder" Vendor="ForkBid" Maintainer="mrbald@github"
RUN apt-get install -yq --no-install-suggests --no-install-recommends wget build-essential g++-7
ENV CC=gcc-7 CXX=g++-7

WORKDIR ${WORK_ROOT}/scripts
ADD build-boost.sh ${WORK_ROOT}/scripts
RUN chmod +x ${WORK_ROOT}/scripts/build-boost.sh && sync

WORKDIR ${WORK_ROOT}/deps
WORKDIR ${WORK_ROOT}/build
RUN env DEPS_DIR=${WORK_ROOT}/deps BUILD_DIR=${WORK_ROOT}/build BOOST_VERSION=${BOOST_VERSION} ${WORK_ROOT}/scripts/build-boost.sh

CMD ["bash"]
39 changes: 13 additions & 26 deletions docker/vanilla-dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
FROM vanillartb/vanilla-base:0.0.2
FROM vanillartb/vanilla-runtime:0.0.2
ARG BOOST_VERSION=1.67.0
ARG VANILLA_RTB_VERSION=snapshot
ARG WORK_ROOT=/root
LABEL Description="vanilla-rtb Dev" Vendor="ForkBid" Maintainer="mrbald@github"
RUN apt-get update
RUN apt-get install -y\
cmake\
git\
clang\
vim\
libboost-atomic1.67-dev\
libboost-chrono1.67-dev\
libboost-date-time1.67-dev\
libboost-filesystem1.67-dev\
libboost-log1.67-dev\
libboost-program-options1.67-dev\
libboost-regex1.67-dev\
libboost-serialization1.67-dev\
libboost-system1.67-dev\
libboost-thread1.67-dev\
libboost-test1.67\
libboost-test1.67-dev\
python
RUN apt-get install -yq --no-install-suggests --no-install-recommends make cmake git build-essential g++-7 vim python
ENV CC=gcc-7 CXX=g++-7

WORKDIR /root/pkg
WORKDIR /root/build
WORKDIR /root/code
WORKDIR ${WORK_ROOT}/scripts
ADD build-vanilla.sh ${WORK_ROOT}/scripts
RUN chmod +x ${WORK_ROOT}/scripts/build-vanilla.sh && sync

ADD build-vanilla.sh /root/code
WORKDIR ${WORK_ROOT}/deps
WORKDIR ${WORK_ROOT}/build
RUN env VANILLA_RTB_VERSION=${VANILLA_RTB_VERSION} PKG_DIR=${WORK_ROOT}/pkg DEPS_DIR=${WORK_ROOT}/deps BUILD_DIR=${WORK_ROOT}/build BOOST_VERSION=${BOOST_VERSION} ${WORK_ROOT}/scripts/build-vanilla.sh

RUN chmod +x ./build-vanilla.sh && sync && ./build-vanilla.sh

WORKDIR /root/pkg/vanilla-rtb/snapshot/bin
WORKDIR /root/pkg/vanilla-rtb-${VANILLA_RTB_VERSION}/bin

CMD ["bash"]
8 changes: 5 additions & 3 deletions docker/vanilla-prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM vanillartb/vanilla-base:0.0.2
FROM vanillartb/vanilla-runtime:0.0.2
ARG VANILLA_RTB_VERSION=snapshot
ARG WORK_ROOT=/root
LABEL Description="VanillaRTB Prod" Vendor="ForkBid" Maintainer="mrbald@github"
WORKDIR /root/pkg/vanilla
ADD vanilla .
ADD pkg ${WORK_ROOT}/pkg
WORKDIR ${WORK_ROOT}/pkg/vanilla-rtb-${VANILLA_RTB_VERSION}/bin
CMD ["bash"]
6 changes: 6 additions & 0 deletions docker/vanilla-runtime.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM vanillartb/vanilla-base:0.0.2
ARG BOOST_VERSION=1.67.0
ARG WORK_ROOT=/root
LABEL Description="VanillaRTB Runtime" Vendor="ForkBid" Maintainer="mrbald@github"
ADD deps ${WORK_ROOT}/deps
CMD ["bash"]

0 comments on commit c2965fd

Please sign in to comment.