Skip to content

Commit

Permalink
feat: Add new dockerfile to build the image with -race
Browse files Browse the repository at this point in the history
Generate 2 images instead of one, push them into container registry.
Update local deployment of minikube to run always with race detector
  • Loading branch information
Matovidlo committed Nov 28, 2024
1 parent 6488153 commit e97e03d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release-service-stream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion provisioning/stream/docker/service/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 35 additions & 0 deletions provisioning/stream/docker/service/race/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions provisioning/stream/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e97e03d

Please sign in to comment.