Docker LAMP sceleton. Fast docker web project up for your existing or new web projects with an envirement you want. If you don't want to waste your time to changing/setuping the envirenment for some webapps you can simply clone the repo and build the images, and then run your project on built environment.
Only the first build will take some time (You can grab some tee meanwhile), then docker images are cached.
- Its better to look at project_example folder to understand the configuration for your project
- Run
sh build.sh
- Run
cd project_example/swayoleg.lamp && docker-compose up -d
- Open 177.168.1.10 at browser and see phpinfo from project folder
This is basic example of usage.
- Install docker, docker compose, add your user to docker group
- Build all base images with
sh build.sh
command - Copy project_example/swayoleg-lamp to your project folder as %yourprojectpath%/swayoleg-lamp
- Edit %yourprojectpath%/swayoleg-lamp/.env with your values. The main config option are VIRTUAL_HOST (the domain to work with, without www ) and DB_FOLDER - please make sure it exists and writable
- Map your dev domain (VIRTUAL_HOST from previous step) to ip of srv container
SRV_IP
(add 177.168.1.10 yourproject.domain at hosts file) - If your project has different web root, please edit .env with
APP_PATH
  andURL_ROOT_FOLDER_FROM_APP_PATH
values. More info see at "##### The folder mapping section" - Go to %yourprojectpath%/swayoleg-lamp/ and run the docker-compose up -d.
cd swayoleg-lamp && docker-compose up -d
- open browser with your domain mapped on
SRV_IP
and see phpinfo
In next example we have the app configured with virtual host for swayoleg.lamp
domain, aplication root folder is located one level up from swayoleg-lamp folder (in %yourprojectpath%), and application web DOCUMENT ROOT (where server looks for entrypoint) is %yourprojectpath%/hdocs
VIRTUAL_HOST=swayoleg.lamp
DB_FOLDER=/srv/olegsrv/db_data
SRV_CONTAINER=swayoleg-lamp-example
DB_CONTAINER=swayoleg-lamp-db-example
APP_PATH=..
URL_ROOT_FOLDER_FROM_APP_PATH=htdocs/
TERM=xterm
DB_IP=177.168.1.12
SRV_IP=177.168.1.10
NET_GATEWAY=177.168.1.1
NET_SUBNET=177.168.1.0/22`
Please note that URL_ROOT_FOLDER_FROM_APP_PATH
is a related path from APP_PATH
If your project has webroot same as %yourprojectpath% please let the
URL_ROOT_FOLDER_FROM_APP_PATH
empty.
In next example we have the app configured with virtual host for swayoleg.lamp
domain, aplication root folder is located one level up from swayoleg-lamp folder (in %projectfolder%), and application web DOCUMENT ROOT is also at is %projectfolder% folder
VIRTUAL_HOST=swayoleg.lamp
DB_FOLDER=/srv/olegsrv/db_data
SRV_CONTAINER=swayoleg-lamp-example
DB_CONTAINER=swayoleg-lamp-db-example
APP_PATH=..
URL_ROOT_FOLDER_FROM_APP_PATH=
TERM=xterm
DB_IP=177.168.1.12
SRV_IP=177.168.1.10
NET_GATEWAY=177.168.1.1
NET_SUBNET=177.168.1.0/22`
VIRTUAL_HOST
section
- container names ( TIP: use your project name for srv per project and same db container name for all projects, cuz you actually dont need more instances for db )
SRV_CONTAINER=swayoleg-lamp-example
DB_CONTAINER=swayoleg-lamp-db-example
TERM=xterm
DB_FOLDER=/srv/olegsrv/db_data
DB_IP=177.168.1.12
SRV_IP=177.168.1.10
NET_GATEWAY=177.168.1.1
NET_SUBNET=177.168.1.0/22
The flexible folder mapping is working only when you work with your app by domain (not IP). If you working with webapp by IP it will always look to /var/www/html at srv container which is mapped to %projectfolder% by default, and this can be changed only in docker-compose.yml file.
If you are working with webapp by configured domain at .env file and this domain is mapped to SRV_IP
at your host machine, you can use flexible path mappings.
APP_PATH=..
URL_ROOT_FOLDER_FROM_APP_PATH=htdocs/
When you place swayoleg-lamp folder to your %projectflder% please note:
- The
APP_PATH
is the related path from %projectflder%/swayoleg-lamp to show the PATH of your webapp. - The
URL_ROOT_FOLDER_FROM_APP_PATH_PATH
is the related path from %projectflder% to show the WEB DOCUMENT ROOT of your webapp.
For server bash connection you can use
docker exec -ti swayoleg-lamp-example bash
where swayoleg-lamp-example is container name, you set at .env filedocker-compose exec srv bash
For mysql bash connection you can use
docker exec -ti swayoleg-lamp-db-example bash
where swayoleg-lamp-example is container name, you set at .env filedocker-compose exec swayolegdb bash
- Virtual host logs are located at /var/www/*.log folder (its good practice to add this files to your gitignore);
- Mysql logs are located at /var/log/mysql/error.log
- You can remove unused docker container images quickly by
sh ./sh/docker-cleanup.sh
- The
sh ./sh/project-cleanup.sh
will remove all built images of this project - The adminer interface will be available via ${SRV_IP}/adminer/ which is 177.168.1.10/adminer/ by default
- Use ${DB_IP} (177.168.1.12 by default) for connecting to mysql host.
- Apache 2.4.2
- PHP 7.0.1
- Ubuntu 16.04 for web server
- Debian 8.0 Jessie for DB container
- MySQL 5.7
Feel free to make an issue or ask for help.