FROM debian:bullseye

# Se instalan las herramientas necesarias para configurar el source list
RUN apt-get update && \
	apt-get install -y --no-install-recommends lsb-release apt-transport-https \
	ca-certificates wget vim curl git unzip gnupg2 make cmake gcc build-essential && \
	apt-get clean

# Se agrega el source list para instalar PHP 7
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
	echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php7.4.list

# Se instala PHP 7.4 y Python.
RUN apt-get update && \
	apt-get install -y php7.4 php7.4-mysql php7.4-zip php7.4-pdo php7.4-mysqli && \
	apt-get install -y php7.4-mbstring php7.4-gd php7.4-dom php7.4-curl && \
	apt-get install -y python && \
	apt-get clean

# Para instalar composer.
RUN cd ~
RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php

RUN php /tmp/composer-setup.php --version=2.2.4 --install-dir=/usr/local/bin --filename=composer

# Para nvm
SHELL ["/bin/bash", "--login", "-c"]
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

RUN nvm install 20.14.0 && npm i -g @ionic/cli@7.2.0 && npm i -g cordova-res
RUN ln -s "$(which node)" /usr/bin/node
RUN ln -s "$(which npm)" /usr/bin/npm
RUN ln -s "$(which ionic)" /usr/bin/ionic

VOLUME /opt/app/front_end

COPY ./sh/run_front_compile.sh /opt/app/sh/run.sh
COPY ./apache2/.htaccess /opt/app/apache2/.htaccess

ENTRYPOINT [ "sh", "/opt/app/sh/run.sh" ]