From 7c536bf6a9158098218eca9b2866d9580d4a044d Mon Sep 17 00:00:00 2001 From: Laurence Jones Date: Tue, 7 Nov 2023 09:13:18 +0000 Subject: [PATCH] Add a build from source 1.5 guide (#427) * Add a build from source 1.5 guide * Implment @mmetc changes * Update install_source.mdx * add link to user guide on bulding * Move info to bottom as it norml --- .../docs/getting_started/install_source.mdx | 198 ++++++++++++++++++ crowdsec-docs/docs/user_guides/building.md | 9 +- crowdsec-docs/sidebars.js | 1 + 3 files changed, 201 insertions(+), 7 deletions(-) create mode 100644 crowdsec-docs/docs/getting_started/install_source.mdx diff --git a/crowdsec-docs/docs/getting_started/install_source.mdx b/crowdsec-docs/docs/getting_started/install_source.mdx new file mode 100644 index 00000000..7ae14ed4 --- /dev/null +++ b/crowdsec-docs/docs/getting_started/install_source.mdx @@ -0,0 +1,198 @@ +--- +id: install_source +title: Compile from source +sidebar_position: 1 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import CodeBlock from '@theme/CodeBlock'; + +:::warning +This is only for advanced users that wish to compile their own software. If you are not comfortable with this, please use the [official packages](/getting_started/getting_started.md) +::: + +We define systems by their underlying distribution rather than a fork or modification of a distribution. For example, Ubuntu and Debian are both Debian based distributions, so they will share the same instructions as the term DEB. Centos and Fedora are both Redhat based distributions, so they will share the same instructions as the term RPM. Arch is just Arch, so it will have its own instructions. + + +## Dependencies + +### Required +- Golang [Check go.mod file for version needed](https://github.com/crowdsecurity/crowdsec/blob/master/go.mod) + - Most of the time your distribution package manager will not have the version (check with your package manager firstly if they do), you will need to install it from the official website. + - If your shell is bash and you have sudo access you can use this [install script](https://gist.github.com/LaurenceJJones/aacedfd4438a811780951b2c40431e3a) +- Make + + + apt install make + + + + dnf install make + + + pacman -S make + + +- GCC + + + apt install gcc + + + + dnf install gcc + + + pacman -S gcc + + +- pkg-config + + + apt install pkg-config + + + + dnf install pkg-config + + + pacman -S pkg-config + + + +### Optional + +- RE2 + + + apt install libre2-dev g++ + + + + dnf install libre2-dev g++ + + + pacman -S re2 base-devel + + + +## Building + +### Clone + +```bash +git clone https://github.com/crowdsecurity/crowdsec +cd crowdsec +``` + +### Build + +```bash +make [build_flags] build +``` + +#### Build flags + +##### Optional + +- `BUILD_VERSION=v1.2.3` - The version you want to build. This will default to the latest version, however, if you fork the project then you will need to use this flag. + +:::info +Do not use a version we have already released as you will get old hub parsers. We recommend using the latest tag from the [releases page](https://github.com/crowdsecurity/crowdsec/releases/latest). +::: + +- `BUILD_STATIC=1` - Build a static binary: + - DEB: none + - RPM/Arch: + - RPM: Enable crb repo + - RPM: `sudo yum install glibc-static libstdc++-static` + - RPM/Arch: compile RE2 from source [install script](https://gist.github.com/LaurenceJJones/d17f7839b03acbe0e4e879fd60f4b433) as the version provided by package managers does not include the static library. + +:::info What is a static build? +Static builds are builds that do not require any external dependencies to run. This means a compiled binary on your system will work on any other system running your architecture and linux/windows/freebsd. As an example if I compile a static build on my Arch Linux machine, I can copy that binary to a Debian machine and it will work without any issues. +::: + +- `BUILD_RE2_WASM=1` - Build the RE2 WASM library +:::info +By default we try to build with RE2 library from libraries provided by OS (We define it as optional since this build flag overrides it). We recommend that you build with RE2 from libraries as it is faster and more performant than the WASM version. +::: + +## Optimal build flags +The following build flags are what we recommend you use when building CrowdSec. + +#### Binary will run on different machine (Built on dev machine then copied to production machine) + +```bash +make BUILD_STATIC=1 release +``` + +Then you can copy the `crowdsec-release.tgz` file to your production machine and extract it. + +#### Binary will only run on your machine (Testing new features) + +```bash +make build +``` + +If you run into any issues when compiling please join our [discord](https://discord.gg/crowdsec) and ask for help. Please provide the output of the build command and the error you are getting. + +## Wizard.sh + +We provide a wizard.sh script that will help you install, update and uninstall CrowdSec. + +### Installing + +Once the binaries have been built you can install them using the wizard.sh file in the root of the repo or release folder. This will install the binaries, systemd service files and create the required directories. + +```bash +sudo ./wizard.sh -i +``` + +If you would like to have a hands off installation then you can provide the `-unattended` flag to the wizard.sh script. + +### Updating + +To update CrowdSec you can use the wizard.sh file in the root of the repo or release folder. This will update the binaries, systemd service files and create the required directories. + +```bash +sudo ./wizard.sh --binupgrade +``` + +If you have compiled CrowdSec with the same build version as the one installed then you can use the `--force` flag to force the update. + +### Uninstalling + +To uninstall CrowdSec you can use the wizard.sh file in the root of the repo or release folder. This will remove the binaries, systemd service files and delete the required directories. + +```bash +sudo ./wizard.sh --uninstall +``` diff --git a/crowdsec-docs/docs/user_guides/building.md b/crowdsec-docs/docs/user_guides/building.md index bf4e293b..da146e8f 100644 --- a/crowdsec-docs/docs/user_guides/building.md +++ b/crowdsec-docs/docs/user_guides/building.md @@ -90,11 +90,6 @@ git clone https://github.com/crowdsecurity/crowdsec.git && cd crowdsec docker build -t crowdsec . ``` -## Building from sources +## Building from source -You can build your own crowdsec release like this : - -```bash -git clone https://github.com/crowdsecurity/crowdsec.git && cd crowdsec -make release -``` +You can see the [build instructions](/getting_started/install_source.mdx) for more details. diff --git a/crowdsec-docs/sidebars.js b/crowdsec-docs/sidebars.js index 9bb3e9eb..3bc5e5ad 100644 --- a/crowdsec-docs/sidebars.js +++ b/crowdsec-docs/sidebars.js @@ -78,6 +78,7 @@ } ] }, + "getting_started/install_source", ], }, {