Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build stream dev images with race #2159

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ run-templates-api:
build-stream-service:
CGO_ENABLED=0 go build -v -mod mod -ldflags "-s -w" -o "$(or $(BUILD_TARGET_PATH), ./target/stream/service)" ./cmd/stream

build-stream-service-with-race:
CGO_ENABLED=1 go build -race -v -mod mod -ldflags "-s -w" -o "$(or $(BUILD_TARGET_PATH), ./target/stream/service)" ./cmd/stream

run-stream-service:
rm -rf /tmp/stream-volumes && \
mkdir -p /tmp/stream-volumes/hdd/my-volume && \
air -c ./provisioning/stream/dev/.air.toml

run-stream-service-once: build-stream-service
run-stream-service-once: build-stream-service-with-race
./target/stream/service api http-source storage-writer storage-reader storage-coordinator

build-apps-proxy:
Expand Down
2 changes: 1 addition & 1 deletion provisioning/apps-proxy/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY . .
RUN make build-apps-proxy

# Production container
FROM alpine:3.19
FROM alpine:3.20
RUN apk add -U --no-cache ca-certificates git

COPY --from=buildContainer /app/target/apps-proxy/proxy /app/server
Expand Down
3 changes: 1 addition & 2 deletions provisioning/dev/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ ENV GOLANGCI_LINT_CACHE=/tmp/cache/golangci-lint
ENV PATH="$PATH:$GOBIN"

# Install packages
RUN apt-get update && apt-get install -y nano protobuf-compiler
RUN apt-get update && apt-get install --no-install-recommends --yes nano protobuf-compiler graphviz build-essential
ENV EDITOR=nano

# Install tools
RUN mkdir -p /tmp/build
COPY Makefile /tmp/build/Makefile
COPY scripts /tmp/build/scripts
RUN cd /tmp/build && make tools && cd / && rm -rf /tmp/build && go clean -cache -modcache
RUN apt update && apt install -y graphviz

# Install envsubstr and helm
RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-$(uname -s)-$(uname -m) -o /usr/local/bin/envsubst && \
Expand Down
2 changes: 1 addition & 1 deletion provisioning/stream/docker/service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY . .
RUN make build-stream-service

# Production container
FROM alpine:3.19
FROM alpine:3.20
RUN apk add -U --no-cache ca-certificates git

COPY --from=buildContainer /app/target/stream/service /app/service
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
# gcc and g++ are needed for CGO_ENABLED racer
RUN apk add --update --no-cache bash make curl 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-with-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
2 changes: 1 addition & 1 deletion provisioning/templates-api/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY . .
RUN make build-templates-api

# Production container
FROM alpine:3.19
FROM alpine:3.20
RUN apk add -U --no-cache ca-certificates git

COPY --from=buildContainer /app/target/templates/api /app/server
Expand Down
Loading