FROM ubuntu:20.04

# Atualizar o sistema operacional e instalar pacotes necessários
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:ondrej/php
RUN apt-get update

RUN apt-get install -y postgresql sqlite3 sudo vim
RUN sudo -u postgres pg_ctlcluster 12 main start
RUN service postgresql start

RUN apt-get install -y apache2 php8.0 php8.0-cli php8.0-common hp8.0-opcache php8.0-pgsql php8.0-sqlite php8.0-zip php8.0-gd libapache2-mod-php8.0

# Configurar o Apache
RUN a2enmod rewrite
RUN a2enmod php8.0
RUN sed -i 's/\/var\/www\/html/\/var\/www\/html\/public/g' /etc/apache2/sites-available/000-default.conf

# Copiar o conteúdo da aplicação para o diretório /var/www/html
COPY . /var/www/html

# Defina a pasta de trabalho
WORKDIR /var/www/html/public

# Exponha a porta 80 do container
EXPOSE 80

# Inicie o Apache
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
#CMD ["php", "-S", "0.0.0.0:80"]