├── 2004 └── Dockerfile ├── .dockerignore ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── app └── index.php ├── docker-compose.test.yml ├── docs └── logo.svg ├── supporting_files ├── apache_default ├── mysql_init.sh ├── run.sh ├── start-apache2.sh ├── start-mysqld.sh ├── supervisord-apache2.conf ├── supervisord-mysqld.conf └── supervisord.conf └── tests ├── 2004-php7.sh ├── 2004-php8.sh ├── _helpers.sh ├── expected ├── 2004-php7.html └── 2004-php8.html └── test.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | CHANGELOG.md 3 | circle.yml 4 | docker-compose.test.yml 5 | docs/ 6 | tests/ 7 | LICENSE 8 | README.md -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | tests/actual -------------------------------------------------------------------------------- /2004/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage:focal-1.1.0 2 | MAINTAINER Matthew Rayner 3 | ENV REFRESHED_AT 2021-09-07 4 | 5 | # based on dgraziotin/lamp 6 | # MAINTAINER Daniel Graziotin 7 | # updated for Ubuntu 20.04 LTS/PHP 7.4/PHP 8.0 Ferdinand Kasper 8 | 9 | ENV DOCKER_USER_ID 501 10 | ENV DOCKER_USER_GID 20 11 | 12 | ENV BOOT2DOCKER_ID 1000 13 | ENV BOOT2DOCKER_GID 50 14 | 15 | ENV PHPMYADMIN_VERSION=5.1.1 16 | ENV SUPERVISOR_VERSION=4.2.2 17 | 18 | ARG PHP_VERSION 19 | ENV PHP_VERSION=$PHP_VERSION 20 | 21 | # Tweaks to give Apache/PHP write permissions to the app 22 | RUN usermod -u ${BOOT2DOCKER_ID} www-data && \ 23 | usermod -G staff www-data && \ 24 | useradd -r mysql && \ 25 | usermod -G staff mysql && \ 26 | groupmod -g $(($BOOT2DOCKER_GID + 10000)) $(getent group $BOOT2DOCKER_GID | cut -d: -f1) && \ 27 | groupmod -g ${BOOT2DOCKER_GID} staff 28 | 29 | # Install packages 30 | ENV DEBIAN_FRONTEND noninteractive 31 | RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \ 32 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C && \ 33 | apt-get update && \ 34 | apt-get -y upgrade && \ 35 | apt-get -y install postfix python3-setuptools wget git apache2 php${PHP_VERSION}-xdebug libapache2-mod-php${PHP_VERSION} mysql-server php${PHP_VERSION}-mysql pwgen php${PHP_VERSION}-apcu php${PHP_VERSION}-gd php${PHP_VERSION}-xml php${PHP_VERSION}-mbstring zip unzip php${PHP_VERSION}-zip curl php${PHP_VERSION}-curl && \ 36 | apt-get -y autoremove && \ 37 | apt-get -y clean && \ 38 | echo "ServerName localhost" >> /etc/apache2/apache2.conf 39 | 40 | # Install supervisor 4 41 | RUN curl -L https://pypi.io/packages/source/s/supervisor/supervisor-${SUPERVISOR_VERSION}.tar.gz | tar xvz && \ 42 | cd supervisor-${SUPERVISOR_VERSION}/ && \ 43 | python3 setup.py install 44 | 45 | # Add image configuration and scripts 46 | ADD supporting_files/start-apache2.sh /start-apache2.sh 47 | ADD supporting_files/start-mysqld.sh /start-mysqld.sh 48 | ADD supporting_files/run.sh /run.sh 49 | RUN chmod 755 /*.sh 50 | ADD supporting_files/supervisord-apache2.conf /etc/supervisor/conf.d/supervisord-apache2.conf 51 | ADD supporting_files/supervisord-mysqld.conf /etc/supervisor/conf.d/supervisord-mysqld.conf 52 | ADD supporting_files/supervisord.conf /etc/supervisor/supervisord.conf 53 | 54 | # Remove pre-installed database 55 | RUN rm -rf /var/lib/mysql 56 | 57 | # Add MySQL utils 58 | ADD supporting_files/mysql_init.sh /mysql_init.sh 59 | 60 | # Add phpmyadmin 61 | RUN wget -O /tmp/phpmyadmin.tar.gz https://files.phpmyadmin.net/phpMyAdmin/${PHPMYADMIN_VERSION}/phpMyAdmin-${PHPMYADMIN_VERSION}-all-languages.tar.gz 62 | RUN tar xfvz /tmp/phpmyadmin.tar.gz -C /var/www 63 | RUN ln -s /var/www/phpMyAdmin-${PHPMYADMIN_VERSION}-all-languages /var/www/phpmyadmin 64 | RUN mv /var/www/phpmyadmin/config.sample.inc.php /var/www/phpmyadmin/config.inc.php 65 | 66 | # Add composer 67 | RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ 68 | php composer-setup.php && \ 69 | php -r "unlink('composer-setup.php');" && \ 70 | mv composer.phar /usr/local/bin/composer 71 | 72 | ENV MYSQL_PASS:-$(pwgen -s 12 1) 73 | # config to enable .htaccess 74 | ADD supporting_files/apache_default /etc/apache2/sites-available/000-default.conf 75 | RUN a2enmod rewrite 76 | 77 | # Configure /app folder with sample app 78 | RUN mkdir -p /app && rm -fr /var/www/html && ln -s /app /var/www/html 79 | ADD app/ /app 80 | 81 | #Environment variables to configure php 82 | ENV PHP_UPLOAD_MAX_FILESIZE 10M 83 | ENV PHP_POST_MAX_SIZE 10M 84 | 85 | # Add volumes for the app and MySql 86 | VOLUME ["/var/lib/mysql", "/app" ] 87 | 88 | EXPOSE 80 3306 89 | CMD ["/run.sh"] 90 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.2.0-alpha 2 | Change image to use updated phusion:baseimage and ubuntu 16:04 3 | 4 | # 0.1.1 5 | Security improvements to image. 6 | 7 | # 0.1.0 8 | Initial release - initial compatability with Concrete5. 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2016 Matthew Rayner 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | http://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. 191 | 192 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | test: build up run-tests clean 2 | 3 | test-no-cache: build-no-cache up run-tests clean 4 | 5 | build: 6 | docker-compose -f docker-compose.test.yml -p ci build 7 | 8 | build-no-cache: 9 | docker-compose -f docker-compose.test.yml -p ci build --no-cache 10 | 11 | up: 12 | docker-compose -f docker-compose.test.yml -p ci up -d 13 | 14 | run-tests: 15 | cd tests && ./test.sh 16 | 17 | clean: 18 | docker-compose -f docker-compose.test.yml -p ci down 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![Docker-LAMP][logo] 2 | Docker-LAMP is a set of docker images that include the phusion baseimage (18.04 and 20.04 varieties), along with a LAMP stack ([Apache][apache], [MySQL][mysql] and [PHP][php]) all in one handy package. 3 | 4 | With Ubuntu **20.04** and **18.04** images on the `latest-2004` and `latest-1804` tags, Docker-LAMP is flexible enough to use with all of your LAMP projects. 5 | 6 | [![Build Status][shield-build-status]][info-build-status] 7 | [![Docker Hub][shield-docker-hub]][info-docker-hub] 8 | [![License][shield-license]][info-license] 9 | 10 | ### Contents 11 | 12 | 13 | 14 | 15 | - [Introduction](#introduction) 16 | - [Image Versions](#image-versions) 17 | - [Using the image](#using-the-image) 18 | - [On the command line](#on-the-command-line) 19 | - [With a Dockerfile](#with-a-dockerfile) 20 | - [MySQL Databases](#mysql-databases) 21 | - [Creating a database](#creating-a-database) 22 | - [PHPMyAdmin](#phpmyadmin) 23 | - [Command Line](#command-line) 24 | - [Initialization script](#initialization-script) 25 | - [SQL initialization script](#sql-initialization-script) 26 | - [Adding your own content](#adding-your-own-content) 27 | - [Adding your app](#adding-your-app) 28 | - [Persisting your MySQL](#persisting-your-mysql) 29 | - [Doing both](#doing-both) 30 | - [`.bash_profile` alias examples](#bash_profile-alias-examples) 31 | - [Example usage](#example-usage) 32 | - [Developing the image](#developing-the-image) 33 | - [Building and running](#building-and-running) 34 | - [Testing](#testing) 35 | - [One-line testing command](#one-line-testing-command) 36 | - [`docker-compose -f docker-compose.test.yml -p ci build;`](#docker-compose--f-docker-composetestyml--p-ci-build) 37 | - [`docker-compose -f docker-compose.test.yml -p ci up -d;`](#docker-compose--f-docker-composetestyml--p-ci-up--d) 38 | - [`cd tests && ./test.sh;`](#cd-tests--testsh) 39 | - [`echo "Exited with status code: $?"`](#echo-exited-with-status-code-) 40 | - [Inspiration](#inspiration) 41 | - [Contributing](#contributing) 42 | - [License](#license) 43 | 44 | 45 | 46 | ## Introduction 47 | As a developer, part of my day to day role is to build LAMP applications. I searched in vain for an image that had everything I wanted, up-to-date packages, a simple interface, good documentation and active support. 48 | 49 | To complicate things even further I needed an image, or actually two, that would run my applications on both 14.04 and 16.04. Having two entirely separate workflows didn't make any sense to me, and Docker-LAMP was born. 50 | 51 | Designed to be a single interface that just 'gets out of your way', and works on 18.04 and 20.04 with php 7 and 8. You can move between all images without changing how you work with Docker. 52 | 53 | ## Image Versions 54 | > **NOTE:** [PHP 5.6 is end of life][end-of-life], so the PHP 5 images `mattrayner/lamp:latest-1404-php5` and `mattrayner/lamp:latest-1604-php5` will not receive any updates. Although these images will stay on Docker Hub, we **strongly** recommend updating you applications to PHP 7 or PHP 8. 55 | 56 | > **NOTE**: The 14.04, 16.04 and 18.04 variants of this image are no longer being actively supported or updated. 57 | 58 | There are four main 'versions' of the docker image. The table below shows the different tags you can use, along with the PHP, MySQL and Apache versions that come with it. 59 | 60 | Component | `latest-1404` | `latest-1604` | `latest-1804-php7` `latest-1804-php8` | `latest-2004-php7` `latest-2004-php8` 61 | ---|---|---|---|--- 62 | [Apache][apache] | `2.4.7` | `2.4.18` | `2.4.29` | `2.4.41` 63 | [MySQL][mysql] | `5.5.62` | `5.7.30` | `5.7.35` | `8.0.36` 64 | [PHP][php] | `7.3.3` | `7.4.6` | `7.4.23`/`8.0.10` | `7.4.33`/`8.0.30` 65 | [phpMyAdmin][phpmyadmin] | `4.8.5` | `5.0.2` | `5.1.1` | `5.1.1` 66 | 67 | 68 | ## Using the image 69 | ### On the command line 70 | This is the quickest way 71 | ```bash 72 | # Launch a 20.04 based image with PHP 8 73 | docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-2004-php8 74 | 75 | # Launch a 20.04 based image with PHP 7 76 | docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-2004-php7 77 | 78 | # Launch a 18.04 based image with PHP 8 79 | docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1804-php8 80 | 81 | # Launch a 18.04 based image with PHP 7 82 | docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1804-php7 83 | 84 | # Launch a 16.04 based image with PHP 7 85 | docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1604 86 | 87 | # Launch a 14.04 based image with PHP 5 88 | docker run -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest-1404 89 | ``` 90 | 91 | ### With a Dockerfile 92 | ```docker 93 | FROM mattrayner/lamp:latest-2004-php8 94 | 95 | # Your custom commands 96 | 97 | CMD ["/run.sh"] 98 | ``` 99 | 100 | ### MySQL Databases 101 | By default, the image comes with a `root` MySQL account that has no password. This account is only available locally, i.e. within your application. It is not available from outside your docker image or through phpMyAdmin. 102 | 103 | When you first run the image you'll see a message showing your `admin` user's password. This user can be used locally and externally, either by connecting to your MySQL port (default 3306) and using a tool like MySQL Workbench or Sequel Pro, or through phpMyAdmin. 104 | 105 | If you need this login later, you can run `docker logs CONTAINER_ID` and you should see it at the top of the log. 106 | 107 | #### Creating a database 108 | So your application needs a database - you have three options: 109 | 110 | 1. PHPMyAdmin 111 | 2. Command line 112 | 3. Initialization script 113 | 114 | ##### PHPMyAdmin 115 | Docker-LAMP comes pre-installed with phpMyAdmin available from `http://DOCKER_ADDRESS/phpmyadmin`. 116 | 117 | **NOTE:** you cannot use the `root` user with PHPMyAdmin. We recommend logging in with the admin user mentioned in the introduction to this section. 118 | 119 | ##### Command Line 120 | First, get the ID of your running container with `docker ps`, then run the below command replacing `CONTAINER_ID` and `DATABASE_NAME` with your required values: 121 | ```bash 122 | docker exec CONTAINER_ID mysql -uroot -e "create database DATABASE_NAME" 123 | ``` 124 | 125 | ##### Initialization script 126 | See the [SQL initialization script section](#sql-initialization-script) for details. 127 | 128 | #### SQL initialization script 129 | Optionally, you can provide a SQL script which will run immediately after MySQL has been installed and configured, allowing you to run custom SQL e.g. to create a database, users or insert custom data. 130 | 131 | Please note that **the SQL initialization script runs only at the container first startup**. The script won't run if MySQL has already been configured (i.e. if the `/var/lib/mysql` contains initialized MySQL data). 132 | 133 | The below command will run the docker image `mattrayner/lamp:latest` interactively, exposing port `80` on the host machine with port `80` on the docker container. It will also create a volume linking the `script.sql` file within your current folder to the `/db/init.sql` file on the container. This is where the container expects the SQL initialization script to live. 134 | 135 | ```bash 136 | docker run -i -t -p "80:80" -v ${PWD}/script.sql:/db/init.sql:ro mattrayner/lamp:latest 137 | ``` 138 | 139 | ## Adding your own content 140 | The 'easiest' way to add your own content to the lamp image is using Docker volumes. This will effectively 'sync' a particular folder on your machine with that on the docker container. 141 | 142 | The below examples assume the following project layout and that you are running the commands from the 'project root'. 143 | ``` 144 | / (project root) 145 | /app/ (your PHP files live here) 146 | /mysql/ (docker will create this and store your MySQL data here) 147 | ``` 148 | 149 | In english, your project should contain a folder called `app` containing all of your app's code. That's pretty much it. 150 | 151 | ### Adding your app 152 | The below command will run the docker image `mattrayner/lamp:latest` interactively, exposing port `80` on the host machine with port `80` on the docker container. It will then create a volume linking the `app/` directory within your project to the `/app` directory on the container. This is where Apache is expecting your PHP to live. 153 | ```bash 154 | docker run -i -t -p "80:80" -v ${PWD}/app:/app mattrayner/lamp:latest 155 | ``` 156 | 157 | ### Persisting your MySQL 158 | The below command will run the docker image `mattrayner/lamp:latest`, creating a `mysql/` folder within your project. This folder will be linked to `/var/lib/mysql` where all of the MySQL files from container lives. You will now be able to stop/start the container and keep your database changes. 159 | 160 | You may also add `-p 3306:3306` after `-p 80:80` to expose the mysql sockets on your host machine. This will allow you to connect an external application such as SequelPro or MySQL Workbench. 161 | ```bash 162 | docker run -i -t -p "80:80" -v ${PWD}/mysql:/var/lib/mysql mattrayner/lamp:latest 163 | ``` 164 | 165 | ### Doing both 166 | The below command is our 'recommended' solution. It both adds your own PHP and persists database files. We have created a more advanced alias in our `.bash_profile` files to enable the short commands `ldi` and `launchdocker`. See the next section for an example. 167 | ```bash 168 | docker run -i -t -p "80:80" -v ${PWD}/app:/app -v ${PWD}/mysql:/var/lib/mysql mattrayner/lamp:latest 169 | ``` 170 | 171 | #### `.bash_profile` alias examples 172 | The below example can be added to your `~/.bash_profile` file to add the alias commands `ldi` and `launchdocker`. By default it will launch the 16.04 image - if you need the 14.04 image, simply change the `docker run` command to use `mattrayner/lamp:latest-1404` instead of `mattrayner/lamp:latest`. 173 | ```bash 174 | # A helper function to launch docker container using mattrayner/lamp with overrideable parameters 175 | # 176 | # $1 - Apache Port (optional) 177 | # $2 - MySQL Port (optional - no value will cause MySQL not to be mapped) 178 | function launchdockerwithparams { 179 | APACHE_PORT=80 180 | MYSQL_PORT_COMMAND="" 181 | 182 | if ! [[ -z "$1" ]]; then 183 | APACHE_PORT=$1 184 | fi 185 | 186 | if ! [[ -z "$2" ]]; then 187 | MYSQL_PORT_COMMAND="-p \"$2:3306\"" 188 | fi 189 | 190 | docker run -i -t -p "$APACHE_PORT:80" $MYSQL_PORT_COMMAND -v ${PWD}/app:/app -v ${PWD}/mysql:/var/lib/mysql mattrayner/lamp:latest 191 | } 192 | alias launchdocker='launchdockerwithparams $1 $2' 193 | alias ldi='launchdockerwithparams $1 $2' 194 | ``` 195 | 196 | ##### Example usage 197 | ```bash 198 | # Launch docker and map port 80 for apache 199 | ldi 200 | 201 | # Launch docker and map port 8080 for apache 202 | ldi 8080 203 | 204 | # Launch docker and map port 3000 for apache along with 3306 for MySQL 205 | ldi 3000 3306 206 | ``` 207 | 208 | 209 | ## Developing the image 210 | ### Building and running 211 | ```bash 212 | # Clone the project from Github 213 | git clone https://github.com/mattrayner/docker-lamp.git 214 | cd docker-lamp 215 | 216 | # Build the images 217 | docker build --build-arg PHP_VERSION=8.0 -t=mattrayner/lamp:latest -f ./2004/Dockerfile . 218 | docker build --build-arg PHP_VERSION=8.0 -t=mattrayner/lamp:latest-2004-php8 -f ./2004/Dockerfile . 219 | docker build --build-arg PHP_VERSION=7.4 -t=mattrayner/lamp:latest-2004-php7 -f ./2004/Dockerfile . 220 | docker build --build-arg PHP_VERSION=8.0 -t=mattrayner/lamp:latest-1804-php8 -f ./1804/Dockerfile . 221 | docker build --build-arg PHP_VERSION=7.4 -t=mattrayner/lamp:latest-1804-php7 -f ./1804/Dockerfile . 222 | 223 | # Run the image as a container 224 | docker run -d -p "3000:80" mattrayner/lamp:latest 225 | 226 | # Sleep to allow the container to boot 227 | sleep 30 228 | 229 | # Curl out the contents of our new container 230 | curl "http://$(docker-machine ip):3000/" 231 | ``` 232 | 233 | ### Testing 234 | We use `docker-compose` to setup, build and run our testing environment. It allows us to offload a large amount of the testing overhead to Docker, and to ensure that we always test our image in a consistent way that's not affected by the host machine. 235 | 236 | ### One-line testing command 237 | We've developed a single-line test command you can run on your machine within the `docker-lamp` directory. This will test any changes that may have been made, as well as comparing installed versions of Apache, MySQL, PHP and phpMyAdmin against those expected. 238 | ```bash 239 | docker-compose -f docker-compose.test.yml -p ci build; docker-compose -f docker-compose.test.yml -p ci up -d; cd tests && ./test.sh; echo "Exited with status code: $?"; 240 | ``` 241 | 242 | So what does this command do? 243 | 244 | #### `docker-compose -f docker-compose.test.yml -p ci build;` 245 | First, build that latest version of our docker-compose images. 246 | 247 | #### `docker-compose -f docker-compose.test.yml -p ci up -d;` 248 | Launch our docker containers (`web2004-php8` etc.) in daemon mode. 249 | 250 | #### `cd tests && ./test.sh;` 251 | Change into the test directory and run out tests 252 | 253 | #### `echo "Exited with status code: $?"` 254 | Report back whether the tests passed or not 255 | 256 | 257 | ## Inspiration 258 | This image was originally based on [dgraziotin/lamp][dgraziotin-lamp], with a few changes to make it compatible with the Concrete5 CMS. 259 | 260 | I also changed the setup to create ubuntu (well, baseimage, but you get what I'm saying) images so that this project could be as useful as possible to as many people as possible. 261 | 262 | 263 | ## Contributing 264 | If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review. 265 | 266 | 1. Clone/fork it 267 | 2. Create your feature branch (git checkout -b my-new-feature) 268 | 3. Commit your changes (git commit -am 'Add some feature') 269 | 4. Test your changes using the steps in [Testing](#testing) 270 | 5. Push to the branch (git push origin my-new-feature) 271 | 6. Create a new Pull Request 272 | 273 | ## Building / Releasing 274 | Manually building and releasing can be done with the following: 275 | 276 | ```bash 277 | docker-compose -f docker-compose.test.yml -p ci build 278 | docker tag ci-web2004-php8 mattrayner/lamp:latest 279 | docker tag ci-web2004-php8 mattrayner/lamp:latest-2004 280 | docker tag ci-web2004-php8 mattrayner/lamp:latest-2004-php8 281 | docker tag ci-web2004-php7 mattrayner/lamp:latest-2004-php7 282 | 283 | docker push mattrayner/lamp:latest 284 | docker push mattrayner/lamp:latest-2004 285 | docker push mattrayner/lamp:latest-2004-php8 286 | docker push mattrayner/lamp:latest-2004-php7 287 | ``` 288 | 289 | ## License 290 | Docker-LAMP is licensed under the [Apache 2.0 License][info-license]. 291 | 292 | 293 | [logo]: https://cdn.rawgit.com/mattrayner/docker-lamp/831976c022782e592b7e2758464b2a9efe3da042/docs/logo.svg 294 | 295 | [apache]: http://www.apache.org/ 296 | [mysql]: https://www.mysql.com/ 297 | [php]: http://php.net/ 298 | [phpmyadmin]: https://www.phpmyadmin.net/ 299 | 300 | [end-of-life]: http://php.net/supported-versions.php 301 | 302 | [info-build-status]: https://circleci.com/gh/mattrayner/docker-lamp 303 | [info-docker-hub]: https://hub.docker.com/r/mattrayner/lamp 304 | [info-license]: LICENSE 305 | 306 | [shield-build-status]: https://img.shields.io/circleci/project/mattrayner/docker-lamp.svg 307 | [shield-docker-hub]: https://img.shields.io/badge/docker%20hub-mattrayner%2Flamp-brightgreen.svg 308 | [shield-license]: https://img.shields.io/badge/license-Apache%202.0-blue.svg 309 | 310 | [dgraziotin-lamp]: https://github.com/dgraziotin/osx-docker-lamp 311 | -------------------------------------------------------------------------------- /app/index.php: -------------------------------------------------------------------------------- 1 | 29 | 30 | 31 | 32 | 33 | Hello World from Docker-LAMP 34 | 35 | 59 | 60 | 61 |
62 |
63 | Docker LAMP logo 64 |

