Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Aug 3, 2023
2 parents 165585e + 1b4097d commit 27b85d1
Show file tree
Hide file tree
Showing 89 changed files with 3,122 additions and 2,405 deletions.
40 changes: 23 additions & 17 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- main
schedule:
- cron: '0 22 * * 6'
- cron: "0 22 * * 6"

jobs:
analyze:
Expand All @@ -20,24 +20,30 @@ jobs:
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Build Artifact
run: make build
- name: Install cross-compilation tools
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Build Artifacts
run: make build-all

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
10 changes: 6 additions & 4 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ name: test-pipeline
on:
pull_request:
branches:
- '**'
- "**"

jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19

- name: Install tools
run: make install-ci
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: benjlevesque/short-sha@v1.2
- uses: benjlevesque/short-sha@v2.2
id: short-sha
- name: Get branch name
id: branch-name
Expand All @@ -39,5 +39,12 @@ jobs:
else
echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
fi
- name: Install cross-compilation tools
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: Build artifacts for arm64/amd64
run: make build-all
- name: Build and push docker image
run: make build-and-push-signoz-collector
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: release

on:
push:
tags:
- v[0].[0-9]+.[0-9]+

jobs:
upload-release-assets:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install cross-compilation tools
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: Build artifacts for arm64/amd64
run: make build-all
- name: Create checksums and tarballs
run: |
set -ex
echo "Creating checksums and tarballs"
cd .build/linux-amd64
sha256sum signoz-collector > signoz-collector-linux-amd64.sha256
tar -czvf signoz-collector-linux-amd64.tar.gz signoz-collector
cd ../linux-arm64
sha256sum signoz-collector > signoz-collector-linux-arm64.sha256
tar -czvf signoz-collector-linux-arm64.tar.gz signoz-collector
- name: Create release and upload assets
uses: softprops/action-gh-release@v1
with:
files: |
.build/linux-amd64/signoz-collector-linux-amd64.sha256
.build/linux-amd64/signoz-collector-linux-amd64.tar.gz
.build/linux-arm64/signoz-collector-linux-arm64.sha256
.build/linux-arm64/signoz-collector-linux-arm64.tar.gz
generate_release_notes: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
.DS_Store
.idea
./config/default-config.yaml

# build folder
.build
*.rollback
signoz-collector
signoz-collector
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
COMMIT_SHA ?= $(shell git rev-parse HEAD)
REPONAME ?= signoz
IMAGE_NAME ?= "signoz-otel-collector"
IMAGE_NAME ?= signoz-otel-collector
CONFIG_FILE ?= ./config/default-config.yaml
DOCKER_TAG ?= latest

Expand All @@ -15,6 +15,8 @@ IMPORT_LOG=.import.log
CLICKHOUSE_HOST ?= localhost
CLICKHOUSE_PORT ?= 9000

LD_FLAGS ?=


.PHONY: install-tools
install-tools:
Expand All @@ -31,7 +33,18 @@ test:

.PHONY: build
build:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o signoz-collector ./cmd/signozcollector
CGO_ENABLED=1 go build -tags timetzdata -o .build/${GOOS}-${GOARCH}/signoz-collector -ldflags "-linkmode external -extldflags '-static' -s -w ${LD_FLAGS}" ./cmd/signozcollector

.PHONY: amd64
amd64:
make GOARCH=amd64 build

.PHONY: arm64
arm64:
make CC=aarch64-linux-gnu-gcc GOARCH=arm64 build

.PHONY: build-all
build-all: amd64 arm64

.PHONY: run
run:
Expand All @@ -47,7 +60,7 @@ build-and-push-signoz-collector:
@echo "------------------"
@echo "--> Build and push signoz collector docker image"
@echo "------------------"
docker buildx build --platform linux/amd64,linux/arm64 --progress plane \
docker buildx build --platform linux/amd64,linux/arm64 --progress plain \
--no-cache --push -f cmd/signozcollector/Dockerfile \
--tag $(REPONAME)/$(IMAGE_NAME):$(DOCKER_TAG) .

Expand All @@ -57,7 +70,7 @@ build-signoz-collector:
@echo "--> Build signoz collector docker image"
@echo "------------------"
docker build --build-arg TARGETPLATFORM="linux/amd64" \
--no-cache -f cmd/signozcollector/Dockerfile --progress plane \
--no-cache -f cmd/signozcollector/Dockerfile --progress plain \
--tag $(REPONAME)/$(IMAGE_NAME):$(DOCKER_TAG) .

.PHONY: lint
Expand Down
42 changes: 19 additions & 23 deletions cmd/signozcollector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
# Builder stage
FROM golang:1.18-alpine as build
RUN apk --update add ca-certificates
# use a minimal alpine image
FROM alpine:3.17

WORKDIR /src
COPY . .

ARG TARGETPLATFORM

RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)

ENV OS111MODULE=on
ENV CGO_ENABLED=0

RUN cd cmd/signozcollector && go build -tags timetzdata -o /out/signoz-collector

# Final stage
FROM alpine:3.15
# add ca-certificates in case you need them
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*

# define arguments and default values
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG USER_UID=10001

# create a non-root user for running the collector
USER ${USER_UID}

COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /out/signoz-collector /
COPY --from=build /src/exporter/clickhousetracesexporter/migrations /migrations
COPY --from=build /src/exporter/clickhouselogsexporter/migrations /logsmigrations
# copy the binaries from the multi-stage build
COPY .build/${TARGETOS}-${TARGETARCH}/signoz-collector /signoz-collector

# copy the config and migration files
COPY config/default-config.yaml /etc/otel/config.yaml
COPY exporter/clickhousetracesexporter/migrations /migrations
COPY exporter/clickhouselogsexporter/migrations /logsmigrations

ENV LOG_MIGRATIONS_FOLDER="/logsmigrations"

# expose OTLP ports for the collector
EXPOSE 4317 4318
ENTRYPOINT ["/signoz-collector"]

# run the binary as the entrypoint and pass the default config file as a flag
ENTRYPOINT [ "/signoz-collector" ]
CMD ["--config", "/etc/otel/config.yaml"]
Loading

0 comments on commit 27b85d1

Please sign in to comment.