FROM ubuntu:22.04

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

ARG VERSION=1.20.3
ARG GOOS=linux
ARG GOARCH=amd64

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

#RUN sed 1,3d -i /etc/dpkg/dpkg.cfg.d/excludes && \
#RUN sed -i 's:^path-exclude=/usr/share/man:#path-exclude=/usr/share/man:' \
#        /etc/dpkg/dpkg.cfg.d/excludes && \ 
RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y --reinstall man manpages-posix coreutils wget curl gcc git aspell aspell-en pandoc zip awscli

# 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 && \
    ln -sv /go/bin/murex /bin/murex && \
    go install golang.org/x/tools/cmd/stringer@latest && \
    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 purge --auto-remove -y && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*

COPY ./test/cat.1.gz /usr/share/man/man1/cat.1.gz
ADD . .

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