Welcome to Docker-Lamp a.k.a mattrayner/lamp

65 |
66 |
67 |

68 | For documentation, click here. 69 |

70 |
71 |
72 |
73 | OS: 
74 | Apache:
75 | MySQL Version: getAttribute( PDO::ATTR_SERVER_VERSION ); ?>
76 | PHP Version:
77 | phpMyAdmin Version: 78 |
79 |
80 |
81 | 82 | 83 | -------------------------------------------------------------------------------- /docker-compose.test.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | 3 | services: 4 | 5 | web2004-php7: 6 | build: 7 | context: . 8 | dockerfile: ./2004/Dockerfile 9 | args: 10 | - PHP_VERSION=7.4 11 | environment: 12 | - MYSQL_ADMIN_PASS=password 13 | ports: 14 | - "3030:80" 15 | - "3031:3306" 16 | tmpfs: 17 | - /var/lib/mysql 18 | 19 | web2004-php8: 20 | build: 21 | context: . 22 | dockerfile: ./2004/Dockerfile 23 | args: 24 | - PHP_VERSION=8.0 25 | environment: 26 | - MYSQL_ADMIN_PASS=password 27 | ports: 28 | - "3040:80" 29 | - "3041:3306" 30 | tmpfs: 31 | - /var/lib/mysql 32 | -------------------------------------------------------------------------------- /docs/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 12 | 18 | 23 | 25 | 30 | 33 | 34 | 36 | 38 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /supporting_files/apache_default: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | 4 | DocumentRoot /var/www/html 5 | 6 | Options Indexes FollowSymLinks MultiViews 7 | # To make wordpress .htaccess work 8 | AllowOverride All 9 | Order allow,deny 10 | allow from all 11 | 12 | 13 | 14 | AllowOverride All 15 | 16 | 17 | Alias /phpmyadmin /var/www/phpmyadmin 18 | 19 | Options Indexes FollowSymLinks MultiViews 20 | # To make wordpress .htaccess work 21 | AllowOverride All 22 | Order allow,deny 23 | allow from all 24 | 25 | 26 | ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 27 | 28 | AllowOverride None 29 | Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 30 | Order allow,deny 31 | Allow from all 32 | 33 | 34 | ErrorLog ${APACHE_LOG_DIR}/error.log 35 | 36 | # Possible values include: debug, info, notice, warn, error, crit, 37 | # alert, emerg. 38 | LogLevel warn 39 | 40 | CustomLog ${APACHE_LOG_DIR}/access.log combined 41 | 42 | # 43 | # Set HTTPS environment variable if we came in over secure 44 | # channel. 45 | SetEnvIf x-forwarded-proto https HTTPS=on 46 | 47 | 48 | -------------------------------------------------------------------------------- /supporting_files/mysql_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/bin/mysqld_safe > /dev/null 2>&1 & 4 | 5 | RET=1 6 | while [[ RET -ne 0 ]]; do 7 | echo "=> Waiting for confirmation of MySQL service startup" 8 | sleep 5 9 | mysql -uroot -e "status" > /dev/null 2>&1 10 | RET=$? 11 | done 12 | 13 | PASS=${MYSQL_ADMIN_PASS:-$(pwgen -s 12 1)} 14 | _word=$( [ ${MYSQL_ADMIN_PASS} ] && echo "preset" || echo "random" ) 15 | echo "=> Creating MySQL admin user with ${_word} password" 16 | 17 | mysql -uroot -e "CREATE USER 'admin'@'%' IDENTIFIED BY '$PASS'" 18 | mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION" 19 | 20 | mysql -uroot -e " GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'pma'@'localhost' IDENTIFIED BY ''" 21 | 22 | CREATE_MYSQL_USER=false 23 | 24 | if [ -n "$CREATE_MYSQL_BASIC_USER_AND_DB" ] || \ 25 | [ -n "$MYSQL_USER_NAME" ] || \ 26 | [ -n "$MYSQL_USER_DB" ] || \ 27 | [ -n "$MYSQL_USER_PASS" ]; then 28 | CREATE_MYSQL_USER=true 29 | fi 30 | 31 | if [ "$CREATE_MYSQL_USER" = true ]; then 32 | _user=${MYSQL_USER_NAME:-user} 33 | _userdb=${MYSQL_USER_DB:-db} 34 | _userpass=${MYSQL_USER_PASS:-password} 35 | 36 | mysql -uroot -e "CREATE USER '${_user}'@'%' IDENTIFIED BY '${_userpass}'" 37 | mysql -uroot -e "GRANT USAGE ON *.* TO '${_user}'@'%' IDENTIFIED BY '${_userpass}'" 38 | mysql -uroot -e "CREATE DATABASE IF NOT EXISTS ${_userdb}" 39 | mysql -uroot -e "GRANT ALL PRIVILEGES ON ${_userdb}.* TO '${_user}'@'%'" 40 | fi 41 | 42 | if [[ -e /db/init.sql ]]; then 43 | echo "=> Initializing the database" 44 | 45 | mysql -uroot < /db/init.sql 46 | fi 47 | 48 | echo "=> Done!" 49 | 50 | echo "========================================================================" 51 | echo "You can now connect to this MySQL Server with $PASS" 52 | echo "" 53 | echo " mysql -uadmin -p$PASS -h -P" 54 | echo "" 55 | echo "Please remember to change the above password as soon as possible!" 56 | echo "MySQL user 'root' has no password but only allows local connections" 57 | echo "" 58 | 59 | if [ "$CREATE_MYSQL_USER" = true ]; then 60 | echo "We also created" 61 | echo "A database called '${_userdb}' and" 62 | echo "a user called '${_user}' with password '${_userpass}'" 63 | echo "'${_user}' has full access on '${_userdb}'" 64 | fi 65 | 66 | echo "enjoy!" 67 | echo "========================================================================" 68 | 69 | mysqladmin -uroot shutdown 70 | -------------------------------------------------------------------------------- /supporting_files/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Prepare our container for initial boot. 4 | 5 | # Where does our MySQL data live? 6 | VOLUME_HOME="/var/lib/mysql" 7 | 8 | ####################################### 9 | # Use sed to replace apache php.ini values for a given PHP version. 10 | # Globals: 11 | # PHP_UPLOAD_MAX_FILESIZE 12 | # PHP_POST_MAX_SIZE 13 | # PHP_TIMEZONE 14 | # Arguments: 15 | # $1 - PHP version i.e. 5.6, 7.3 etc. 16 | # Returns: 17 | # None 18 | ####################################### 19 | function replace_apache_php_ini_values () { 20 | echo "Updating for PHP $1" 21 | 22 | sed -ri -e "s/^upload_max_filesize.*/upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}/" \ 23 | -e "s/^post_max_size.*/post_max_size = ${PHP_POST_MAX_SIZE}/" /etc/php/$1/apache2/php.ini 24 | 25 | sed -i "s/;date.timezone =/date.timezone = Europe\/London/g" /etc/php/$1/apache2/php.ini 26 | 27 | } 28 | if [ -e /etc/php/5.6/apache2/php.ini ]; then replace_apache_php_ini_values "5.6"; fi 29 | if [ -e /etc/php/$PHP_VERSION/apache2/php.ini ]; then replace_apache_php_ini_values $PHP_VERSION; fi 30 | 31 | ####################################### 32 | # Use sed to replace cli php.ini values for a given PHP version. 33 | # Globals: 34 | # PHP_TIMEZONE 35 | # Arguments: 36 | # $1 - PHP version i.e. 5.6, 7.3 etc. 37 | # Returns: 38 | # None 39 | ####################################### 40 | function replace_cli_php_ini_values () { 41 | echo "Replacing CLI php.ini values" 42 | sed -i "s/;date.timezone =/date.timezone = Europe\/London/g" /etc/php/$1/cli/php.ini 43 | } 44 | if [ -e /etc/php/5.6/cli/php.ini ]; then replace_cli_php_ini_values "5.6"; fi 45 | if [ -e /etc/php/$PHP_VERSION/cli/php.ini ]; then replace_cli_php_ini_values $PHP_VERSION; fi 46 | 47 | echo "Editing APACHE_RUN_GROUP environment variable" 48 | sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=staff/" /etc/apache2/envvars 49 | 50 | if [ -n "$APACHE_ROOT" ];then 51 | echo "Linking /var/www/html to the Apache root" 52 | rm -f /var/www/html && ln -s "/app/${APACHE_ROOT}" /var/www/html 53 | fi 54 | 55 | echo "Editing phpmyadmin config" 56 | sed -i "s/cfg\['blowfish_secret'\] = ''/cfg['blowfish_secret'] = '`date | md5sum`'/" /var/www/phpmyadmin/config.inc.php 57 | 58 | echo "Setting up MySQL directories" 59 | mkdir -p /var/run/mysqld 60 | 61 | # Setup user and permissions for MySQL and Apache 62 | chmod -R 770 /var/lib/mysql 63 | chmod -R 770 /var/run/mysqld 64 | 65 | if [ -n "$VAGRANT_OSX_MODE" ];then 66 | echo "Setting up users and groups" 67 | usermod -u $DOCKER_USER_ID www-data 68 | groupmod -g $(($DOCKER_USER_GID + 10000)) $(getent group $DOCKER_USER_GID | cut -d: -f1) 69 | groupmod -g ${DOCKER_USER_GID} staff 70 | else 71 | echo "Allowing Apache/PHP to write to the app" 72 | # Tweaks to give Apache/PHP write permissions to the app 73 | chown -R www-data:staff /var/www 74 | chown -R www-data:staff /app 75 | fi 76 | 77 | echo "Allowing Apache/PHP to write to MySQL" 78 | chown -R www-data:staff /var/lib/mysql 79 | chown -R www-data:staff /var/run/mysqld 80 | chown -R www-data:staff /var/log/mysql 81 | 82 | # Listen only on IPv4 addresses 83 | sed -i 's/^Listen .*/Listen 0.0.0.0:80/' /etc/apache2/ports.conf 84 | 85 | if [ -e /var/run/mysqld/mysqld.sock ];then 86 | echo "Removing MySQL socket" 87 | rm /var/run/mysqld/mysqld.sock 88 | fi 89 | 90 | echo "Editing MySQL config" 91 | sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf 92 | sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/mysql.conf.d/mysqld.cnf 93 | sed -i "s/user.*/user = www-data/" /etc/mysql/mysql.conf.d/mysqld.cnf 94 | 95 | if [[ ! -d $VOLUME_HOME/mysql ]]; then 96 | echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME" 97 | echo "=> Installing MySQL ..." 98 | 99 | # Try the 'preferred' solution 100 | mysqld --initialize-insecure --innodb-flush-log-at-trx-commit=0 --skip-log-bin 101 | 102 | # IF that didn't work 103 | if [ $? -ne 0 ]; then 104 | # Fall back to the 'depreciated' solution 105 | mysql_install_db > /dev/null 2>&1 106 | fi 107 | 108 | echo "=> Done!" 109 | /mysql_init.sh 110 | else 111 | echo "=> Using an existing volume of MySQL" 112 | fi 113 | 114 | echo "Starting supervisord" 115 | exec supervisord -n 116 | -------------------------------------------------------------------------------- /supporting_files/start-apache2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source /etc/apache2/envvars 3 | exec apache2 -D FOREGROUND 4 | -------------------------------------------------------------------------------- /supporting_files/start-mysqld.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec /usr/local/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe 3 | -------------------------------------------------------------------------------- /supporting_files/supervisord-apache2.conf: -------------------------------------------------------------------------------- 1 | [program:apache2] 2 | command=/start-apache2.sh 3 | numprocs=1 4 | autostart=true 5 | autorestart=true -------------------------------------------------------------------------------- /supporting_files/supervisord-mysqld.conf: -------------------------------------------------------------------------------- 1 | [program:mysqld] 2 | command=/start-mysqld.sh 3 | numprocs=1 4 | autostart=true 5 | autorestart=true -------------------------------------------------------------------------------- /supporting_files/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | 3 | [include] 4 | files=/etc/supervisor/conf.d/supervisord-apache2.conf /etc/supervisor/conf.d/supervisord-mysqld.conf 5 | 6 | ; https://github.com/Supervisor/supervisor/issues/376#issuecomment-404385767 7 | 8 | [unix_http_server] 9 | file=/var/run/supervisor.sock 10 | chmod=0700 11 | 12 | [rpcinterface:supervisor] 13 | supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 14 | 15 | [supervisorctl] 16 | serverurl=unix:///var/run/supervisor.sock 17 | -------------------------------------------------------------------------------- /tests/2004-php7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source _helpers.sh 3 | 4 | waitForSupervisordProcess web2004-php7 apache2 5 | waitForSupervisordProcess web2004-php7 mysqld 6 | 7 | testimage 2004-php7 3030 8 | #testmysql web2004-php7 3031 -------------------------------------------------------------------------------- /tests/2004-php8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source _helpers.sh 3 | 4 | waitForSupervisordProcess web2004-php8 apache2 5 | waitForSupervisordProcess web2004-php8 mysqld 6 | 7 | testimage 2004-php8 3040 8 | #testmysql web2004-php8 3041 -------------------------------------------------------------------------------- /tests/_helpers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Echo success or cause an exit if the value passed != 0 3 | function checkstatus { 4 | if [ $1 -eq 0 ]; then 5 | echo "=> Success" 6 | else 7 | echo "=> Failed" 8 | exit $1 9 | fi 10 | } 11 | 12 | # Test our image, first curling our container and then checking the result against our expectations 13 | function testimage { 14 | echo "=> Querying image ($1)" 15 | docker-compose -f ../docker-compose.test.yml -p ci exec web$1 curl --head --retry 10 --retry-delay 5 --silent --show-error http://127.0.0.1 >/dev/null && \ 16 | curl --retry 3 --retry-delay 3 --silent --show-error --stderr - -o actual/$1.html http://localhost:$2 17 | checkstatus $? 18 | 19 | echo "=> Checking against expected values ($1)" 20 | diff -b actual/$1.html expected/$1.html 21 | checkstatus $? 22 | echo 23 | } 24 | 25 | function testmysql { 26 | echo "=> Connecting to MySQL: ($1:$2)" 27 | docker-compose -f ../docker-compose.test.yml -p ci exec $1 mysql -h 127.0.0.1 -u admin -ppassword -e"quit" && \ 28 | mysql -h 127.0.0.1 -P $2 -u admin -ppassword -e"quit" 29 | checkstatus $? 30 | } 31 | 32 | function waitForSupervisordProcess { 33 | while true; do 34 | echo "=> Waiting for $2 on the service $1..." 35 | docker-compose -f ../docker-compose.test.yml -p ci exec $1 supervisorctl status $2 36 | [ $? -ne 0 ] || break 37 | sleep 5 38 | done 39 | } 40 | -------------------------------------------------------------------------------- /tests/expected/2004-php7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello World from Docker-LAMP 6 | 7 | 31 | 32 | 33 |
34 |
35 | Docker LAMP logo 36 |

