This documentation provides a comprehensive guide on how to build and start the Thanos project, focusing on expert developers familiar with the repository.

Prerequisites

Before proceeding, ensure you have the following installed:

  • Go (version >= 1.17)
  • Node.js and npm
  • Make
  • Docker (if using Docker)

Setting Up the Development Environment

1. Clone the Repository

First, clone the Thanos repository:

git clone https://github.com/thanos-io/thanos.git
cd thanos

2. Install Dependencies

Use the Makefile to install the dependencies defined within:

make deps

This will ensure your go.mod file is tidy and verified.

Building the Project

3. Build the Binary

To build the Thanos binary, execute the following command:

make build

This targets the main build process defined in the Makefile. The output binary will be located in the current project directory.

4. Cross-Compile for Different Platforms (Optional)

If you require cross-compilation for different platforms, use:

make crossbuild

This will generate binaries for several platforms based on the current branch of the repository. If you are on the main branch, it will specifically build for:

  • linux/amd64
  • linux/arm64
  • linux/ppc64le

5. Verify the Build

After building, verify that the binary has been created:

ls -l ./thanos

Running the Project

6. Starting the Server

To initiate the Thanos server, execute:

./thanos server --http-address=0.0.0.0:10902

Adjust parameters according to your deployment strategy.

7. Start Local Object Storage (Optional)

If local object storage is desired, run the quickstart script after ensuring any necessary variables (e.g., MINIO_ENABLED) are set in your environment:

bash scripts/quickstart.sh

This script sets up locally required services. Ensure that you have the Minio binary available if using S3-compatible APIs.

8. Running Tests

To execute tests, be mindful of build constraints. Exclude tests with constraints like !linux or !stringlabels if necessary:

make test

This command triggers the testing process defined within the Makefile, executing tests while adhering to established constraints.

Additional Steps

9. Linting & Formatting

Maintain code quality by running:

make lint
make format

These commands will apply lint and formatting checks across your Go and JavaScript/TypeScript code, ensuring consistency.

10. Docker Support

If you plan to run Thanos in a Docker container, utilize the following command to build the Docker image:

make docker

This pulls together all necessary components into a Docker image that can be deployed as needed.

To run the Docker image:

docker run -p 10902:10902 thanos-io/thanos:latest server --http-address=0.0.0.0:10902

Conclusion

By following this guide, you can efficiently build and run the Thanos project. For further development and contributions, refer to the CONTRIBUTING.md file for best practices.

Sources used:

  • Makefile
  • docs/getting-started.md
  • scripts/quickstart.sh