From 7774d25f40f1e4c6000925dab500c96aa58aeff7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 25 Sep 2023 14:20:44 +0200 Subject: [PATCH] init --- .docker/Dockerfile | 53 +++++++++++++++++++++++++++++++++++++ .docker/docker-compose.yml | 40 ++++++++++++++++++++++++++++ .docker/init.sh | 13 +++++++++ .idea/.gitignore | 8 ++++++ .idea/WebServerSkeleton.iml | 8 ++++++ .idea/encodings.xml | 4 +++ .idea/modules.xml | 8 ++++++ .idea/php.xml | 19 +++++++++++++ README.md | 29 +++++++++++++++++++- logs/tbserver-cron-log.txt | 0 logs/tbserver-log.txt | 0 public/index.php | 3 +++ 12 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 .docker/Dockerfile create mode 100644 .docker/docker-compose.yml create mode 100644 .docker/init.sh create mode 100644 .idea/.gitignore create mode 100644 .idea/WebServerSkeleton.iml create mode 100644 .idea/encodings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 logs/tbserver-cron-log.txt create mode 100644 logs/tbserver-log.txt create mode 100755 public/index.php diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..b62d220 --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,53 @@ +FROM php:8.1-apache + +ENV APACHE_DOCUMENT_ROOT /var/www/html/public +ENV APACHE_SERVER_NAME localhost +ENV PATH="$PATH" +WORKDIR /var/www/html + +RUN apt-get update + +RUN apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + libicu-dev \ + && docker-php-ext-install -j$(nproc) iconv \ + && docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd \ + && docker-php-ext-install -j$(nproc) intl \ + && docker-php-ext-install -j$(nproc) pdo_mysql + +RUN apt-get install -y git zip + +RUN apt install nano + +RUN pecl install xdebug-3.1.5 \ + && docker-php-ext-enable xdebug \ + && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.client_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo 'xdebug.discover_client_host=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo 'xdebug.log=/var/www/var/log/xdebug.log' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo 'xdebug.log_level=0' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +RUN a2enmod rewrite && a2enmod headers +RUN a2ensite 000-default + +COPY ./ /var/www/html + +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + + +RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" + +RUN chown -R www-data:www-data /var/www/html/ + +COPY /init.sh /init.sh +RUN chmod 755 /init.sh +RUN chmod +x /init.sh +EXPOSE 80 + +ENTRYPOINT ["/init.sh"] +CMD ["apache2-foreground"] \ No newline at end of file diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml new file mode 100644 index 0000000..771ca92 --- /dev/null +++ b/.docker/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3.7' + +services: + database: + image: mariadb + container_name: skeleton-mariadb + ports: + - "3401:3306" + environment: + # think about .env file here + MYSQL_ROOT_PASSWORD: root + volumes: + - ./../.db:/var/lib/mysql + restart: always + networks: + - default + php: + build: + context: ./ + dockerfile: Dockerfile + image: 'skeleton_php' + container_name: skeleton-php + ports: + - '8101:80' + volumes: + - ./../:/var/www/html + networks: + - default + phpmyadmin: + image: phpmyadmin + container_name: skeleton-phpmyadmin + restart: always + ports: + - "8102:80" + environment: + - PMA_ARBITRARY=1 + networks: + - default +networks: + default: \ No newline at end of file diff --git a/.docker/init.sh b/.docker/init.sh new file mode 100644 index 0000000..e88c9ca --- /dev/null +++ b/.docker/init.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +echo "create log files" + +su www-data -s /bin/bash +mkdir /var/www/html/temp +mkdir /var/www/html/logs +cd /var/www/html/logs +touch tbserver-log.txt +touch tbserver-cron-log.txt + +echo "$@" +docker-php-entrypoint "$@" diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/WebServerSkeleton.iml b/.idea/WebServerSkeleton.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/WebServerSkeleton.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d1ae912 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f324872 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index d4f9058..acec19e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ -# web-server-skeleton +# contao-docker-test +#Installation: + +# Some important information + +# Some helpful docker commands: +- `docker-compose up -d` +- `docker-compose down` +- `docker exec -it tb-con-tbuddy /bin/bash` +- `docker build -t tb-con-tbuddy .` +- `docker image rm tb_spt_image` +- `docker ps` +- `docker ps --all` +- `docker container stop $(docker container ls -aq)` +- `docker container rm $(docker container ls -aq)` +- `docker rmi $(docker images -q)` +- `docker stop spt_tbuddy && docker rm spt_tbuddy && docker rmi spt_tb && docker-compose up -d` + +# Some helpful other commands: +- Restart Apache within the container + - Go into docker container `docker exec -it spt_tbuddy /bin/bash` + - Apache restart `sudo /etc/init.d/apache2 reload` + +# Clean restart of Docker instance +1. Stop the container(s) using the following command: `docker-compose down` +2. Delete all containers using the following command: `docker rm -f $(docker ps -a -q)` +3. Delete all volumes using the following command: `docker volume rm $(docker volume ls -q)` +4. Restart the containers using the following command: `docker-compose up -d` \ No newline at end of file diff --git a/logs/tbserver-cron-log.txt b/logs/tbserver-cron-log.txt new file mode 100644 index 0000000..e69de29 diff --git a/logs/tbserver-log.txt b/logs/tbserver-log.txt new file mode 100644 index 0000000..e69de29 diff --git a/public/index.php b/public/index.php new file mode 100755 index 0000000..2031d3d --- /dev/null +++ b/public/index.php @@ -0,0 +1,3 @@ + + +
hello
\ No newline at end of file