Initial commit

parents
FROM mattrayner/lamp:latest-1604
ADD run.sh /run.sh
# LAMP (Linux/Apache/MySQL/PHP)
This LAMP docker image is based on `mattrayner/lamp:latest-1604` image.
You have more detailed information at https://hub.docker.com/r/mattrayner/lamp/
# Build the image
First, you have to build the docker image. This process has to be done only once.
```
git clone https://www.sing-group.org/dt/gitlab/dgpena/lampserver
cd lampserver
docker build . -t lampserver
```
# Running the server
Go to the directory **where your web files are placed**, and run:
```
docker run -it -e PHP_DISPLAY_ERRORS=On -e DOCKER_USER_ID=`id -u \`whoami\`` \
-p "80:80" -v ${PWD}:/app -v ${PWD}/mysql:/var/lib/mysql --name lampserver-1 \
--rm lampserver
```
`lampserver-1` is the name of the docker *container*, i.e, a running instance
of the `lampserver` image.
The first time you run the server in your directory, a MySQL data folder will
be created inside your web directory under `./mysql`
(you can change this if you want changing
`-v <directory_for_mysql_data>:/var/lib/mysql`).
A password for the `admin` user of MySQL is shown the first time.
Your server is available at: http://localhost (if you want to use another port
of your host machine, change `-p "80:80"` by `-p "<another_port>:80"`)
# Using MySQL
1. You can use PHPMyAdmin by going to http://localhost/phpmyadmin. You have
to login with the `admin` user.
2. Alternatively, you can use the MySQL client for a running instance by issuing:
```
docker exec -it lampserver-1 mysql -uroot
```
# Backup a database
You can get an SQL dump of a given database in your running instance by issuing:
```
docker exec -it lampserver-1 mysqldump -uroot [yourdatabasename] > db.sql
```
#!/bin/bash
VOLUME_HOME="/var/lib/mysql"
sed -ri -e "s/^upload_max_filesize.*/upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}/" \
-e "s/^post_max_size.*/post_max_size = ${PHP_POST_MAX_SIZE}/" /etc/php/5.6/apache2/php.ini
if [ "$PHP_DISPLAY_ERRORS" == "On" ];then
sed -ri -e "s/^display_errors.*/display_errors = On/" /etc/php/5.6/apache2/php.ini
fi
sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=staff/" /etc/apache2/envvars
if [ -n "$APACHE_ROOT" ];then
rm -f /var/www/html && ln -s "/app/${APACHE_ROOT}" /var/www/html
fi
sed -i -e "s/cfg\['blowfish_secret'\] = ''/cfg['blowfish_secret'] = '`date | md5sum`'/" /var/www/phpmyadmin/config.inc.php
mkdir -p /var/run/mysqld
usermod -u $DOCKER_USER_ID www-data
if [ -n "$VAGRANT_OSX_MODE" ];then
groupmod -g $(($DOCKER_USER_GID + 10000)) $(getent group $DOCKER_USER_GID | cut -d: -f1)
groupmod -g ${DOCKER_USER_GID} staff
chmod -R 770 /var/lib/mysql
chmod -R 770 /var/run/mysqld
chown -R www-data:staff /var/lib/mysql
chown -R www-data:staff /var/run/mysqld
else
# Tweaks to give Apache/PHP write permissions to the app
chown -R www-data:staff /var/www
chown -R www-data:staff /app
chown -R www-data:staff /var/lib/mysql
chown -R www-data:staff /var/run/mysqld
chmod -R 770 /var/lib/mysql
chmod -R 770 /var/run/mysqld
fi
rm /var/run/mysqld/mysqld.sock
sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
sed -i "s/user.*/user = www-data/" /etc/mysql/my.cnf
if [[ ! -d $VOLUME_HOME/mysql ]]; then
echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME"
echo "=> Installing MySQL ..."
# Try the 'preferred' solution
mysqld --initialize-insecure > /dev/null 2>&1
# IF that didn't work
if [ $? -ne 0 ]; then
# Fall back to the 'depreciated' solution
mysql_install_db > /dev/null 2>&1
fi
echo "=> Done!"
/create_mysql_users.sh
else
echo "=> Using an existing volume of MySQL"
fi
exec supervisord -n
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment