Adding multi architecture (ARM64 and AMD64) support for signoz components (#201)

* Adding multi arch support for amd64 and arm64

Signed-off-by: rajdas98 <mail.rajdas@gmail.com>

* test

* reset package-lock.json

Signed-off-by: rajdas98 <mail.rajdas@gmail.com>

* reset yarn-lock.json

Signed-off-by: rajdas98 <mail.rajdas@gmail.com>

* reset yarn-lock.json

Signed-off-by: rajdas98 <mail.rajdas@gmail.com>
This commit is contained in:
Raj Babu Das 2021-07-14 23:36:27 +05:30 committed by GitHub
parent ec0059dbd8
commit b1169c7315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 38 deletions

View File

@ -40,8 +40,8 @@ jobs:
- name: Build frontend docker image
shell: bash
run: |
cd frontend
docker build . -f Dockerfile
make build-frontend-amd64
build-query-service:
runs-on: ubuntu-latest
needs:
@ -53,8 +53,8 @@ jobs:
- name: Build query-service image
shell: bash
run: |
cd pkg/query-service
docker build . -f Dockerfile
make build-flattener-amd64
build-flattener:
runs-on: ubuntu-latest
needs:
@ -66,5 +66,4 @@ jobs:
- name: Build flattener docker image
shell: bash
run: |
cd pkg/processors/flattener
docker build . -f Dockerfile
make build-query-service-amd64

View File

@ -52,12 +52,11 @@ jobs:
with:
name: env_artifact
- name: Build frontend docker image
shell: bash
run: |
source env-vars
cd frontend
docker build . -f Dockerfile -t ${{ secrets.REPONAME }}/${FRONTEND_IMAGE}:${IMG_TAG}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v1
@ -65,15 +64,20 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push frontend docker image
- name: Build & Push Frontend Docker Image
shell: bash
env:
FRONTEND_DIRECTORY: "frontend"
REPONAME: ${{ secrets.REPONAME }}
FRONTEND_DOCKER_IMAGE: ${FRONTEND_IMAGE}
DOCKER_TAG: ${IMG_TAG}
run: |
branch=${GITHUB_REF#refs/*/}
array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`)
if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]]
then
source env-vars
docker push ${{ secrets.REPONAME }}/${FRONTEND_IMAGE}:${IMG_TAG}
make build-push-frontend
fi
build-and-push-query-service:
@ -89,12 +93,11 @@ jobs:
with:
name: env_artifact
- name: Build query-service image
shell: bash
run: |
source env-vars
cd pkg/query-service
docker build . -f Dockerfile -t ${{ secrets.REPONAME }}/${QUERY_SERVICE}:${IMG_TAG}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v1
@ -102,15 +105,20 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push query service docker image
- name: Build & Push Query Service Docker Image
shell: bash
env:
QUERY_SERVICE_DIRECTORY: "pkg/query-service"
REPONAME: ${{ secrets.REPONAME }}
QUERY_SERVICE_DOCKER_IMAGE: ${QUERY_SERVICE}
DOCKER_TAG: ${IMG_TAG}
run: |
branch=${GITHUB_REF#refs/*/}
array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`)
if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]]
then
source env-vars
docker push ${{ secrets.REPONAME }}/${QUERY_SERVICE}:${IMG_TAG}
make build-push-query-service
fi
build-and-push-flattener:
@ -126,12 +134,11 @@ jobs:
with:
name: env_artifact
- name: Build flattener docker image
shell: bash
run: |
source env-vars
cd pkg/processors/flattener
docker build . -f Dockerfile -t ${{ secrets.REPONAME }}/${FLATTENER_PROCESSOR}:${IMG_TAG}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
- name: Login to DockerHub
uses: docker/login-action@v1
@ -139,13 +146,18 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push flattener processor docker image
- name: Build & Push Flattener Processor Docker Image
shell: bash
env:
FLATTENER_DIRECTORY: "pkg/processors/flattener"
REPONAME: ${{ secrets.REPONAME }}
FLATTERNER_DOCKER_IMAGE: ${FLATTENER_PROCESSOR}
DOCKER_TAG: ${IMG_TAG}
run: |
branch=${GITHUB_REF#refs/*/}
array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`)
if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]]
then
source env-vars
docker push ${{ secrets.REPONAME }}/${FLATTENER_PROCESSOR}:${IMG_TAG}
fi
make build-push-flattener
fi

69
Makefile Normal file
View File

@ -0,0 +1,69 @@
# Reference Guide - https://www.gnu.org/software/make/manual/make.html
#
# Internal variables or constants.
#
FRONTEND_DIRECTORY ?= frontend
FLATTENER_DIRECTORY ?= pkg/processors/flattener
QUERY_SERVICE_DIRECTORY ?= pkg/query-service
REPONAME ?= signoz
DOCKER_TAG ?= latest
FRONTEND_DOCKER_IMAGE ?= frontend
FLATTERNER_DOCKER_IMAGE ?= query-service
QUERY_SERVICE_DOCKER_IMAGE ?= flattener-processor
all: build-push-frontend build-push-query-service build-push-flattener
# Steps to build and push docker image of frontend
.PHONY: build-frontend-amd64 build-push-frontend
# Step to build docker image of frontend in amd64 (used in build pipeline)
build-frontend-amd64:
@echo "------------------"
@echo "--> Building frontend docker image for amd64"
@echo "------------------"
@cd $(FRONTEND_DIRECTORY) && \
docker build -f Dockerfile --no-cache -t $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETPLATFORM="linux/amd64"
# Step to build and push docker image of frontend(used in push pipeline)
build-push-frontend:
@echo "------------------"
@echo "--> Building and pushing frontend docker image"
@echo "------------------"
@cd $(FRONTEND_DIRECTORY) && \
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/amd64 --tag $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) .
# Steps to build and push docker image of query service
.PHONY: build-query-service-amd64 build-push-query-service
# Step to build docker image of query service in amd64 (used in build pipeline)
build-query-service-amd64:
@echo "------------------"
@echo "--> Building query-service docker image for amd64"
@echo "------------------"
@cd $(QUERY_SERVICE_DIRECTORY) && \
docker build -f Dockerfile --no-cache -t $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETPLATFORM="linux/amd64"
# Step to build and push docker image of query in amd64 and arm64 (used in push pipeline)
build-push-query-service:
@echo "------------------"
@echo "--> Building and pushing query-service docker image"
@echo "------------------"
@cd $(QUERY_SERVICE_DIRECTORY) && \
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/arm64,linux/amd64 --tag $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) .
# Steps to build and push docker image of flattener
.PHONY: build-flattener-amd64 build-push-flattener
# Step to build docker image of flattener in amd64 (used in build pipeline)
build-flattener-amd64:
@echo "------------------"
@echo "--> Building flattener docker image for amd64"
@echo "------------------"
@cd $(FLATTENER_DIRECTORY) && \
docker build -f Dockerfile --no-cache -t $(REPONAME)/$(FLATTERNER_DOCKER_IMAGE):$(DOCKER_TAG) . --build-arg TARGETPLATFORM="linux/amd64"
# Step to build and push docker image of flattener in amd64 (used in push pipeline)
build-push-flattener:
@echo "------------------"
@echo "--> Building and pushing flattener docker image"
@echo "------------------"
@cd $(FLATTENER_DIRECTORY) && \
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/arm64,linux/amd64 --tag $(REPONAME)/$(FLATTERNER_DOCKER_IMAGE):$(DOCKER_TAG) .

View File

@ -1,5 +1,11 @@
# stage1 as builder
FROM node:12-alpine as builder
FROM node:12.18.0 as builder
# Add Maintainer Info
LABEL maintainer="signoz"
ARG TARGETOS=linux
ARG TARGETARCH
WORKDIR /frontend
@ -14,7 +20,7 @@ COPY . .
# Build the project and copy the files
RUN yarn build
FROM nginx:1.12-alpine
FROM nginx:1.18-alpine
#!/bin/sh

View File

@ -21587,4 +21587,4 @@
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
}
}
}
}

View File

@ -1,9 +1,16 @@
FROM golang:1.14-buster AS builder
# Add Maintainer Info
LABEL maintainer="signoz"
ARG TARGETPLATFORM
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
ENV GOPATH=/go
RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
# Prepare and enter src directory
WORKDIR /go/src/github.com/signoz/signoz/pkg/processors/flattener

View File

@ -1,9 +1,16 @@
FROM golang:1.14-buster AS builder
# Add Maintainer Info
LABEL maintainer="signoz"
ARG TARGETPLATFORM
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
ENV GOPATH=/go
RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
# Prepare and enter src directory
WORKDIR /go/src/github.com/signoz/signoz/pkg/query-service