FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive \
    DEBCONF_NONINTERACTIVE_SEEN=true \
    GOPATH=/go

ARG VERSION=1.18.3
ARG GOOS=linux
ARG GOARCH=amd64

VOLUME /go/bin
WORKDIR /go/src/github.com/lmorg/murex

RUN apt-get update && apt-get install -y wget git gcc

# install golang and sources
RUN mkdir -p /go && cd /go && \
    wget https://dl.google.com/go/go${VERSION}.${GOOS}-${GOARCH}.tar.gz && \
    tar xf go${VERSION}.${GOOS}-${GOARCH}.tar.gz && \
    rm -v go${VERSION}.${GOOS}-${GOARCH}.tar.gz && \
    ln -sv /go/go/bin/go /bin/go && \
    go get -u golang.org/x/tools/cmd/stringer && \
    ln -sv /go/bin/murex /bin/murex && \
    ln -sv /go/bin/docgen /bin/docgen && \
    ln -sv /go/src/github.com/lmorg/murex/test/buildserver/ci.env /etc/ci-murex.env

# clean up
RUN apt-get remove -y wget git && \
    apt-get autoremove -y && \
    apt-get purge --auto-remove -y && \
    apt-get clean && \
    rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*

ADD . .

ENTRYPOINT /go/src/github.com/lmorg/murex/test/ci-murex.sh
