FROM ubuntu:bionic

RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \
    apt-transport-https \
    python3-dev \
    wget \
    curl \
    git \
    mercurial \
    make \
    ruby \
    ruby-dev \
    rpm \
    zip \
    python3-pip \
    autoconf \
    libtool

RUN pip3 install boto requests python-jose --upgrade
RUN gem install fpm

# Install node
ENV NODE_VERSION v14.15.0
RUN wget -q https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz; \
   mkdir /usr/local/node; \
   tar -xvf node-${NODE_VERSION}-linux-x64.tar.gz -C /usr/local/node --strip-components=1; \
   rm -f node-${NODE_VERSION}-linux-x64.tar.gz
ENV PATH=/usr/local/node/bin:$PATH

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&  \
    apt-get update -y && apt-get install yarn -y

# Install go
ENV GOPATH /root/go
ENV GO_VERSION 1.16.4
ENV GO_ARCH amd64
ENV GO111MODULES ON
RUN wget https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz; \
   tar -C /usr/local/ -xf /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz ; \
   rm /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz
ENV PATH /usr/local/go/bin:$PATH

ENV PROJECT_DIR $GOPATH/src/github.com/influxdata/chronograf
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR

VOLUME $PROJECT_DIR

ENTRYPOINT [ "/root/go/src/github.com/influxdata/chronograf/etc/build.py" ]
