# Dockerfile

FROM      amd64/ubuntu

WORKDIR    /var/app

# Update and install common packages
RUN        apt -y update
RUN        DEBIAN_FRONTEND="noninteractive" apt -y upgrade
RUN        DEBIAN_FRONTEND="noninteractive" apt -y install software-properties-common
RUN        DEBIAN_FRONTEND="noninteractive" apt -y install curl git tar zip wget nano ffmpeg gcc locales
RUN        locale-gen en_US.UTF-8
RUN        dpkg-reconfigure locales

# import env vars for subprocess commands
ENV        LANG en_US.UTF-8
ENV        LANGUAGE en_US:en
ENV        LC_ALL en_US.UTF-8

# Install python 3.6 and wsgi dependencies
RUN        apt -y install python3-pip python3-venv

# Install latest ffmpeg
#RUN        wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
#RUN        tar -xvf ffmpeg-release-amd64-static.tar.xz
#RUN        mv ffmpeg-4.3.1-amd64-static/ffmpeg /usr/local/bin
#RUN        mv ffmpeg-4.3.1-amd64-static/ffprobe /usr/local/bin
#RUN        ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg
#RUN        ln -s /usr/local/bin/ffprobe /usr/bin/ffprobe

# Create and configure virtualenv and uwsgi
RUN        python3 -m venv /var/app
RUN        /var/app/bin/pip3 install --upgrade pip
RUN        useradd worker -s /bin/false

# Add application and install requirements
ADD        index.py /var/app
ADD        requirements.txt /var/app
ADD        FreigMicMedIta.ttf /var/app

RUN        if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -I -r /var/app/requirements.txt; fi

RUN        chown -R worker /var/app

# Set service user
USER       worker

CMD ["ffmpeg", "-version"]