Skip to content

Commit

Permalink
[native] Add dockerfiles for dependencies and runtime
Browse files Browse the repository at this point in the history
These dockerfiles allow building container images for dependencies and
Prestissimo runtime.
  • Loading branch information
majetideepak committed May 15, 2024
1 parent e572b03 commit cfff317
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 6 deletions.
6 changes: 5 additions & 1 deletion presto-native-execution/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.PHONY: all cmake build clean debug release unittest submodules velox-submodule
.PHONY: all cmake build cmake-and-build clean debug release unittest submodules velox-submodule

BUILD_BASE_DIR=_build
BUILD_DIR=release
Expand Down Expand Up @@ -79,6 +79,10 @@ release: #: Build the release version
$(MAKE) cmake BUILD_DIR=release BUILD_TYPE=Release && \
$(MAKE) build BUILD_DIR=release

cmake-and-build: #: cmake and build without updating submodules which requires git
cmake -B "$(BUILD_BASE_DIR)/$(BUILD_DIR)" $(FORCE_COLOR) $(CMAKE_FLAGS) $(EXTRA_CMAKE_FLAGS)
cmake --build $(BUILD_BASE_DIR)/$(BUILD_DIR) -j $(NUM_THREADS)

unittest: debug #: Build with debugging and run unit tests
cd $(BUILD_BASE_DIR)/debug && ctest -j $(NUM_THREADS) -VV --output-on-failure --exclude-regex velox.*

