Since the collector repo uses a submodule for the sysdig source, use the following command to clone.
git clone --recurse-submodules [email protected]:stackrox/collector.git
These instructions are for using the JetBrains C/C++ IDE CLion, but should be adaptable to any IDE that supports development over ssh/sftp.
- If running CLion IDE for the first time:
- Download and install CLion (https://www.jetbrains.com/clion/download/)
- Create a project from the
collector/collector
directory using an existing CMakeLists file (collector/collector/CMakeLists.txt
).
- Create the collector builder container if not already running, or if the builder image has changed.
make start-dev
- (Optional) Local builder images can used by setting the environment variable before execution using
BUILD_BUILDER_IMAGE=true make start-dev
. Or, builder images from a PR by withCOLLECTOR_BUILDER_TAG=<circle-build-id> make start-dev
.
- (Optional) Local builder images can used by setting the environment variable before execution using
Instructions for Mac OS
- In the CLion->Preferences window, add a new Toolchain entry in settings under Build, Execution, Deployment as a Remote Host type.
- Then, click in the Credentials section and fill out the SSH credentials used in the builder Dockerfile.
- Host:
localhost
, Port:2222
, User name:remoteuser
, Password:c0llectah
- Host:
- Next, select Deployment under Build, Execution, Deployment, and then Mappings. Set Deployment path to
/tmp
. - Finally, add a CMake profile that uses the Remote Host toolchain and change Build directory/Generation Path to
cmake-build
.
Instructions for Linux
- In the File->Settings->Build, Execution, Deployment->Toolchains window, add a new Toolchain entry as a Remote Host type.
- Then, click in the Credentials section and fill out the SSH credentials used in the builder Dockerfile.
- Host:
localhost
, Port:2222
, User name:remoteuser
, Password:c0llectah
- Host:
- In the File->Setting->Build, Execution, Deployment->Deployment window click on the Mappings tab. Set Deployment path to /tmp.
- In the File->Settings->Build, Execution, Deployment->CMake window add a CMake profile that uses the Remote Host toolchain and change Build directory/Generation Path to
cmake-build
.
- Run
make teardown-dev
to remove the builder container and associated ephemeral ssh keys from$HOME/.ssh/known_hosts
- After restarting, you may need click Resync with Remote Hosts under the Tools menu in CLion.
- To build the sysdig wrapper libary and collector binary: select the collector configuration from the Run... menu and then Build.
- To run unit tests, select the runUnitTests configuration and then select Run.
Visual Studio Code can be used as a development environment by leveraging its devcontainers feature.
- Install the remote-containers extension.
- Create a
.devcontainer.json
file undercollector
and set theimage
attribute toquay.io/stackrox-io/collector-builder:cache
{
"name": "collector-dev",
"image": "quay.io/stackrox-io/collector-builder:cache"
}
- Open the
collector/
directory in a new instance of Visual Studio Code and when prompted select Reopen In Container, a new container should be created and the workspace directory will be mounted inside of it.
Closing the Visual Studio Code instance will stop the container.
Even though development containers is a supported feature of Docker for Desktop
, there is a bug that tanks performance when running containers with mounted volumes. A possible workaround is to setup docker to run inside a VM and mounting the work directories using NFS.
make image
will create the Red Hat based collector image.make image-dev
will create a collector image based on CentOS Stream, the package manager in this image is available so additional developer tools can be installed.make image-dev-full
will extend theimage-dev
target and also compile and embed the kernel module and eBPF probes in the final image, making it easier to test changes in these components.
Git hooks are configured in the .pre-commit-config.yaml
file using pre-commit
In order to use them install pre-commit, and run git config core.hooksPath ./githooks/
from the collector root directory.