FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

## INSTALL DEPENDENCIES
RUN apt-get update && \
    apt-get install -yq \
                    git gdb curl expect g++ make libssl-dev \
                    libxml2-dev libncurses5-dev flex bison \
                    libsctp-dev xutils-dev ant xsltproc automake perl sudo \
                    libedit2 libedit-dev

## CREATE SUDOER USER
RUN useradd --create-home --shell /bin/bash titan && \
    adduser --disabled-password titan sudo && \
    echo "titan ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
USER titan

## SET UP ENV VARIABLES
ENV TTCN3_DIR=/home/titan/titan.core/Install
ENV PATH=$TTCN3_DIR/bin:$PATH \
    LD_LIBRARY_PATH=$TTCN3_DIR/lib:$LD_LIBRARY_PATH

## CLONE TITAN
WORKDIR /home/titan/
RUN git clone https://gitlab.eclipse.org/eclipse/titan/titan.EclipsePlug-ins.git
# Checkout release 11.1.0
WORKDIR /home/titan/titan.core
RUN git checkout tags/11.1.0

## SET Makefile.personal
# TTCN3_DIR := /home/titan/titan.core/Install
# XMLDIR := /usr
# OPENSSL_DIR := /usr
# JNI := no
# GEN_PDF := no
COPY Makefile.personal-ubuntu Makefile.personal

## BUILD TITAN
RUN make install

WORKDIR /home/titan
CMD compiler -v && /bin/bash
