Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native] Add dockerfiles for dependencies and runtime and remove existing dockerfiles #21929

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions 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 Expand Up @@ -107,24 +111,6 @@ tidy-fix: cmake #: Fix clang-tidy issues in the master branch
tidy-check: cmake #: Check clang-tidy issues in the master branch
pushd "$$(pwd)/.." && presto-native-execution/velox/scripts/check.py tidy master && popd

centos-container: #: Build the linux container for CircleCi
$(MAKE) linux-container CONTAINER_NAME=centos

linux-container:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you update presto-native-execution/README.md since it has references to these deleted targets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! done!

rm -rf /tmp/docker && \
mkdir -p /tmp/docker && \
$(eval VELOX_SETUP_SCRIPT=$(shell [ $(CONTAINER_NAME) == centos ] && echo setup-centos8.sh; [ $(CONTAINER_NAME) != centos ] && echo setup-$(CONTAINER_NAME).sh;)) \
cp scripts/setup-$(CONTAINER_NAME).sh scripts/$(CONTAINER_NAME)-container.dockfile velox/scripts/${VELOX_SETUP_SCRIPT} velox/scripts/setup-helper-functions.sh /tmp/docker && \
cd /tmp/docker && \
docker build --build-arg cpu_target=$(CPU_TARGET) --tag "prestocpp/prestocpp-$(CPU_TARGET)-$(CONTAINER_NAME):$(USER)-$(shell date +%Y%m%d)" -f $(CONTAINER_NAME)-container.dockfile .

runtime-container:
rm -rf /tmp/release-centos-dockerfile && \
mkdir -p /tmp/release-centos-dockerfile && \
cp -r scripts/build-centos.sh scripts/release-centos-dockerfile /tmp/release-centos-dockerfile && \
cd /tmp/release-centos-dockerfile && \
PRESTOCPP_ROOT_DIR=$(PRESTOCPP_ROOT_DIR) ./build-centos.sh

help: #: Show the help messages
@cat $(firstword $(MAKEFILE_LIST)) | \
awk '/^[-a-z]+:/' | \
Expand Down
6 changes: 1 addition & 5 deletions presto-native-execution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,11 @@ A reminder of the available Makefile targets can be obtained using `make help`
header-check Check for license header issues on the current branch
tidy-fix Fix clang-tidy issues in the current branch
tidy-check Check clang-tidy issues in the current branch
linux-container Build the CircleCi linux container from scratch
runtime-container Build the software in container using current git commit
help Show the help messages
```

## Build using Dockerfile
Run `make runtime-container` in the presto-native-execution root directory
to build run-ready containerized version of Prestissimo. Information on available
configuration options can be found in [scripts/release-centos-dockerfile/README.md](scripts/release-centos-dockerfile/README.md)
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
131 changes: 0 additions & 131 deletions presto-native-execution/scripts/build-centos.sh

This file was deleted.

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
Expand Up @@ -9,11 +9,17 @@
# 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.
# Build the test and build container for presto_cpp
#
FROM ghcr.io/facebookincubator/velox-dev:centos8

COPY setup-centos.sh /
COPY setup-helper-functions.sh /
RUN chmod +x ./setup-centos.sh
RUN mkdir build && ( cd build && ../setup-centos.sh install_presto_deps ) && rm -rf build
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/
Loading
Loading