FROM --platform=linux/amd64 almalinux:8.10

SHELL ["/bin/bash", "-c"]

RUN yum -y update

RUN yum -y install make sudo

RUN sudo yum -y install git wget gcc-toolset-9

RUN scl enable gcc-toolset-9 bash

COPY . /cli/

RUN export GO_VERSION=$(cat /cli/.go-version) && \
    wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" && \
    sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"

ENV PATH=${PATH}:/usr/local/go/bin:/root/go/bin

RUN cd /cli/ && \
    CGO_ENABLED=1 GOEXPERIMENT=boringcrypto go build -ldflags="-s -w -X main.commit="00000000" -X main.date="1970-01-01T00:00:00Z" -X main.isTest=true" ./cmd/confluent
