FROM ubuntu:22.04

ARG CHORAL_VERSION

RUN apt-get -y update

# Install tools
RUN apt-get -y install curl gnupg ca-certificates net-tools sudo unzip nano

# Install java
RUN apt-get -y install openjdk-11-jre

USER root
WORKDIR /home

# copy choral
COPY choral_linux_${CHORAL_VERSION}.deb choral_linux_${CHORAL_VERSION}.deb

# install choral service
RUN dpkg -i choral_linux_${CHORAL_VERSION}.deb

# expose choral service port
EXPOSE 8128

# link logfiles to stdout/stderr
RUN touch /opt/chemaxon/choral/logs/choral-out.log
RUN touch /opt/chemaxon/choral/logs/choral-error.log
RUN ln -sf /proc/1/fd/1 /opt/chemaxon/choral/logs/choral-out.log \
    && ln -sf /proc/1/fd/2 /opt/chemaxon/choral/logs/choral-error.log

COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