Welcome to Docker-Lamp a.k.a mattrayner/lamp

37 |
38 |
39 |

40 | For documentation, click here. 41 |

42 |
43 |
44 |
45 | OS: Ubuntu 20.04.6 LTS
46 | Apache: Apache/2.4.41 (Ubuntu)
47 | MySQL Version: 8.0.36-0ubuntu0.20.04.1
48 | PHP Version: 7.4.33
49 | phpMyAdmin Version: 5.1.1
50 |
51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/expected/2004-php8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello World from Docker-LAMP 6 | 7 | 31 | 32 | 33 |
34 |
35 | Docker LAMP logo 36 |

Welcome to Docker-Lamp a.k.a mattrayner/lamp

37 |
38 |
39 |

40 | For documentation, click here. 41 |

42 |
43 |
44 |
45 | OS: Ubuntu 20.04.6 LTS
46 | Apache: Apache/2.4.41 (Ubuntu)
47 | MySQL Version: 8.0.36-0ubuntu0.20.04.1
48 | PHP Version: 8.0.30
49 | phpMyAdmin Version: 5.1.1
50 |
51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /tests/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source _helpers.sh 3 | 4 | echo 5 | echo "Testing mattrayner/lamp" 6 | 7 | if [ -d actual ]; then 8 | rm -R actual 9 | fi 10 | mkdir actual 11 | 12 | echo 13 | echo "=> Testing 20.04 PHP 7 images" 14 | . 2004-php7.sh 15 | 16 | echo "=> Testing 20.04 PHP 8 images" 17 | . 2004-php8.sh 18 | --------------------------------------------------------------------------------