Expand Down
4 changes: 4 additions & 0 deletions presto-native-execution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using [Velox](https://github.com/facebookincubator/velox).

## Table of Contents
* [Build from Source](#build-from-source)
* [Build using Dockerfile](#build-using-dockerfile)
* [Development](#development)
* [Create Pull Request](#create-pull-request)
* [Advance Velox Version](#advance-velox-version)
Expand Down Expand Up @@ -108,6 +109,9 @@ A reminder of the available Makefile targets can be obtained using `make help`
help Show the help messages
```

## Build using Dockerfile
Information on how to build a dependency and runtime image of Prestissimo [can be found here](scripts/dockerfiles/README.md).

## Development
### Setup Presto with [IntelliJ IDEA](https://www.jetbrains.com/idea/) and Prestissimo with [CLion](https://www.jetbrains.com/clion/)

Expand Down
64 changes: 64 additions & 0 deletions presto-native-execution/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version: '3.5'

services:
ubuntu-native-dependency:
# Usage:
# docker-compose build ubuntu-native-dependency
# podman compose build ubuntu-native-dependency
image: presto/prestissimo-dependency:amd64-ubuntu-22.04
build:
args:
- BUILD_TYPE=Release
context: .
dockerfile: scripts/dockerfiles/ubuntu-22.04-dependency.dockerfile

ubuntu-native-runtime:
# Usage:
# docker-compose build ubuntu-native-runtime
# podman compose build ubuntu-native-runtime
image: presto/prestissimo-runtime:amd64-ubuntu-22.04
build:
args:
- BUILD_TYPE=Release
- DEPENDENCY_IMAGE=presto/prestissimo-dependency:amd64-ubuntu-22.04
- BASE_IMAGE=amd64/ubuntu:22.04
- OSNAME=ubuntu
context: .
dockerfile: scripts/dockerfiles/prestissimo-runtime.dockerfile
environment:
NUM_THREADS: 8 # default value for NUM_THREADS

centos-native-dependency:
# Usage:
# docker-compose build centos-native-dependency
# podman compose build centos-native-dependency
image: presto/prestissimo-dependency:centos8
build:
args:
- BUILD_TYPE=Release
context: .
dockerfile: scripts/dockerfiles/centos-8-stream-dependency.dockerfile

centos-native-runtime:
# Usage:
# docker-compose build centos-native-runtime
# podman compose build centos-native-runtime
image: presto/prestissimo-runtime:centos8
build:
args:
- BUILD_TYPE=Release
context: .
dockerfile: scripts/dockerfiles/prestissimo-runtime.dockerfile
environment:
NUM_THREADS: 8 # default value for NUM_THREADS
55 changes: 55 additions & 0 deletions presto-native-execution/scripts/dockerfiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Prestissimo - Dockerfile build

> 📝 _**Note:** Please post in Presto Slack if you have any questions_
There are two kinds of Dockerfiles:
1) A platform specific file to build dependencies. Current supported platforms are
1) Centos-8-stream with gcc9.
2) Ubuntu-22.04 with gcc11.
2) A platform-agnostic file to build Prestissimo runtime on top of the dependency image.
### Dependency Dockerfiles
These Dockerfiles install all the dependencies including those needed for testing.
A list of dependencies can be found [here](../../README.md).
By default, the dependencies are built in Release mode.
The Dependency Image needs to be built only when some dependency is updated.
Prestissimo dependencies change infrequently.

### Runtime Dockerfile
This Dockerfile builds Prestissimo on top of the dependency image.
There are 2 stages:
* The first stage builds the Prestissimo binary.
* The second stage creates a Prestissimo runtime image from
a base image and copies the binary and shared libraries that are required
for execution.

Run the following command to see the services available to build images.
```
podman compose config --services
```

## Quick Start

### 1. Clone the Presto repository and checkout Prestissimo submodules

```bash
git clone https://github.com/prestodb/presto
cd presto/presto-native-execution && make submodules
```

### 2. Build Dependency Image using docker/podman compose

Specify the build type using the ``BUILD_TYPE`` (defaults to Release)
environment variable.

```bash
podman compose build centos-native-dependency
```

### 3. Build Runtime Image

Specify the build type using ``BUILD_TYPE`` (defaults to Release)
environment variable.

```bash
podman compose build centos-native-runtime
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM quay.io/centos/centos:stream8

ARG BUILD_TYPE=Release
ENV PROMPT_ALWAYS_RESPOND=n
ENV CC=/opt/rh/gcc-toolset-9/root/bin/gcc
ENV CXX=/opt/rh/gcc-toolset-9/root/bin/g++

RUN mkdir -p /scripts /velox/scripts
COPY scripts /scripts
COPY velox/scripts /velox/scripts
RUN mkdir build && \
(cd build && ../scripts/setup-centos.sh && ../velox/scripts/setup-adapters.sh aws) && \
rm -rf build
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG DEPENDENCY_IMAGE=presto/prestissimo-dependency:centos8
ARG BASE_IMAGE=quay.io/centos/centos:stream8
FROM ${DEPENDENCY_IMAGE} as prestissimo-image

ARG OSNAME=centos
ARG BUILD_TYPE=Release
ARG EXTRA_CMAKE_FLAGS=''
ARG NUM_THREADS=8

ENV PROMPT_ALWAYS_RESPOND=n
ENV BUILD_BASE_DIR=_build
ENV BUILD_DIR=""

RUN mkdir -p /prestissimo /runtime-libraries
COPY . /prestissimo/
RUN EXTRA_CMAKE_FLAGS=${EXTRA_CMAKE_FLAGS} \
make -j${NUM_THREADS} --directory="/prestissimo/" cmake-and-build BUILD_TYPE=${BUILD_TYPE} BUILD_DIR=${BUILD_DIR} BUILD_BASE_DIR=${BUILD_BASE_DIR}
RUN ldd /prestissimo/${BUILD_BASE_DIR}/${BUILD_DIR}/presto_cpp/main/presto_server | awk 'NF == 4 { system("cp " $3 " /runtime-libraries") }'

#/////////////////////////////////////////////
# prestissimo-runtime
#//////////////////////////////////////////////

FROM ${BASE_IMAGE}

ENV BUILD_BASE_DIR=_build
ENV BUILD_DIR=""

COPY --chmod=0775 --from=prestissimo-image /prestissimo/${BUILD_BASE_DIR}/${BUILD_DIR}/presto_cpp/main/presto_server /usr/local/bin/
COPY --chmod=0775 --from=prestissimo-image /runtime-libraries/* /usr/local/lib/
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG base=amd64/ubuntu:22.04
FROM ${base}
ARG BUILD_TYPE=Release
# Set a default timezone, can be overriden via ARG
ARG tz="America/New_York"
ARG DEBIAN_FRONTEND="noninteractive"
ENV PROMPT_ALWAYS_RESPOND=n
ENV SUDO=" "
# TZ and DEBIAN_FRONTEND="noninteractive"
# are required to avoid tzdata installation
# to prompt for region selection.
ENV TZ=${tz}

RUN mkdir -p /scripts /velox/scripts
COPY scripts /scripts
COPY velox/scripts /velox/scripts
# setup-adapters.sh does not install rpm needed for minio install.
RUN mkdir build && \
(cd build && ../scripts/setup-ubuntu.sh && apt install -y rpm && ../velox/scripts/setup-adapters.sh aws) && \
rm -rf build
9 changes: 4 additions & 5 deletions presto-native-execution/scripts/setup-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ set -eufx -o pipefail
# Run the velox setup script first.
source "$(dirname "${BASH_SOURCE}")/../velox/scripts/setup-ubuntu.sh"
export FB_OS_VERSION=v2024.04.01.00

function install_presto_deps_from_apt {
sudo apt install -y gperf
}
SUDO="${SUDO:-"sudo --preserve-env"}"

function install_proxygen {
# proxygen requires python and gperf
${SUDO} apt update
${SUDO} apt install -y gperf python3
github_checkout facebook/proxygen "${FB_OS_VERSION}"
cmake_install -DBUILD_TESTS=OFF
}

function install_presto_deps {
run_and_time install_presto_deps_from_apt
run_and_time install_proxygen
}

Expand Down

0 comments on commit cfff317

Please sign in to comment.