diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..975164c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +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"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index aadec81..11cecb1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,48 @@ +# docker-compose.yaml +# https://www.devpowerup.com/php-docker version: '3' + services: - php: - build: .docker - restart: always - volumes: - - .:/var/www/html/urfat \ No newline at end of file + app: + build: + context: . + dockerfile: docker/Dockerfile + container_name: app + tty: true + depends_on: + - db + environment: + DATABASE_URL: postgresql://dbuser:bigsecret@127.0.0.1:5432/devdb + working_dir: /var/www + volumes: + - ./:/var/www + + webserver: + image: nginx:stable + container_name: webserver + restart: always + ports: + - "8080:80" + depends_on: + - app + volumes: + - ./:/var/www + - ./docker/app.conf:/etc/nginx/conf.d/default.conf + links: + - app + + db: + image: postgres:14 + container_name: db + restart: always + volumes: + - db_data:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: devsecret + POSTGRES_USER: devuser + POSTGRES_DB: devdb + ports: + - "5432:5432" + +volumes: + db_data: \ No newline at end of file