Skip to content

Commit

Permalink
Initial distro implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Jul 19, 2022
2 parents c7bb2cb + 7d8cd2b commit cba3df7
Show file tree
Hide file tree
Showing 87 changed files with 12,345 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/lint-and-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: test-pipeline

on:
pull_request:
branches:
- develop
- main
- release/v*

jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Install tools
run: make install-ci

- name: Run unit tests and lint
run: make test-and-lint
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@

# Dependency directories (remove the comment below to include it)
# vendor/

.vscode
.DS_Store
.idea
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
run:
timeout: 10m
linters-settings:
depguard:
list-type: blacklist
include-go-root: true
gofmt:
simplify: true
gosimple:
go: '1.17'
linters:
enable:
- gofmt
- goimports
disable:
- staticcheck
- typecheck
- gosec
- govet
- errcheck
- gocritic
- revive
- deadcode
- gosimple
- ineffassign
- depguard
- errorlint
- structcheck
- varcheck
- unused
issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
COMMIT_SHA ?= $(shell git rev-parse HEAD)
REPONAME ?= signoz
IMAGE_NAME ?= "otel-collector"
CONFIG_FILE ?= ./config/default-config.yaml
DOCKER_TAG ?= latest

GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOPATH ?= $(shell go env GOPATH)
GOTEST=go test -v $(RACE)
GOFMT=gofmt
FMT_LOG=.fmt.log
IMPORT_LOG=.import.log


.PHONY: install-tools
install-tools:
go install github.com/golangci/golangci-lint/cmd/[email protected]

.DEFAULT_GOAL := test-and-lint

.PHONY: test-and-lint
test-and-lint: test fmt lint

.PHONY: test
test:
go test -count=1 -v -race -cover ./...

.PHONY: build
build:
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o signoz-collector ./cmd/signozcollector

.PHONY: run
run:
go run cmd/signozcollector/* --config ${CONFIG_FILE}

.PHONY: fmt
fmt:
@echo Running go fmt on query service ...
@$(GOFMT) -e -s -l -w .

.PHONY: build-signoz-collector
build-signoz-collector:
@echo "------------------"
@echo "--> Building signoz collector docker image"
@echo "------------------"
docker buildx build --progress plane \
--no-cache -f cmd/signozcollector/Dockerfile \
--tag $(REPONAME)/$(IMAGE_NAME):$(DOCKER_TAG) .

.PHONY: lint
lint:
@echo "Running linters..."
@$(GOPATH)/bin/golangci-lint -v --config .golangci.yml run && echo "Done."

.PHONY: install-ci
install-ci: install-tools

.PHONY: test-ci
test-ci: lint
30 changes: 30 additions & 0 deletions cmd/signozcollector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Builder stage
FROM --platform=$BUILDPLATFORM golang:1.17-alpine as build
RUN apk --update add ca-certificates

WORKDIR /src
COPY . .

ARG TARGETOS TARGETARCH

ENV OS111MODULE=on
ENV CGO_ENABLED=0
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH

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

# Final stage
FROM scratch

ARG USER_UID=10001

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

EXPOSE 4317 4318
ENTRYPOINT ["/signoz-collector"]
CMD ["--config", "/etc/otel/config.yaml"]
Loading

0 comments on commit cba3df7

Please sign in to comment.