FROM ubuntu:24.04
MAINTAINER "Andrea Valtulina" <andrea.valtulina@bitonlive.com>

LABEL Description="Streamer V25"

#SHELL ["/bin/bash", "-c"]
# Install dipendencies
RUN apt-get update && apt-get install -y \
        apt-utils \
        build-essential \
        openssl \
        libssl-dev \
        openssh-client \
        openssh-server \
        iputils-ping \
        net-tools \
        locales \
        cron \
        curl \
        wget \
        nano \
        unzip \
        software-properties-common \
        mysql-client \
        ffmpeg \
    apache2 \
    nginx

ENV DEBIAN_FRONTEND=noninteractive
#################  no!!! ENV TZ Europe/Rome

#RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
#RUN add-apt-repository -y ppa:ondrej/php

#RUN apt-get update && apt-get install -y \
#       php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-mysql php7.0-xml \
#       php7.0-dev php-ssh2 php7.0-soap php7.0-curl php7.0-zip \#
#       nodejs

#RUN npm i pm2 -g
ENV NVMPATH=/root/.nvm/versions/node/v24.2.0/bin/

ENV PATH=$PATH:$NVMPATH

RUN apt install curl gpg gnupg2 software-properties-common ca-certificates apt-transport-https lsb-release -y
RUN add-apt-repository ppa:ondrej/php
RUN apt update -y
RUN apt install -y php8.3 
RUN apt install -y php8.3-cli php8.3-pdo php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-common php8.3-mcrypt  php8.3-ssh2


RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
RUN chmod +x "$HOME/.nvm/nvm.sh"
#
#  dafare ne docker manualmente
#
RUN bash -c "source /root/.nvm/nvm.sh && nvm install 24.2.0"
#RUN "$HOME/.nvm/nvm.sh" && nvm install 24
#RUN nvm install 24
RUN npm i -g yarn
RUN npm i -g pm2

RUN locale-gen it_IT.UTF-8
ENV LANG it=IT.UTF-8
ENV LANGUAGE=it_IT:it
ENV LC_ALL=it_IT.UTF-8


COPY default /etc/nginx/sites-available

COPY check_streamer.sh /root/
RUN chmod +x /root/check_streamer.sh
RUN mkdir /var/www/streamerv2

COPY ioncube_loader_lin_8.3.so /usr/lib/php/20230831/
COPY ioncube_loader_lin_8.3_ts.so /usr/lib/php/20230831/
RUN echo "zend_extension=/usr/lib/php/20230831/ioncube_loader_lin_8.3.so" > /etc/php/8.3/cli/conf.d/00-ioncube.ini

RUN curl -o  /var/www/streamerv2/streamerV3.zip http://software.bitonlive.net/cinema/streamerV2/streamerV3.zip
RUN unzip  /var/www/streamerv2/streamerV3.zip -d /var/www/streamerv2/

WORKDIR /var/www/streamerv2/api/
RUN   yarn install
RUN   pm2 start app.dist.js

VOLUME [ "/datastore" ]
CMD ["/root/check_streamer.sh"]
