FROM debian:9

ENV USER docker-build

ARG VCS_URL=https://core.tcl.tk/tclquadcode
LABEL org.label-schema.vcs-url=$VCS_URL \
	org.label-schema.docker.schema-version="1.0"

RUN apt-get update && \
	apt-get install -y git curl && \
	apt-get install -y libssl-dev && \
	apt-get install -y llvm llvm-dev llvm-runtime clang make && \
	apt-get install -y tcl8.6 tcl8.6-dev && \
	mkdir -p /tmp/build /tmp/build/llvmtcl /tmp/build/tclquadcode /tmp/build/tcllib /tmp/build/fossil && \
	git clone https://github.com/dkfellows/llvmtcl /tmp/build/llvmtcl && \
	cd /tmp/build/llvmtcl && ./configure --prefix=/usr --with-tcl=/usr/lib/tcl8.6 && make && make install && \
	cd /tmp/build/fossil && curl 'http://fossil-scm.org/index.html/uv/fossil-src-2.3.tar.gz' | gzip -dc | tar -xf - && \
	cd /tmp/build/fossil/* && ./configure && make && cp fossil /usr/bin && \
	fossil clone https://core.tcl.tk/tcllib /tmp/build/tcllib/.repo && \
	cd /tmp/build/tcllib && fossil open /tmp/build/tcllib/.repo tcllib-1-18 && ./configure --prefix=/usr && make && make install && \
	rm -rf /tmp/build && \
	mkdir -p /opt/tclquadcode && \
	fossil clone $VCS_URL /opt/tclquadcode/.repo && \
	cd /opt/tclquadcode && fossil open .repo && \
	apt-get remove -y curl git libssl-dev llvm llvm-dev llvm-runtime clang make tcl8.6-dev && \
	apt-get autoremove -y && \
	apt-get install -y ca-certificates binutils && \
	apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
