Overview
This documentation describes the CI/CD workflow for thanos-io/thanos
. At present, there is no formal CI/CD system set up within the Thanos project.
Next Steps
To implement a CI/CD pipeline for the Thanos project, consider the following steps:
Choose a CI/CD Tool:
- Consider using platforms such as GitHub Actions, CircleCI, Travis CI, or Jenkins, depending on team familiarity and preferences.
Define Workflow:
- Clearly define stages in your workflow. These could include Build, Test, and Deploy stages.
Create Configuration Files:
- Based on the CI/CD tool chosen, create appropriate configuration files (e.g.,
.github/workflows/main.yml
for GitHub Actions).
- Based on the CI/CD tool chosen, create appropriate configuration files (e.g.,
Integrate Testing:
- Use the existing testing mechanisms in the Thanos project to ensure code integrity before the deployment process.
Implement Docker:
- As the project uses Docker, setting up automated builds and tests in Docker containers can streamline the process.
Documentation:
- Ensure that the newly created CI/CD processes are well documented for future contributors.
Here is a sample CI/CD workflow to guide development efforts once you choose a platform:
Example CI/CD Configuration
GitHub Actions Workflow
Once you decide to use GitHub Actions, create a file at .github/workflows/main.yml
with the following content:
name: CI/CD Workflow
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set Up Go
uses: actions/setup-go@v2
with:
go-version: '1.17' # Specify the Go version.
- name: Build
run: |
make build
- name: Run Tests
run: |
go test ./... -tags '!linux,!stringlabels'
- name: Build Docker Image
run: |
docker build -t thanos:latest .
- name: Push Docker Image
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
docker push thanos:latest
Explanation of Configuration
Trigger Events:
- The workflow triggers on pushes and pull requests to the
main
branch.
- The workflow triggers on pushes and pull requests to the
Jobs:
- The
build
job runs on the latest Ubuntu environment.
- The
Checkout:
- The repository is checked out using actions/checkout.
Go Setup:
- The specific Go version is set up with actions/setup-go.
Build Command:
- The
make build
command is executed to build the project.
- The
Run Tests:
- Tests are run with constraints to exclude certain configurations.
Build and Push Docker Image:
- A Docker image is built and pushed to a registry, with credentials securely handled through GitHub Secrets.
Dockerfile Example
If your CI/CD pipeline includes Docker, ensure that your Dockerfile
is properly set up:
# By default we pin to amd64 sha. Use make docker to automatically adjust for arm64 versions.
ARG BASE_DOCKER_SHA="14d68ca3d69fceaa6224250c83d81d935c053fb13594c811038c461194599973"
FROM quay.io/prometheus/busybox@sha256:${BASE_DOCKER_SHA}
LABEL maintainer="The Thanos Authors"
COPY /thanos_tmp_for_docker /bin/thanos
RUN adduser \
-D `#Dont assign a password` \
-H `#Dont create home directory` \
-u 1001 `#User id`\
thanos && \
chown thanos /bin/thanos
USER 1001
ENTRYPOINT [ "/bin/thanos" ]
This Dockerfile
uses an ARG for the base image SHA and sets up the application in a minimal environment suitable for running Thanos.
Conclusion
While the Thanos project currently lacks a formal CI/CD setup, implementing one can significantly enhance the development workflow and ensure code quality. By building upon the example workflows and incorporating existing code practices, contributors can streamline the process of continuous integration and deployment for Thanos.
Sources Used:
- Makefile
- Dockerfile
- Release process documentation