Skip to content

Commit

Permalink
ci: πŸ‘· build and push workflow (#12)
Browse files Browse the repository at this point in the history
* ci: πŸ‘· add push workflow
* chore: πŸ”¨ Makefile target to build local image and related changes
* ci: πŸ‘· fix docker image tag

Signed-off-by: Prashant Shahi <[email protected]>
  • Loading branch information
prashant-shahi authored Aug 23, 2022
1 parent d712b72 commit 633fec6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 10 deletions.
File renamed without changes.
43 changes: 43 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Push

on:
push:
branches:
- main
- develop
tags:
- v*

jobs:
image-build-and-push-signoz-collector:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: benjlevesque/[email protected]
id: short-sha
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]
- name: Set docker tag environment
run: |
if [ '${{ steps.branch-name.outputs.is_tag }}' == 'true' ]; then
tag="${{ steps.branch-name.outputs.tag }}"
tag="${tag:1}"
echo "DOCKER_TAG=$tag" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
fi
- name: Build and push docker image
run: make build-and-push-signoz-collector
19 changes: 14 additions & 5 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 ?= "otel-collector"
IMAGE_NAME ?= "signoz-otel-collector"
CONFIG_FILE ?= ./config/default-config.yaml
DOCKER_TAG ?= latest

Expand Down Expand Up @@ -42,13 +42,22 @@ fmt:
@echo Running go fmt on query service ...
@$(GOFMT) -e -s -l -w .

.PHONY: build-and-push-signoz-collector
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 \
--no-cache --push -f cmd/signozcollector/Dockerfile \
--tag $(REPONAME)/$(IMAGE_NAME):$(DOCKER_TAG) .

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

.PHONY: lint
Expand All @@ -69,4 +78,4 @@ migrate-logs:

.PHONY: migrate-logs-down
migrate-logs-down:
migrate -verbose -path "./exporter/clickhouselogsexporter/migrations/" -database "clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}?database=signoz_logs&x-multi-statement=true" down
migrate -verbose -path "./exporter/clickhouselogsexporter/migrations/" -database "clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}?database=signoz_logs&x-multi-statement=true" down
10 changes: 5 additions & 5 deletions cmd/signozcollector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Builder stage
FROM --platform=$BUILDPLATFORM golang:1.17-alpine as build
FROM golang:1.17-alpine as build
RUN apk --update add ca-certificates

WORKDIR /src
COPY . .

ARG TARGETOS TARGETARCH
ARG TARGETPLATFORM

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

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

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

Expand All @@ -31,4 +32,3 @@ ENV LOG_MIGRATIONS_FOLDER="/logsmigrations"
EXPOSE 4317 4318
ENTRYPOINT ["/signoz-collector"]
CMD ["--config", "/etc/otel/config.yaml"]

0 comments on commit 633fec6

Please sign in to comment.