From 0f2a418a9b5b70cc3885a8f0e7e2500b9745eda5 Mon Sep 17 00:00:00 2001 From: Brian Fertig Date: Sun, 14 Jul 2024 12:57:13 -0600 Subject: [PATCH] initial commit --- .gitignore | 9 ++ LICENSE | 22 +++ README.md | 296 ++++++++++++++++++++++++++++++++++++++ bin/mariadb103/Dockerfile | 1 + bin/mariadb104/Dockerfile | 1 + bin/mariadb105/Dockerfile | 1 + bin/mariadb106/Dockerfile | 1 + bin/mysql57/Dockerfile | 1 + bin/mysql8/Dockerfile | 3 + bin/php54/Dockerfile | 59 ++++++++ bin/php56/Dockerfile | 54 +++++++ bin/php71/Dockerfile | 59 ++++++++ bin/php72/Dockerfile | 69 +++++++++ bin/php73/Dockerfile | 72 ++++++++++ bin/php74/Dockerfile | 90 ++++++++++++ bin/php8/Dockerfile | 104 ++++++++++++++ bin/php81/Dockerfile | 103 +++++++++++++ bin/php82/Dockerfile | 103 +++++++++++++ bin/php83/Dockerfile | 102 +++++++++++++ dev_build_container.sh | 142 ++++++++++++++++++ docker-compose.yml | 87 +++++++++++ sample.env | 63 ++++++++ todo.md | 4 + 23 files changed, 1446 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 bin/mariadb103/Dockerfile create mode 100644 bin/mariadb104/Dockerfile create mode 100644 bin/mariadb105/Dockerfile create mode 100644 bin/mariadb106/Dockerfile create mode 100644 bin/mysql57/Dockerfile create mode 100644 bin/mysql8/Dockerfile create mode 100644 bin/php54/Dockerfile create mode 100644 bin/php56/Dockerfile create mode 100644 bin/php71/Dockerfile create mode 100644 bin/php72/Dockerfile create mode 100644 bin/php73/Dockerfile create mode 100644 bin/php74/Dockerfile create mode 100644 bin/php8/Dockerfile create mode 100644 bin/php81/Dockerfile create mode 100644 bin/php82/Dockerfile create mode 100644 bin/php83/Dockerfile create mode 100644 dev_build_container.sh create mode 100644 docker-compose.yml create mode 100644 sample.env create mode 100644 todo.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfb8958 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/.env +/.vscode +/config/* +/data/* +/logs/* +/www/** +.DS_Store +/buildtest +/vs-code/* \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..55d904d --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2017 Narendra Vaghela +Copyright (c) 2019 Malte Graebner aka (MrOffline77) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..127c177 --- /dev/null +++ b/README.md @@ -0,0 +1,296 @@ +# LAMP stack built with Docker Compose + +![Landing Page](https://user-images.githubusercontent.com/43859895/141092846-905eae39-0169-4fd7-911f-9ff32c48b7e8.png) + +A basic LAMP stack environment built using Docker Compose. It consists of the following: + +- PHP +- Apache +- MySQL +- phpMyAdmin +- Redis + +As of now, we have several different PHP versions. Use appropriate php version as needed: + +- 5.4.x +- 5.6.x +- 7.1.x +- 7.2.x +- 7.3.x +- 7.4.x +- 8.0.x +- 8.1.x +- 8.2.x +- 8.3.x + +## Installation + +- Clone this repository on your local computer +- configure .env as needed +- Run the `docker compose up -d`. + +```shell +git clone https://github.com/sprintcube/docker-compose-lamp.git +cd docker-compose-lamp/ +cp sample.env .env +// modify sample.env as needed +docker compose up -d +// visit localhost +``` + +Your LAMP stack is now ready!! You can access it via `http://localhost`. + +## Configuration and Usage + +### General Information + +This Docker Stack is build for local development and not for production usage. + +### Configuration + +This package comes with default configuration options. You can modify them by creating `.env` file in your root directory. +To make it easy, just copy the content from `sample.env` file and update the environment variable values as per your need. + +### Configuration Variables + +There are following configuration variables available and you can customize them by overwritting in your own `.env` file. + +--- + +#### PHP + +--- + +_**PHPVERSION**_ +Is used to specify which PHP Version you want to use. Defaults always to latest PHP Version. + +_**PHP_INI**_ +Define your custom `php.ini` modification to meet your requirments. + +--- + +#### Apache + +--- + +_**DOCUMENT_ROOT**_ + +It is a document root for Apache server. The default value for this is `./www`. All your sites will go here and will be synced automatically. + +_**APACHE_DOCUMENT_ROOT**_ + +Apache config file value. The default value for this is /var/www/html. + +_**VHOSTS_DIR**_ + +This is for virtual hosts. The default value for this is `./config/vhosts`. You can place your virtual hosts conf files here. + +> Make sure you add an entry to your system's `hosts` file for each virtual host. + +_**APACHE_LOG_DIR**_ + +This will be used to store Apache logs. The default value for this is `./logs/apache2`. + +--- + +#### Database + +--- + +> For Apple Silicon Users: +> Please select Mariadb as Database. Oracle doesn't build their SQL Containers for the arm Architecture + +_**DATABASE**_ + +Define which MySQL or MariaDB Version you would like to use. + +_**MYSQL_INITDB_DIR**_ + +When a container is started for the first time files in this directory with the extensions `.sh`, `.sql`, `.sql.gz` and +`.sql.xz` will be executed in alphabetical order. `.sh` files without file execute permission are sourced rather than executed. +The default value for this is `./config/initdb`. + +_**MYSQL_DATA_DIR**_ + +This is MySQL data directory. The default value for this is `./data/mysql`. All your MySQL data files will be stored here. + +_**MYSQL_LOG_DIR**_ + +This will be used to store Apache logs. The default value for this is `./logs/mysql`. + +## Web Server + +Apache is configured to run on port 80. So, you can access it via `http://localhost`. + +#### Apache Modules + +By default following modules are enabled. + +- rewrite +- headers + +> If you want to enable more modules, just update `./bin/phpX/Dockerfile`. You can also generate a PR and we will merge if seems good for general purpose. +> You have to rebuild the docker image by running `docker compose build` and restart the docker containers. + +#### Connect via SSH + +You can connect to web server using `docker compose exec` command to perform various operation on it. Use below command to login to container via ssh. + +```shell +docker compose exec webserver bash +``` + +## PHP + +The installed version of php depends on your `.env`file. + +#### Extensions + +By default following extensions are installed. +May differ for PHP Versions <7.x.x + +- mysqli +- pdo_sqlite +- pdo_mysql +- mbstring +- zip +- intl +- mcrypt +- curl +- json +- iconv +- xml +- xmlrpc +- gd + +> If you want to install more extension, just update `./bin/webserver/Dockerfile`. You can also generate a PR and we will merge if it seems good for general purpose. +> You have to rebuild the docker image by running `docker compose build` and restart the docker containers. + +## phpMyAdmin + +phpMyAdmin is configured to run on port 8080. Use following default credentials. + +http://localhost:8080/ +username: root +password: tiger + +## Xdebug + +Xdebug comes installed by default and it's version depends on the PHP version chosen in the `".env"` file. + +**Xdebug versions:** + +PHP <= 7.3: Xdebug 2.X.X + +PHP >= 7.4: Xdebug 3.X.X + +To use Xdebug you need to enable the settings in the `./config/php/php.ini` file according to the chosen version PHP. + +Example: + +``` +# Xdebug 2 +#xdebug.remote_enable=1 +#xdebug.remote_autostart=1 +#xdebug.remote_connect_back=1 +#xdebug.remote_host = host.docker.internal +#xdebug.remote_port=9000 + +# Xdebug 3 +#xdebug.mode=debug +#xdebug.start_with_request=yes +#xdebug.client_host=host.docker.internal +#xdebug.client_port=9003 +#xdebug.idekey=VSCODE +``` + +Xdebug VS Code: you have to install the Xdebug extension "PHP Debug". After installed, go to Debug and create the launch file so that your IDE can listen and work properly. + +Example: + +**VERY IMPORTANT:** the `pathMappings` depends on how you have opened the folder in VS Code. Each folder has your own configurations launch, that you can view in `.vscode/launch.json` + +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + // "port": 9000, // Xdebug 2 + "port": 9003, // Xdebug 3 + "pathMappings": { + // "/var/www/html": "${workspaceFolder}/www" // if you have opened VSCODE in root folder + "/var/www/html": "${workspaceFolder}" // if you have opened VSCODE in ./www folder + } + } + ] +} +``` + +Now, make a breakpoint and run debug. + +**Tip!** After theses configurations, you may need to restart container. + +## Redis + +It comes with Redis. It runs on default port `6379`. + +## SSL (HTTPS) + +Support for `https` domains is built-in but disabled by default. There are 3 ways you can enable and configure SSL; `https` on `localhost` being the easiest. If you are trying to recreating a testing environment as close as possible to a production environment, any domain name can be supported with more configuration. + +**Notice:** For every non-localhost domain name you wish to use `https` on, you will need to modify your computers [hosts file](https://en.wikipedia.org/wiki/Hosts_%28file%29) and point the domain name to `127.0.0.1`. If you fail to do this SSL will not work and you will be routed to the internet every time you try to visit that domain name locally. + +### 1) HTTPS on Localhost + +To enable `https` on `localhost` (https://localhost) you will need to: + +1. Use a tool like [mkcert](https://github.com/FiloSottile/mkcert#installation) to create an SSL certificate for `localhost`: + - With `mkcert`, in the terminal run `mkcert localhost 127.0.0.1 ::1`. + - Rename the files that were generated `cert.pem` and `cert-key.pem` respectively. + - Move these files into your docker setup by placing them in `config/ssl` directory. +2. Uncomment the `443` vhost in `config/vhosts/default.conf`. + +Done. Now any time you turn on your LAMP container `https` will work on `localhost`. + +### 2) HTTPS on many Domains with a Single Certificate + +If you would like to use normal domain names for local testing, and need `https` support, the simplest solution is an SSL certificate that covers all the domain names: + +1. Use a tool like [mkcert](https://github.com/FiloSottile/mkcert#installation) to create an SSL certificate that covers all the domain names you want: + - With `mkcert`, in the terminal run `mkcert example.com "*.example.org" myapp.dev localhost 127.0.0.1 ::1` where you replace all the domain names and IP addresses to the ones you wish to support. + - Rename the files that were generated `cert.pem` and `cert-key.pem` respectively. + - Move these files into your docker setup by placing them in `config/ssl` directory. +2. Uncomment the `443` vhost in `config/vhosts/default.conf`. + +Done. Since you combined all the domain names into a single certificate, the vhost file will support your setup without needing to modify it further. You could add domain specific rules if you wish however. Now any time you turn on your LAMP container `https` will work on all the domains you specified. + +### 3) HTTPS on many Domain with Multiple Certificates + +If you would like your local testing environment to exactly match your production, and need `https` support, you could create an SSL certificate for every domain you wish to support: + +1. Use a tool like [mkcert](https://github.com/FiloSottile/mkcert#installation) to create an SSL certificate that covers the domain name you want: + - With `mkcert`, in the terminal run `mkcert [your-domain-name(s)-here]` replacing the bracket part with your domain name. + - Rename the files that were generated to something unique like `[name]-cert.pem` and `[name]-cert-key.pem` replacing the bracket part with a unique name. + - Move these files into your docker setup by placing them in `config/ssl` directory. +2. Using the `443` example from the vhost file (`config/vhosts/default.conf`), make new rules that match your domain name and certificate file names. + +Done. The LAMP container will auto pull in any SSL certificates in `config/ssl` when it starts. As long as you configure the vhosts file correctly and place the SSL certificates in `config/ssl`, any time you turn on your LAMP container `https` will work on your specified domains. + +## Contributing + +We are happy if you want to create a pull request or help people with their issues. If you want to create a PR, please remember that this stack is not built for production usage, and changes should be good for general purpose and not overspecialized. + +> Please note that we simplified the project structure from several branches for each php version, to one centralized master branch. Please create your PR against master branch. +> +> Thank you! + +## Why you shouldn't use this stack unmodified in production + +We want to empower developers to quickly create creative Applications. Therefore we are providing an easy to set up a local development environment for several different Frameworks and PHP Versions. +In Production you should modify at a minimum the following subjects: + +- php handler: mod_php=> php-fpm +- secure mysql users with proper source IP limitations diff --git a/bin/mariadb103/Dockerfile b/bin/mariadb103/Dockerfile new file mode 100644 index 0000000..82c2da0 --- /dev/null +++ b/bin/mariadb103/Dockerfile @@ -0,0 +1 @@ +FROM mariadb:10.3 \ No newline at end of file diff --git a/bin/mariadb104/Dockerfile b/bin/mariadb104/Dockerfile new file mode 100644 index 0000000..a786dea --- /dev/null +++ b/bin/mariadb104/Dockerfile @@ -0,0 +1 @@ +FROM mariadb:10.4 diff --git a/bin/mariadb105/Dockerfile b/bin/mariadb105/Dockerfile new file mode 100644 index 0000000..787e7f0 --- /dev/null +++ b/bin/mariadb105/Dockerfile @@ -0,0 +1 @@ +FROM mariadb:10.5 diff --git a/bin/mariadb106/Dockerfile b/bin/mariadb106/Dockerfile new file mode 100644 index 0000000..b4abaa0 --- /dev/null +++ b/bin/mariadb106/Dockerfile @@ -0,0 +1 @@ +FROM mariadb:10.6 diff --git a/bin/mysql57/Dockerfile b/bin/mysql57/Dockerfile new file mode 100644 index 0000000..7efee1d --- /dev/null +++ b/bin/mysql57/Dockerfile @@ -0,0 +1 @@ +FROM mysql:5.7 diff --git a/bin/mysql8/Dockerfile b/bin/mysql8/Dockerfile new file mode 100644 index 0000000..7f6484e --- /dev/null +++ b/bin/mysql8/Dockerfile @@ -0,0 +1,3 @@ +FROM mysql:8 +RUN echo "[mysqld]" >> /etc/mysql/my.cnf +RUN echo "mysql_native_password=ON" >> /etc/mysql/my.cnf diff --git a/bin/php54/Dockerfile b/bin/php54/Dockerfile new file mode 100644 index 0000000..40c709e --- /dev/null +++ b/bin/php54/Dockerfile @@ -0,0 +1,59 @@ +FROM php:5.4-apache + +# Backup and clean source.list file +RUN cp /etc/apt/sources.list /etc/apt/sources.list.old && \ + cat /dev/null > /etc/apt/sources.list + +# Fix the source.list for jessie +RUN printf "deb http://archive.debian.org/debian/ jessie main\n" > /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian/ jessie main\n" >> /etc/apt/sources.list && \ + printf "deb http://archive.debian.org/debian-security jessie/updates main\n" >> /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list + +RUN apt-get -y --allow-unauthenticated update && apt-get upgrade -y --allow-unauthenticated + +# Install tools && libraries +RUN apt-get -y --allow-unauthenticated install --fix-missing apt-utils nano wget dialog \ + build-essential git curl libcurl3 libcurl3-dev zip \ + libmcrypt-dev libsqlite3-dev libsqlite3-0 mysql-client \ + zlib1g-dev libicu-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev \ + libapache2-mod-rpaf libpng12-dev \ + && rm -rf /var/lib/apt/lists/* + +# Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# PHP5 Extensions +RUN docker-php-ext-install curl \ + && docker-php-ext-install tokenizer \ + && docker-php-ext-install json \ + && docker-php-ext-install bcmath \ + && docker-php-ext-install mcrypt \ + && docker-php-ext-install pdo_mysql \ + && docker-php-ext-install pdo_sqlite \ + && docker-php-ext-install mysql \ + && docker-php-ext-install mysqli \ + && docker-php-ext-install zip \ + && docker-php-ext-install intl \ + && docker-php-ext-install mbstring + +RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install gd + +RUN pecl install xdebug-2.4.0RC4 && docker-php-ext-enable xdebug \ + && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/php.ini + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers +RUN a2enmod rewrite rpaf + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] diff --git a/bin/php56/Dockerfile b/bin/php56/Dockerfile new file mode 100644 index 0000000..3afa7d1 --- /dev/null +++ b/bin/php56/Dockerfile @@ -0,0 +1,54 @@ +FROM php:5.6-apache + +# Backup and clean source.list file +RUN cp /etc/apt/sources.list /etc/apt/sources.list.old && \ + cat /dev/null > /etc/apt/sources.list + +# Fix the source.list for stretch +RUN printf "deb http://archive.debian.org/debian/ stretch main\n" > /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian/ stretch main\n" >> /etc/apt/sources.list && \ + printf "deb http://archive.debian.org/debian-security stretch/updates main\n" >> /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list + +RUN apt-get -y update && apt-get upgrade -y + +# Install tools && libraries +RUN apt-get -y install --fix-missing nano wget dialog \ + build-essential git curl libcurl3 libcurl3-dev zip \ + libmcrypt-dev libsqlite3-dev libsqlite3-0 mysql-client \ + zlib1g-dev libicu-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev \ + && rm -rf /var/lib/apt/lists/* + +# Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# PHP5 Extensions +RUN docker-php-ext-install curl \ + && docker-php-ext-install tokenizer \ + && docker-php-ext-install json \ + && docker-php-ext-install bcmath \ + && docker-php-ext-install mcrypt \ + && docker-php-ext-install pdo_mysql \ + && docker-php-ext-install pdo_sqlite \ + && docker-php-ext-install mysqli \ + && docker-php-ext-install zip \ + && docker-php-ext-install -j$(nproc) intl \ + && docker-php-ext-install mbstring \ + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd \ + && pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug \ + && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/php.ini + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] diff --git a/bin/php71/Dockerfile b/bin/php71/Dockerfile new file mode 100644 index 0000000..4a6d537 --- /dev/null +++ b/bin/php71/Dockerfile @@ -0,0 +1,59 @@ +FROM php:7.1.20-apache + +# Fix the source.list for stretch +RUN printf "deb http://archive.debian.org/debian/ stretch main\n" > /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian/ stretch main\n" >> /etc/apt/sources.list && \ + printf "deb http://archive.debian.org/debian-security stretch/updates main\n" >> /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list + +RUN apt-get -y update --fix-missing +RUN apt-get upgrade -y + +# Install useful tools +RUN apt-get -y install apt-utils nano wget dialog + +# Install important libraries +RUN apt-get -y install --fix-missing apt-utils build-essential git curl libcurl3 libcurl3-dev zip + +# Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-2.5.0 +RUN docker-php-ext-enable xdebug + +# Other PHP7 Extensions + +RUN apt-get -y install libmcrypt-dev +RUN docker-php-ext-install mcrypt + +RUN apt-get -y install libsqlite3-dev libsqlite3-0 mysql-client +RUN docker-php-ext-install pdo_mysql +RUN docker-php-ext-install pdo_sqlite +RUN docker-php-ext-install mysqli + +RUN docker-php-ext-install curl +RUN docker-php-ext-install tokenizer +RUN docker-php-ext-install json +RUN docker-php-ext-install bcmath + +RUN apt-get -y install zlib1g-dev +RUN docker-php-ext-install zip + +RUN apt-get -y install libicu-dev +RUN docker-php-ext-install -j$(nproc) intl + +RUN docker-php-ext-install mbstring + +RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev +RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ +RUN docker-php-ext-install -j$(nproc) gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers diff --git a/bin/php72/Dockerfile b/bin/php72/Dockerfile new file mode 100644 index 0000000..afe2e66 --- /dev/null +++ b/bin/php72/Dockerfile @@ -0,0 +1,69 @@ +#Quickfix - Basebox for PHP7.2 Library now uses Debian "10" Buster, superceeding #libcurl3, stretch is most compatible at this time whilst devs workout backport. +#https://github.com/docker-library/php/issues/865 + +FROM php:7.2-apache-stretch + +#Surpresses debconf complaints of trying to install apt packages interactively +#https://github.com/moby/moby/issues/4032#issuecomment-192327844 + +ARG DEBIAN_FRONTEND=noninteractive + +# Fix the source.list for stretch +RUN printf "deb http://archive.debian.org/debian/ stretch main\n" > /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian/ stretch main\n" >> /etc/apt/sources.list && \ + printf "deb http://archive.debian.org/debian-security stretch/updates main\n" >> /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list + +RUN apt-get -y update --fix-missing --no-install-recommends +RUN apt-get -y upgrade + +# Install useful tools +RUN apt-get -yq install apt-utils nano wget dialog + +# Install important libraries +RUN apt-get -y install --fix-missing apt-utils build-essential git curl libcurl3 libcurl3-dev zip openssl + +# Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-2.6.0 +RUN docker-php-ext-enable xdebug + +# Install redis +RUN pecl install redis-4.0.1 +RUN docker-php-ext-enable redis + +# Other PHP7 Extensions + +RUN apt-get -y install libsqlite3-dev libsqlite3-0 mysql-client +RUN docker-php-ext-install pdo_mysql +RUN docker-php-ext-install pdo_sqlite +RUN docker-php-ext-install mysqli + +RUN docker-php-ext-install curl +RUN docker-php-ext-install tokenizer +RUN docker-php-ext-install json +RUN docker-php-ext-install bcmath + +RUN apt-get -y install zlib1g-dev +RUN docker-php-ext-install zip + +RUN apt-get -y install libicu-dev +RUN docker-php-ext-install -j$(nproc) intl + +RUN docker-php-ext-install mbstring +RUN docker-php-ext-install gettext + +RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev +RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ +RUN docker-php-ext-install -j$(nproc) gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers \ No newline at end of file diff --git a/bin/php73/Dockerfile b/bin/php73/Dockerfile new file mode 100644 index 0000000..1ca1c88 --- /dev/null +++ b/bin/php73/Dockerfile @@ -0,0 +1,72 @@ +FROM php:7.3-apache-stretch + +# Surpresses debconf complaints of trying to install apt packages interactively +# https://github.com/moby/moby/issues/4032#issuecomment-192327844 + +ARG DEBIAN_FRONTEND=noninteractive + +# Remove the old sources.list file. +RUN rm /etc/apt/sources.list + +# Fix the source.list for stretch +RUN printf "deb http://archive.debian.org/debian/ stretch main\n" > /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian/ stretch main\n" >> /etc/apt/sources.list && \ + printf "deb http://archive.debian.org/debian-security stretch/updates main\n" >> /etc/apt/sources.list && \ + printf "deb-src http://archive.debian.org/debian-security stretch/updates main" >> /etc/apt/sources.list + +# Update +RUN apt-get -y update --fix-missing && \ + apt-get upgrade -y && \ + apt-get --no-install-recommends install -y apt-utils && \ + rm -rf /var/lib/apt/lists/* + + +# Install useful tools and install important libaries +RUN apt-get -y update && \ + apt-get -y --no-install-recommends install nano wget dialog libsqlite3-dev libsqlite3-0 && \ + apt-get -y --no-install-recommends install mysql-client zlib1g-dev libzip-dev libicu-dev && \ + apt-get -y --no-install-recommends install --fix-missing apt-utils build-essential git curl && \ + apt-get -y --no-install-recommends install --fix-missing libcurl3 libcurl3-dev zip openssl && \ + rm -rf /var/lib/apt/lists/* && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-2.7.2 && \ + docker-php-ext-enable xdebug + +# Install redis +RUN pecl install redis-5.0.2 && \ + docker-php-ext-enable redis + +# Other PHP7 Extensions + +RUN docker-php-ext-install pdo_mysql && \ + docker-php-ext-install pdo_sqlite && \ + docker-php-ext-install bcmath && \ + docker-php-ext-install mysqli && \ + docker-php-ext-install curl && \ + docker-php-ext-install tokenizer && \ + docker-php-ext-install json && \ + docker-php-ext-install zip && \ + docker-php-ext-install -j$(nproc) intl && \ + docker-php-ext-install mbstring && \ + docker-php-ext-install gettext + +# Install Freetype +RUN apt-get -y update && \ + apt-get --no-install-recommends install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \ + rm -rf /var/lib/apt/lists/* && \ + docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \ + docker-php-ext-install -j$(nproc) gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers + +# Cleanup +RUN rm -rf /usr/src/* diff --git a/bin/php74/Dockerfile b/bin/php74/Dockerfile new file mode 100644 index 0000000..f8b7d99 --- /dev/null +++ b/bin/php74/Dockerfile @@ -0,0 +1,90 @@ +FROM php:7.4.2-apache-buster + +# Surpresses debconf complaints of trying to install apt packages interactively +# https://github.com/moby/moby/issues/4032#issuecomment-192327844 + +ARG DEBIAN_FRONTEND=noninteractive + +# Update +RUN apt-get -y update --fix-missing && \ + apt-get upgrade -y && \ + apt-get --no-install-recommends install -y apt-utils && \ + rm -rf /var/lib/apt/lists/* + + +# Install useful tools and install important libaries +RUN apt-get -y update && \ + apt-get -y --no-install-recommends install nano wget \ +dialog \ +libsqlite3-dev \ +libsqlite3-0 && \ + apt-get -y --no-install-recommends install default-mysql-client \ +zlib1g-dev \ +libzip-dev \ +libicu-dev && \ + apt-get -y --no-install-recommends install --fix-missing apt-utils \ +build-essential \ +git \ +curl \ +libonig-dev && \ + apt-get install -y iputils-ping && \ + apt-get -y --no-install-recommends install --fix-missing libcurl4 \ +libcurl4-openssl-dev \ +zip \ +openssl && \ + rm -rf /var/lib/apt/lists/* && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-3.1.4 && \ + docker-php-ext-enable xdebug && \ + mkdir /var/log/xdebug + +# Install redis +RUN pecl install redis-5.1.1 && \ + docker-php-ext-enable redis + +# Install imagick +RUN apt-get update && \ + apt-get -y --no-install-recommends install --fix-missing libmagickwand-dev && \ + rm -rf /var/lib/apt/lists/* && \ + pecl install imagick && \ + docker-php-ext-enable imagick + +# Other PHP7 Extensions + +RUN docker-php-ext-install pdo_mysql && \ + docker-php-ext-install pdo_sqlite && \ + docker-php-ext-install bcmath && \ + docker-php-ext-install mysqli && \ + docker-php-ext-install curl && \ + docker-php-ext-install tokenizer && \ + docker-php-ext-install json && \ + docker-php-ext-install zip && \ + docker-php-ext-install -j$(nproc) intl && \ + docker-php-ext-install mbstring && \ + docker-php-ext-install gettext && \ + docker-php-ext-install calendar && \ + docker-php-ext-install exif + + +# Install Freetype +RUN apt-get -y update && \ + apt-get --no-install-recommends install -y libfreetype6-dev \ +libjpeg62-turbo-dev \ +libpng-dev && \ + rm -rf /var/lib/apt/lists/* && \ + docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers + +# Cleanup +RUN rm -rf /usr/src/* diff --git a/bin/php8/Dockerfile b/bin/php8/Dockerfile new file mode 100644 index 0000000..fc76afb --- /dev/null +++ b/bin/php8/Dockerfile @@ -0,0 +1,104 @@ +FROM php:8.0.19-apache-buster + +# Surpresses debconf complaints of trying to install apt packages interactively +# https://github.com/moby/moby/issues/4032#issuecomment-192327844 + +ARG DEBIAN_FRONTEND=noninteractive + +# Update +RUN apt-get -y update --fix-missing && \ + apt-get upgrade -y && \ + apt-get --no-install-recommends install -y apt-utils && \ + rm -rf /var/lib/apt/lists/* + + +# Install useful tools and install important libaries +RUN apt-get -y update && \ + apt-get -y --no-install-recommends install nano wget \ +dialog \ +libsqlite3-dev \ +libsqlite3-0 && \ + apt-get -y --no-install-recommends install default-mysql-client \ +zlib1g-dev \ +libzip-dev \ +libicu-dev && \ + apt-get -y --no-install-recommends install --fix-missing apt-utils \ +build-essential \ +git \ +curl \ +libonig-dev && \ + apt-get install -y iputils-ping && \ + apt-get -y --no-install-recommends install --fix-missing libcurl4 \ +libcurl4-openssl-dev \ +zip \ +openssl && \ + rm -rf /var/lib/apt/lists/* && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-3.1.4 && \ + docker-php-ext-enable xdebug && \ + mkdir /var/log/xdebug + +# Install redis +RUN pecl install redis-5.3.3 && \ + docker-php-ext-enable redis + +# Install imagick +RUN apt-get update && \ + apt-get -y --no-install-recommends install --fix-missing libmagickwand-dev && \ + rm -rf /var/lib/apt/lists/* + +# Workarround until imagick is available in pecl with php8 support +# Imagick Commit to install +# https://github.com/Imagick/imagick +ARG IMAGICK_COMMIT="132a11fd26675db9eb9f0e9a3e2887c161875206" + +RUN cd /usr/local/src && \ + git clone https://github.com/Imagick/imagick && \ + cd imagick && \ + git checkout ${IMAGICK_COMMIT} && \ + phpize && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf imagick && \ + docker-php-ext-enable imagick + +# Other PHP8 Extensions + +RUN docker-php-ext-install pdo_mysql && \ + docker-php-ext-install pdo_sqlite && \ + docker-php-ext-install bcmath && \ + docker-php-ext-install mysqli && \ + docker-php-ext-install curl && \ + docker-php-ext-install tokenizer && \ + docker-php-ext-install zip && \ + docker-php-ext-install -j$(nproc) intl && \ + docker-php-ext-install mbstring && \ + docker-php-ext-install gettext && \ + docker-php-ext-install calendar && \ + docker-php-ext-install exif + + +# Install Freetype +RUN apt-get -y update && \ + apt-get --no-install-recommends install -y libfreetype6-dev \ +libjpeg62-turbo-dev \ +libpng-dev && \ + rm -rf /var/lib/apt/lists/* && \ + docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers + +# Cleanup +RUN rm -rf /usr/src/* diff --git a/bin/php81/Dockerfile b/bin/php81/Dockerfile new file mode 100644 index 0000000..aa7f350 --- /dev/null +++ b/bin/php81/Dockerfile @@ -0,0 +1,103 @@ +FROM php:8.1-apache-buster + +# Surpresses debconf complaints of trying to install apt packages interactively +# https://github.com/moby/moby/issues/4032#issuecomment-192327844 + +ARG DEBIAN_FRONTEND=noninteractive + +# Update +RUN apt-get -y update --fix-missing && \ + apt-get upgrade -y && \ + apt-get --no-install-recommends install -y apt-utils && \ + rm -rf /var/lib/apt/lists/* + + +# Install useful tools and install important libaries +RUN apt-get -y update && \ + apt-get -y --no-install-recommends install nano wget \ +dialog \ +libsqlite3-dev \ +libsqlite3-0 && \ + apt-get -y --no-install-recommends install default-mysql-client \ +zlib1g-dev \ +libzip-dev \ +libicu-dev && \ + apt-get -y --no-install-recommends install --fix-missing apt-utils \ +build-essential \ +git \ +curl \ +libonig-dev && \ + apt-get install -y iputils-ping && \ + apt-get -y --no-install-recommends install --fix-missing libcurl4 \ +libcurl4-openssl-dev \ +zip \ +openssl && \ + rm -rf /var/lib/apt/lists/* && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-3.1.4 && \ + docker-php-ext-enable xdebug && \ + mkdir /var/log/xdebug + +# Install redis +RUN pecl install redis-5.3.3 && \ + docker-php-ext-enable redis + +# Install imagick +RUN apt-get update && \ + apt-get -y --no-install-recommends install --fix-missing libmagickwand-dev && \ + rm -rf /var/lib/apt/lists/* + +# Workarround until imagick is available in pecl with php8 support +# Imagick Commit to install +# https://github.com/Imagick/imagick +ARG IMAGICK_COMMIT="661405abe21d12003207bc8eb0963fafc2c02ee4" + +RUN cd /usr/local/src && \ + git clone https://github.com/Imagick/imagick && \ + cd imagick && \ + git checkout ${IMAGICK_COMMIT} && \ + phpize && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf imagick && \ + docker-php-ext-enable imagick + +# Other PHP8 Extensions + +RUN docker-php-ext-install pdo_mysql && \ + docker-php-ext-install pdo_sqlite && \ + docker-php-ext-install bcmath && \ + docker-php-ext-install mysqli && \ + docker-php-ext-install curl && \ + docker-php-ext-install zip && \ + docker-php-ext-install -j$(nproc) intl && \ + docker-php-ext-install mbstring && \ + docker-php-ext-install gettext && \ + docker-php-ext-install calendar && \ + docker-php-ext-install exif + + +# Install Freetype +RUN apt-get -y update && \ + apt-get --no-install-recommends install -y libfreetype6-dev \ +libjpeg62-turbo-dev \ +libpng-dev && \ + rm -rf /var/lib/apt/lists/* && \ + docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers + +# Cleanup +RUN rm -rf /usr/src/* diff --git a/bin/php82/Dockerfile b/bin/php82/Dockerfile new file mode 100644 index 0000000..d14be2d --- /dev/null +++ b/bin/php82/Dockerfile @@ -0,0 +1,103 @@ +FROM php:8.2.1-apache-buster + +# Surpresses debconf complaints of trying to install apt packages interactively +# https://github.com/moby/moby/issues/4032#issuecomment-192327844 + +ARG DEBIAN_FRONTEND=noninteractive + +# Update +RUN apt-get -y update --fix-missing && \ + apt-get upgrade -y && \ + apt-get --no-install-recommends install -y apt-utils && \ + rm -rf /var/lib/apt/lists/* + + +# Install useful tools and install important libaries +RUN apt-get -y update && \ + apt-get -y --no-install-recommends install nano wget \ +dialog \ +libsqlite3-dev \ +libsqlite3-0 && \ + apt-get -y --no-install-recommends install default-mysql-client \ +zlib1g-dev \ +libzip-dev \ +libicu-dev && \ + apt-get -y --no-install-recommends install --fix-missing apt-utils \ +build-essential \ +git \ +curl \ +libonig-dev && \ + apt-get install -y iputils-ping && \ + apt-get -y --no-install-recommends install --fix-missing libcurl4 \ +libcurl4-openssl-dev \ +zip \ +openssl && \ + rm -rf /var/lib/apt/lists/* && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-3.2.1 && \ + docker-php-ext-enable xdebug && \ + mkdir /var/log/xdebug + +# Install redis +RUN pecl install redis-5.3.7 && \ + docker-php-ext-enable redis + +# Install imagick +RUN apt-get update && \ + apt-get -y --no-install-recommends install --fix-missing libmagickwand-dev && \ + rm -rf /var/lib/apt/lists/* + +# Workarround until imagick is available in pecl with php8 support +# Imagick Commit to install +# https://github.com/Imagick/imagick +ARG IMAGICK_COMMIT="661405abe21d12003207bc8eb0963fafc2c02ee4" + +RUN cd /usr/local/src && \ + git clone https://github.com/Imagick/imagick && \ + cd imagick && \ + git checkout ${IMAGICK_COMMIT} && \ + phpize && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf imagick && \ + docker-php-ext-enable imagick + +# Other PHP8 Extensions + +RUN docker-php-ext-install pdo_mysql && \ + docker-php-ext-install pdo_sqlite && \ + docker-php-ext-install bcmath && \ + docker-php-ext-install mysqli && \ + docker-php-ext-install curl && \ + docker-php-ext-install zip && \ + docker-php-ext-install -j$(nproc) intl && \ + docker-php-ext-install mbstring && \ + docker-php-ext-install gettext && \ + docker-php-ext-install calendar && \ + docker-php-ext-install exif + + +# Install Freetype +RUN apt-get -y update && \ + apt-get --no-install-recommends install -y libfreetype6-dev \ +libjpeg62-turbo-dev \ +libpng-dev && \ + rm -rf /var/lib/apt/lists/* && \ + docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers + +# Cleanup +RUN rm -rf /usr/src/* diff --git a/bin/php83/Dockerfile b/bin/php83/Dockerfile new file mode 100644 index 0000000..6ff6a7c --- /dev/null +++ b/bin/php83/Dockerfile @@ -0,0 +1,102 @@ +FROM php:8.3-apache-bookworm + +# Surpresses debconf complaints of trying to install apt packages interactively +# https://github.com/moby/moby/issues/4032#issuecomment-192327844 + +ARG DEBIAN_FRONTEND=noninteractive + +# Update +RUN apt-get -y update --fix-missing && \ + apt-get upgrade -y && \ + apt-get --no-install-recommends install -y apt-utils && \ + rm -rf /var/lib/apt/lists/* + + +# Install useful tools and install important libaries +RUN apt-get -y update && \ + apt-get -y --no-install-recommends install nano wget \ +dialog \ +libsqlite3-dev \ +libsqlite3-0 && \ + apt-get -y --no-install-recommends install default-mysql-client \ +zlib1g-dev \ +libzip-dev \ +libicu-dev && \ + apt-get -y --no-install-recommends install --fix-missing apt-utils \ +build-essential \ +git \ +curl \ +libonig-dev && \ + apt-get install -y iputils-ping && \ + apt-get -y --no-install-recommends install --fix-missing libcurl4 \ +libcurl4-openssl-dev \ +zip \ +openssl && \ + rm -rf /var/lib/apt/lists/* && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Install xdebug +RUN pecl install xdebug-3.3.1 && \ + docker-php-ext-enable xdebug && \ + mkdir /var/log/xdebug + +# Install redis +RUN pecl install redis-6.0.2 && \ + docker-php-ext-enable redis + +# Install imagick +RUN apt-get update && \ + apt-get -y --no-install-recommends install --fix-missing libmagickwand-dev && \ + rm -rf /var/lib/apt/lists/* + +# Imagick Commit to install +# https://github.com/Imagick/imagick +ARG IMAGICK_COMMIT="28f27044e435a2b203e32675e942eb8de620ee58" + +RUN cd /usr/local/src && \ + git clone https://github.com/Imagick/imagick && \ + cd imagick && \ + git checkout ${IMAGICK_COMMIT} && \ + phpize && \ + ./configure && \ + make && \ + make install && \ + cd .. && \ + rm -rf imagick && \ + docker-php-ext-enable imagick + +# Other PHP8 Extensions + +RUN docker-php-ext-install pdo_mysql && \ + docker-php-ext-install pdo_sqlite && \ + docker-php-ext-install bcmath && \ + docker-php-ext-install mysqli && \ + docker-php-ext-install curl && \ + docker-php-ext-install zip && \ + docker-php-ext-install -j$(nproc) intl && \ + docker-php-ext-install mbstring && \ + docker-php-ext-install gettext && \ + docker-php-ext-install calendar && \ + docker-php-ext-install exif + + +# Install Freetype +RUN apt-get -y update && \ + apt-get --no-install-recommends install -y libfreetype6-dev \ +libjpeg62-turbo-dev \ +libpng-dev && \ + rm -rf /var/lib/apt/lists/* && \ + docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \ + docker-php-ext-install gd + +# Insure an SSL directory exists +RUN mkdir -p /etc/apache2/ssl + +# Enable SSL support +RUN a2enmod ssl && a2enmod rewrite + +# Enable apache modules +RUN a2enmod rewrite headers + +# Cleanup +RUN rm -rf /usr/src/* diff --git a/dev_build_container.sh b/dev_build_container.sh new file mode 100644 index 0000000..3efb2f0 --- /dev/null +++ b/dev_build_container.sh @@ -0,0 +1,142 @@ +#!/bin/bash + +# This script is for building +# all stack variations and check for errors +# during the mysqli and pdo connect. +# This Script is build for Linux +# Info: +# This Script works on WSL2 _but_ you cant use +# WSL2 Windows Host mounted paths for the data. + +dc=$(which docker-compose) +osversion=$(uname) +dbarr=(mariadb103 mariadb104 mariadb105 mariadb106 mysql57 mysql8) + +checkdep() { + +echo "### checking dependencies" +which docker || { echo 'Executable not found: docker' ; exit 1; } +which docker-compose || { echo 'Executable not found: docker-compose' ; exit 1; } +which curl || { echo 'Executable not found: curl' ; exit 1; } +which sed || { echo 'Executable not found: sed' ; exit 1; } +} + +usage() { + +echo "Usage:" +echo " -b = build all container variations of specified version" +echo " valid values are: php54, php56, php71, php72, php73, php74, php8, php81, php82" +echo -e " \nAttention: !!! SCRIPT REMOVES ALL DATA IN 'data/mysql/*' !!!" +} + +# build stack variations +build () { + + echo "### building $buildtarget-$version" + + # removing old mysql data, old data prevents mysql + # from starting correct + echo -e "### cleaning old mysql data" + rm -rf ./data/mysql/* + echo -e "### building ./buildtarget/$buildtarget-$version.env \n" + $dc --env-file ./buildtest/$buildtarget-$version.env up -d --build + # wait for mysql to initialize + sleep 30 + # check definitions + curlmysqli=$(curl -s --max-time 15 --connect-timeout 15 http://localhost/test_db.php |grep proper |wc -l |tr -d '[:space:]') + curlpdo=$(curl -s --max-time 15 --connect-timeout 15 http://localhost/test_db_pdo.php |grep proper |wc -l |tr -d '[:space:]') + + # check if we can create a successfull connection to the database + # 1=OK everything else is not ok + if [ "$curlmysqli" -ne "1" ]; then + echo -e "### ERROR: myqli database check failed expected string 'proper' not found \n" + echo "### ...stopping container" + $dc --env-file ./buildtest/$buildtarget-$version.env down + exit + else + echo -e "\n OK - mysqli database check successfull \n" + sleep 3 + fi + + if [ "$curlpdo" -ne "1" ]; then + echo -e "### ERROR: pdo database check failed expected string 'proper' not found \n" + echo "### ...stopping container" + $dc --env-file ./buildtest/$buildtarget-$version.env down + exit + else + echo -e "\n OK - pdo database check successfull \n" + sleep 3 + fi + + echo "### ... stopping container" + $dc --env-file ./buildtest/$buildtarget-$version.env down +} + +buildenvfile () { + +cat sample.env > ./buildtest/"$buildtarget"-"$version".env +sed -i "s/COMPOSE_PROJECT_NAME=lamp/COMPOSE_PROJECT_NAME=$buildtarget-buildtest/" ./buildtest/"$buildtarget"-"$version".env +sed -i "s/PHPVERSION=php8/PHPVERSION=$buildtarget/" ./buildtest/"$buildtarget"-"$version".env +sed -i "s/DATABASE=mysql8/DATABASE=$version/" ./buildtest/"$buildtarget"-"$version".env +} + +prepare () { + +# generate all .env files for building +echo "### building env file" +mkdir -p ./buildtest +rm -rf ./buildtest/"$buildtarget"* +} + +cleanup () { + +echo "### cleaning old env file" +rm -rf ./buildtest/"$buildtarget"* +} + +while getopts ":b:" opt; +do + case "${opt}" in + b) buildtarget=${OPTARG};; + esac + no_args="false" +done + +# check user input +[[ "$no_args" == "true" ]] && { usage; exit 1; } + +# check if we are running on Linux +if [[ $osversion != 'Linux' ]]; then + echo "This Script only supports Linux sorry :(" + exit +fi + +# we don't want to test against mysql8 for the old +# php versions due to pdo, therefore we only +# take the first 5 elements of the database versions arrays + +if [ "$buildtarget" == 'php54' ]||[ "$buildtarget" == 'php56' ]||[ "$buildtarget" == 'php71' ]||\ + [ "$buildtarget" == 'php72' ]||[ "$buildtarget" == 'php73' ] ; then + for version in "${dbarr[@]:0:5}" + do + checkdep + prepare + buildenvfile "$buildtarget" "$version" + build "$buildtarget" "$version" + cleanup + done +elif [ "$buildtarget" == 'php74' ]||[ "$buildtarget" == 'php8' ]||[ "$buildtarget" == 'php81' ] || [ "$buildtarget" == 'php82' ] || [ "$buildtarget" == 'php83' ] ; then + for version in "${dbarr[@]}" + do + checkdep + prepare + buildenvfile "$buildtarget" "$version" + build "$buildtarget" "$version" + cleanup + done +else + echo "Input not valid" + usage +fi + +exit \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3f8637b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,87 @@ +version: "3" + +services: + webserver: + build: + context: ./bin/${PHPVERSION} + container_name: "${COMPOSE_PROJECT_NAME}-${PHPVERSION}" + restart: "always" + ports: + - "${HOST_MACHINE_UNSECURE_HOST_PORT}:80" + - "${HOST_MACHINE_SECURE_HOST_PORT}:443" + links: + - database + volumes: + - ${DOCUMENT_ROOT-./www}:/var/www/html:rw + - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini + - ${SSL_DIR-./config/ssl}:/etc/apache2/ssl/ + - ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled + - ${LOG_DIR-./logs/apache2}:/var/log/apache2 + - ${XDEBUG_LOG_DIR-./logs/xdebug}:/var/log/xdebug + environment: + APACHE_DOCUMENT_ROOT: ${APACHE_DOCUMENT_ROOT-/var/www/html} + PMA_PORT: ${HOST_MACHINE_PMA_PORT} + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DATABASE} + HOST_MACHINE_MYSQL_PORT: ${HOST_MACHINE_MYSQL_PORT} + XDEBUG_CONFIG: "client_host=host.docker.internal remote_port=${XDEBUG_PORT}" + extra_hosts: + - "host.docker.internal:host-gateway" + database: + build: + context: "./bin/${DATABASE}" + container_name: "${COMPOSE_PROJECT_NAME}-${DATABASE}" + restart: "always" + ports: + - "127.0.0.1:${HOST_MACHINE_MYSQL_PORT}:3306" + volumes: + - ${MYSQL_INITDB_DIR-./config/initdb}:/docker-entrypoint-initdb.d + - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql + - ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DATABASE} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + phpmyadmin: + image: phpmyadmin + container_name: "${COMPOSE_PROJECT_NAME}-phpmyadmin" + links: + - database + environment: + PMA_HOST: database + PMA_PORT: 3306 + PMA_USER: root + PMA_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + UPLOAD_LIMIT: ${UPLOAD_LIMIT} + MEMORY_LIMIT: ${MEMORY_LIMIT} + ports: + - "${HOST_MACHINE_PMA_PORT}:80" + - "${HOST_MACHINE_PMA_SECURE_PORT}:443" + volumes: + - /sessions + - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/conf.d/php-phpmyadmin.ini + redis: + container_name: "${COMPOSE_PROJECT_NAME}-redis" + image: redis:latest + ports: + - "127.0.0.1:${HOST_MACHINE_REDIS_PORT}:6379" + code-server: + image: lscr.io/linuxserver/code-server:latest + container_name: code-server + environment: + - PUID=1000 + - PGID=1000 + - TZ=US/Denver + - DEFAULT_WORKSPACE=/config/workspace #optional + volumes: + - ./vs-config:/config + - ${DOCUMENT_ROOT-./www}:/config/workspace + ports: + - ${HOST_MACHINE_VS_PORT}:8443 + restart: unless-stopped diff --git a/sample.env b/sample.env new file mode 100644 index 0000000..449ce90 --- /dev/null +++ b/sample.env @@ -0,0 +1,63 @@ +# Please Note: +# In PHP Versions <= 7.4 MySQL8 is not supported due to lacking pdo support + +# To determine the name of your containers +COMPOSE_PROJECT_NAME=lamp + +# Possible values: php54, php56, php71, php72, php73, php74, php8, php81, php82, php83 +PHPVERSION=php83 +DOCUMENT_ROOT=./www +APACHE_DOCUMENT_ROOT=/var/www/html +VHOSTS_DIR=./config/vhosts +APACHE_LOG_DIR=./logs/apache2 +PHP_INI=./config/php/php.ini +SSL_DIR=./config/ssl + +# PHPMyAdmin +UPLOAD_LIMIT=512M +MEMORY_LIMIT=512M + +# Xdebug +XDEBUG_LOG_DIR=./logs/xdebug +XDEBUG_PORT=9003 +#XDEBUG_PORT=9000 + +# Possible values: mysql57, mysql8, mariadb103, mariadb104, mariadb105, mariadb106 +# +# For Apple Silicon User: +# Please select Mariadb as Database. Oracle doesn't build their SQL Containers for the arm Architecure + +DATABASE=mysql8 +MYSQL_INITDB_DIR=./config/initdb +MYSQL_DATA_DIR=./data/mysql +MYSQL_LOG_DIR=./logs/mysql + +# If you already have the port 80 in use, you can change it (for example if you have Apache) +HOST_MACHINE_UNSECURE_HOST_PORT=80 + +# If you already have the port 443 in use, you can change it (for example if you have Apache) +HOST_MACHINE_SECURE_HOST_PORT=443 + +# If you already have the port 3306 in use, you can change it (for example if you have MySQL) +HOST_MACHINE_MYSQL_PORT=3306 + +#VS-Code Browser Settings +HOST_MACHINE_VS_PORT=8095 + +# If you already have the port 8080 in use, you can change it (for example if you have PMA) +HOST_MACHINE_PMA_PORT=8080 +HOST_MACHINE_PMA_SECURE_PORT=8443 + +# If you already has the port 6379 in use, you can change it (for example if you have Redis) +HOST_MACHINE_REDIS_PORT=6379 + +# MySQL root user password +MYSQL_ROOT_PASSWORD=tiger + +# Database settings: Username, password and database name +# +# If you need to give the docker user access to more databases than the "docker" db +# you can grant the privileges with phpmyadmin to the user. +MYSQL_USER=docker +MYSQL_PASSWORD=docker +MYSQL_DATABASE=docker diff --git a/todo.md b/todo.md new file mode 100644 index 0000000..3ef71e2 --- /dev/null +++ b/todo.md @@ -0,0 +1,4 @@ +# ToDo List + +* Redesign readme.md for better readability +* Update issue templates