FROM centos:7.6.1810

RUN yum -y update

RUN yum -y install curl wget vim git

RUN curl --silent --location https://rpm.nodesource.com/setup_14.x | bash -

RUN yum -y install nodejs

RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo

RUN rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg

RUN yum -y install yarn

ARG VERSION

RUN wget https://dl.google.com/go/go1.17.1.linux-amd64.tar.gz

RUN tar -C /usr/local -xzf go1.17.1.linux-amd64.tar.gz

RUN echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.bash_profile && \
	source ~/.bash_profile

RUN echo "$VERSION ver 4"

RUN git clone http://gitlab.hiperpbx.com/javier.larrosa/web-console.git 

RUN cd web-console/web && \
	yarn install && \
	yarn build
	
RUN cd /web-console/web && \
	git clone https://github.com/rakyll/statik

RUN cd /web-console/web/statik && \
	/usr/local/go/bin/go build && \
	cp -a statik /usr/sbin/
	
RUN cd /web-console && \
	statik -src=web/build && \
	/usr/local/go/bin/go install && \
	/usr/local/go/bin/go build

ADD VERSION /web-console/VERSION

ADD changelog /web-console/changelog
	
WORKDIR /web-console

ADD start.sh /web-console/start.sh

CMD ./start.sh
