From e97e03d62e1fbc3d65e3f3d609f40e8be87f5c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Va=C5=A1ko?= Date: Thu, 28 Nov 2024 13:31:19 +0100 Subject: [PATCH] feat: Add new dockerfile to build the image with -race Generate 2 images instead of one, push them into container registry. Update local deployment of minikube to run always with race detector --- .github/workflows/release-service-stream.yml | 26 ++++++++++++++ provisioning/stream/docker/service/Dockerfile | 1 - .../stream/docker/service/race/Dockerfile | 35 +++++++++++++++++++ provisioning/stream/local.sh | 4 +-- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 provisioning/stream/docker/service/race/Dockerfile diff --git a/.github/workflows/release-service-stream.yml b/.github/workflows/release-service-stream.yml index 1b0cc5971d..d9773c48cc 100644 --- a/.github/workflows/release-service-stream.yml +++ b/.github/workflows/release-service-stream.yml @@ -76,6 +76,14 @@ jobs: context: . file: provisioning/stream/docker/service/Dockerfile + - name: Build Service image with race detector + uses: docker/build-push-action@v6 + with: + load: true + tags: ${{ env.IMAGE_NAME }}-race:${{ env.IMAGE_TAG }} + context: . + file: provisioning/stream/docker/service/race/Dockerfile + - name: Push Service image to Amazon ECR, Azure ACR and GCP GAR uses: ./.github/actions/push-image-aws-azure-gcp with: @@ -92,6 +100,24 @@ jobs: acrRepository: ${{ env.ACR_REPOSITORY }} acrUsername: ${{ env.ACR_USERNAME }} acrPassword: ${{ secrets.STREAM_ACR_PASSWORD }} + + - name: Push Service image with race detector to Amazon ECR, Azure ACR and GCP GAR + uses: ./.github/actions/push-image-aws-azure-gcp + with: + imageName: ${{ env.IMAGE_NAME }}-race + imageTag: ${{ env.IMAGE_TAG }} + ecrRegion: ${{ env.ECR_REGION }} + ecrRepository: ${{ env.ECR_REPOSITORY }} + ecrPushRole: ${{ env.ECR_PUSH_ROLE }} + gcpRegistry: ${{ env.GCP_REGISTRY }} + gcpRepository: ${{ env.GCP_REPOSITORY }} + gcpIdentityProvider: ${{ env.GCP_IDENTITY_PROVIDER }} + gcpServiceAccount: ${{ env.GCP_ACCOUNT }} + acrRegistry: ${{ env.ACR_REGISTRY }} + acrRepository: ${{ env.ACR_REPOSITORY }} + acrUsername: ${{ env.ACR_USERNAME }} + acrPassword: ${{ secrets.STREAM_ACR_PASSWORD }} + - name: Trigger image tag update uses: keboola/kbc-stacks/.github/actions/trigger-image-tag-update@main with: diff --git a/provisioning/stream/docker/service/Dockerfile b/provisioning/stream/docker/service/Dockerfile index 34d0295ef7..7bb59d40c7 100644 --- a/provisioning/stream/docker/service/Dockerfile +++ b/provisioning/stream/docker/service/Dockerfile @@ -1,7 +1,6 @@ # Build container FROM golang:1.23.3-alpine3.20 AS buildContainer RUN apk add -U --no-cache bash make curl -RUN apk add --no-cache --update gcc g++ WORKDIR /app COPY Makefile Makefile diff --git a/provisioning/stream/docker/service/race/Dockerfile b/provisioning/stream/docker/service/race/Dockerfile new file mode 100644 index 0000000000..889e75291a --- /dev/null +++ b/provisioning/stream/docker/service/race/Dockerfile @@ -0,0 +1,35 @@ +# Build container +FROM golang:1.23.3-alpine3.20 AS buildContainer +RUN apk add -U --no-cache bash make curl +RUN apk add --no-cache --update gcc g++ +WORKDIR /app + +COPY Makefile Makefile +COPY scripts scripts +RUN make tools + +COPY go.mod go.mod +COPY go.sum go.sum +RUN go mod download + +COPY . . +RUN make build-stream-service-race + +# Production container +FROM alpine:3.20 +RUN apk add -U --no-cache ca-certificates git + +COPY --from=buildContainer /app/target/stream/service /app/service +WORKDIR /app + +# Storage writer ingress - UDP port +EXPOSE 6000 + +# HTTP source +EXPOSE 7000 + +# API +EXPOSE 8000 + +# Prometheus metrics +EXPOSE 9000 diff --git a/provisioning/stream/local.sh b/provisioning/stream/local.sh index eb8e915352..585e0228f1 100644 --- a/provisioning/stream/local.sh +++ b/provisioning/stream/local.sh @@ -65,9 +65,9 @@ fi # Build Docker image in the local Docker, so it is cached, if Minikube is destroyed SERVICE_IMAGE="$STREAM_IMAGE_REPOSITORY:$STREAM_IMAGE_TAG" echo -echo "Building Service image ..." +echo "Building Service image with race detector ..." echo "--------------------------" -docker build -t "$SERVICE_IMAGE" -f "./docker/service/Dockerfile" "../../" +docker build -t "$SERVICE_IMAGE" -f "./docker/service/race/Dockerfile" "../../" echo # Load the images to the Minikube