diff --git a/presto-native-execution/.devcontainer/Dockerfile b/presto-native-execution/.devcontainer/Dockerfile new file mode 100644 index 0000000000000..86e72e86a4318 --- /dev/null +++ b/presto-native-execution/.devcontainer/Dockerfile @@ -0,0 +1,19 @@ +FROM presto/prestissimo-dependency:centos9 + +# Install necesary packages to run dev containers in CLion +# https://www.jetbrains.com/help/clion/prerequisites-for-dev-containers.html#remote_container +RUN dnf -y update && dnf -y install epel-release +RUN dnf -y --skip-broken install \ + curl \ + unzip \ + procps \ + libXext \ + libXrender \ + libXtst \ + libXi \ + freetype \ + procps \ + java-17-openjdk-headless \ + python3.12 + +RUN pip3 install pre-commit diff --git a/presto-native-execution/.devcontainer/README.md b/presto-native-execution/.devcontainer/README.md new file mode 100644 index 0000000000000..92bc62b93d9b9 --- /dev/null +++ b/presto-native-execution/.devcontainer/README.md @@ -0,0 +1,34 @@ +# How to develop Presto C++ with dev-containers in CLion + +> **_NOTE:_** For this to work you need CLion 2025.2.2 or greater. + +If you can't build, or want to build the development environment on your machine, you can use dev-containers. With them, you can have your IDE frontend working against a CLion backend running on a docker container. To set it up, run the following command: + +```sh +docker compose build centos-native-dependency +``` +Once the image is built, open the `presto-native-execution` module on CLion. + +Right-click on `.devcontainer\devcontainer.json`, and in the contextual menu select `Dev Containers->Create Dev Container and mount sources...->CLion`. Wait for the container to be up and running before you continue. + +The source code is mounted from your machine so any change made into it from the dev-container will also be on your machine. + +## Debug or execute `presto_server` + +Reload CMake project and configure the `presto_server` executable. See [Setup Presto with IntelliJ IDEA and Prestissimo with CLion](https://github.com/prestodb/presto/tree/master/presto-native-execution#setup-presto-with-intellij-idea-and-prestissimo-with-clion). Compile the project as needed. + +Then, execute the script `./devcontainer/install-shared-libs.sh` inside the container. This will create a directory `/runtime-libraries` and copy all the shared libraries needed for your compilation runtime in there. + +Edit the `presto_server` configuration to add the environment variable `LD_LIBRARY_PATH=/runtime-libraries`. This way, you'll have the same environment as distributed prestissimo images. + +## Known errors + - In some cases an error such as `Computing backend... error. Collection contains no element matching the predicate` can appear. The feature is still in beta. In this case, the container will be created and running, but there might have been an issue starting the CLion backend inside the container. + +To resolve this issue, close CLion and reopen it. + +In the `Welcome to CLion` window go to `Remote Development (beta)->Dev Containers`. You should see that the container `Presto C++ Dev Container` is up and running, so connect to it. In this case, the backend should start properly and the project should be opened. + + - In you can't use git inside the container, you need to manually add the mounted repo to the trusted directories for the dev-container + ```sh + git config --global --add safe.directory /workspace/presto + ``` diff --git a/presto-native-execution/.devcontainer/devcontainer.json b/presto-native-execution/.devcontainer/devcontainer.json new file mode 100644 index 0000000000000..d72ba896b0efd --- /dev/null +++ b/presto-native-execution/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +{ + "name": "Presto C++ Dev Container", + "build": { + "dockerfile": "Dockerfile" + }, + "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspace/presto,type=bind", + "workspaceFolder": "/workspace/presto/presto-native-execution" +} diff --git a/presto-native-execution/.devcontainer/install-shared-libs.sh b/presto-native-execution/.devcontainer/install-shared-libs.sh new file mode 100755 index 0000000000000..9e935f1c5f559 --- /dev/null +++ b/presto-native-execution/.devcontainer/install-shared-libs.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# 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. +# Before executing this script, you should compile presto_server +# Copy shared libs to the directory /runtime-libraries +mkdir /runtime-libraries && + bash -c '!(LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:/usr/local/lib64 ldd ../cmake-build-debug/presto_cpp/main/presto_server | grep "not found")' && + LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:/usr/local/lib64 ldd ../cmake-build-debug/presto_cpp/main/presto_server | awk 'NF == 4 { system("cp " $3 " /runtime-libraries") }' diff --git a/presto-native-execution/README.md b/presto-native-execution/README.md index 5956a5d5efd15..f40b753cebe78 100644 --- a/presto-native-execution/README.md +++ b/presto-native-execution/README.md @@ -243,6 +243,10 @@ Run CLion: ![ScreenShot](docs/images/cl_clangformat_switcherenable.png) +### Setup Presto C ++ with dev containers using [CLion](https://www.jetbrains.com/clion/) + +See [How to develop Presto C++ with dev-containers in CLion](.devcontainer/README.md). + ### Run Presto Coordinator + Worker * Note that everything below can be done without using IDEs by running command line commands (not in this readme). * Run QueryRunner as per your choice,