# Use working FTS versions from Dockerfile
FROM ubuntu:20.04

LABEL maintainer=FreeTAKTeam

ARG FTS_VERSION=1.9
ARG FTS_UI_VERSION=1.8.1

# UTC for buildtimes
RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime

# APT
RUN apt-get update && \
    apt-get install -y libssl-dev libffi-dev curl python3 python3-pip \
            libxml2-dev libxslt-dev python3-lxml python3-dev \
            python3-setuptools build-essential iproute2 &&\
    rm -rf /var/lib/apt/lists/*

# PIP3
RUN pip3 install supervisor &&\
    pip3 install "requests==2.28.1" &&\
    pip3 install "flask-login==0.5.0" &&\
    pip3 install "FreeTAKServer==${FTS_VERSION}" && \
    pip3 install "FreeTAKServer-UI==${FTS_UI_VERSION}" && \
    pip3 install defusedxml &&\
    pip3 install pyopenssl &&\
    pip3 install pytak && \
    pip3 install "markupsafe==2.0.1" && \
    pip3 install "jinja2==3.0.3" && \
    pip3 install "flask==2.0.3" && \
    pip3 install "werkzeug==2.0.3"

# Create FTS user
RUN addgroup --gid 1000 fts && \
    adduser --disabled-password --uid 1000 --ingroup fts --home /home/fts fts

# Copy configuration files (will be provided at runtime)
COPY docker-run.sh /home/fts/docker-run.sh
RUN chmod +x /home/fts/docker-run.sh

# FTS ports
EXPOSE 8080 8087 8089 8443 9000 19023 5000

WORKDIR /home/fts
USER fts

CMD ["/home/fts/docker-run.sh"]
