-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,447 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ src/config.php | |
*.lock | ||
proxies/ | ||
.vagrant | ||
mysql_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Docker Image | ||
|
||
based on [tutum/lamp](https://github.com/tutumcloud/lamp). It was specialized for scrumonline. | ||
|
||
## Software Stack | ||
The image creates a basic container of debian jessie and the standard LAMP stack. | ||
|
||
* Apache2 | ||
* PHP5.6 | ||
* MySQL 5 | ||
|
||
## Build | ||
The image needs to be build once on every machine before using it. Using the *docker* command may require root access. | ||
|
||
```sh | ||
cd docker | ||
docker build -t scrum-lamp . | ||
``` | ||
|
||
**Note:** When rebuilding the image the old one is not replaced. To avoid wasting disk space you should delete the old image before | ||
running `docker build` again. Delete the old image by running: | ||
|
||
```sh | ||
docker rmi scrum-lamp | ||
docker build -t scrum-lamp . | ||
``` | ||
|
||
## Usage | ||
While you can use the standard docker commands it is recommended to use the `docker.sh` script in the root directory. | ||
|
||
```sh | ||
# Prepare repository and database. This must be called before calling start for the first time | ||
docker.sh prepare | ||
|
||
# All other commands might require root access, e.g. 'sudo ./docker.sh start' | ||
# Start container instance on localhost:8080 using empty database from image | ||
docker.sh start | ||
# Start container, but initialize and reuse database in directory 'mysql_db' | ||
docker.sh start mysql_db | ||
|
||
# Enter bash | ||
docker.sh bash | ||
# Access logs | ||
docker.sh readlog error | ||
docker.sh readlog access | ||
|
||
# Access db | ||
docker.sh db | ||
# Start myadmin graphical UI on localhost:8081 with credentials myadmin:myadmin | ||
docker.sh myadmin | ||
# Stop myadmin | ||
docker.sh myadmin stop | ||
|
||
# Kill the running container | ||
docker.sh stop | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
command=$1 | ||
current_dir=$(pwd) | ||
container_name=scrumonline | ||
image=scrum-lamp | ||
|
||
case $command in | ||
"prepare") | ||
echo "Preparing repository for usage with docker" | ||
php bin/composer install | ||
cp src/sample-config.php src/config.php | ||
# Overwrite host | ||
echo '$host = "localhost:8080";' >> src/config.php | ||
;; | ||
"start") | ||
running=$(docker ps -a -q) | ||
if [ -n "$running" ]; then | ||
echo "Stopping running containers" | ||
docker stop $running | ||
docker rm $running | ||
fi | ||
|
||
echo "Starting container $container_name..." | ||
mysql_dir=$2 | ||
if [ -n "$mysql_dir" ]; then | ||
docker run -d --name $container_name -p 8080:80 -p 3306:3306 \ | ||
-v $current_dir:/var/www/scrumonline -v $current_dir/$mysql_dir:/var/lib/mysql \ | ||
$image | ||
else | ||
docker run -d --name $container_name -p 8080:80 -p 3306:3306 \ | ||
-v $current_dir:/var/www/scrumonline $image | ||
fi | ||
echo "...done!" | ||
;; | ||
"stop") | ||
echo "Stopping container $container_name..." | ||
docker stop $container_name | ||
docker rm $container_name | ||
echo "...done" | ||
;; | ||
"readlog") | ||
log_name=$2 | ||
if [ -n "$log_name" ]; then | ||
docker exec -it $container_name tail -f /var/log/apache2/$log_name.log | ||
else | ||
echo "No log name specified" | ||
fi | ||
;; | ||
"db") | ||
docker exec -it $container_name mysql scrum_online -u root --password=passwd | ||
;; | ||
"myadmin") | ||
mycommand=$2 | ||
case $mycommand in | ||
"stop") | ||
docker stop myadmin | ||
docker rm myadmin | ||
;; | ||
*) | ||
docker run --name myadmin -d --link $container_name:db -p 8081:80 phpmyadmin/phpmyadmin | ||
;; | ||
esac | ||
;; | ||
"bash") | ||
docker exec -it $container_name bash | ||
;; | ||
"") | ||
echo "No command specified!" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM debian:jessie | ||
|
||
# Install packages | ||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN apt-get update && \ | ||
apt-get -y install supervisor \ | ||
apache2 libapache2-mod-php5 \ | ||
mysql-server mysql-client php5-mysql \ | ||
php5-xdebug php5-curl php5-imagick \ | ||
curl wget vim | ||
|
||
# Prepare apache/php config and directory | ||
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf | ||
ADD php_config /etc/php5/apache2/php.ini | ||
ADD php_config /etc/php5/cli/php.ini | ||
|
||
# Utils folder | ||
RUN mkdir /utils | ||
RUN mkdir /utils/custom | ||
|
||
# Run script | ||
ADD run.sh /utils/run.sh | ||
RUN chmod 755 /utils/run.sh | ||
|
||
# MySQL configuration | ||
ADD my.cnf /etc/mysql/conf.d/my.cnf | ||
ADD mysql_init.sh /utils/mysql_init.sh | ||
RUN chmod 755 /utils/mysql_init.sh | ||
|
||
# Supervisor configurations | ||
ADD supervisord-apache2.conf /etc/supervisor/conf.d/supervisord-apache2.conf | ||
ADD supervisord-mysqld.conf /etc/supervisor/conf.d/supervisord-mysqld.conf | ||
ADD start-apache2.sh /utils/start-apache2.sh | ||
ADD start-mysqld.sh /utils/start-mysqld.sh | ||
|
||
# Config with mod_rewrite | ||
ADD apache_default /etc/apache2/sites-available/000-default.conf | ||
ADD xdebug.ini /etc/php5/mods-available/xdebug.ini | ||
RUN a2enmod rewrite | ||
# Allow modification of http headers (needed for CORS) | ||
RUN a2enmod headers | ||
|
||
#Environment variables to configure php | ||
ENV PHP_UPLOAD_MAX_FILESIZE 20M | ||
ENV PHP_POST_MAX_SIZE 10M | ||
|
||
# Add volumes for MySQL and webroot | ||
VOLUME ["/var/lib/mysql", "/var/www/scrumonline"] | ||
|
||
EXPOSE 80 3306 | ||
CMD ["/utils/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<VirtualHost *:80> | ||
DocumentRoot /var/www/scrumonline/src | ||
|
||
RewriteEngine on | ||
RewriteRule ^/api/(\w+)/(\w+) /api.php?c=$1&m=$2 [QSA] | ||
|
||
ErrorLog ${APACHE_LOG_DIR}/error.log | ||
CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# | ||
# The MySQL database server configuration file. | ||
# | ||
# You can copy this to one of: | ||
# - "/etc/mysql/my.cnf" to set global options, | ||
# - "~/.my.cnf" to set user-specific options. | ||
# | ||
# One can use all long options that the program supports. | ||
# Run program with --help to get a list of available options and with | ||
# --print-defaults to see which it would actually understand and use. | ||
# | ||
# For explanations see | ||
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html | ||
|
||
# This will be passed to all mysql clients | ||
# It has been reported that passwords should be enclosed with ticks/quotes | ||
# escpecially if they contain "#" chars... | ||
# Remember to edit /etc/mysql/debian.cnf when changing the socket location. | ||
[client] | ||
port = 3306 | ||
socket = /var/run/mysqld/mysqld.sock | ||
|
||
# Here is entries for some specific programs | ||
# The following values assume you have at least 32M ram | ||
|
||
# This was formally known as [safe_mysqld]. Both versions are currently parsed. | ||
[mysqld_safe] | ||
socket = /var/run/mysqld/mysqld.sock | ||
nice = 0 | ||
|
||
[mysqld] | ||
# | ||
# * Basic Settings | ||
# | ||
user = mysql | ||
pid-file = /var/run/mysqld/mysqld.pid | ||
socket = /var/run/mysqld/mysqld.sock | ||
port = 3306 | ||
basedir = /usr | ||
datadir = /var/lib/mysql | ||
tmpdir = /tmp | ||
lc-messages-dir = /usr/share/mysql | ||
skip-external-locking | ||
# | ||
# Instead of skip-networking the default is now to listen only on | ||
# localhost which is more compatible and is not less secure. | ||
bind-address = 0.0.0.0 | ||
# | ||
# * Fine Tuning | ||
# | ||
key_buffer = 16M | ||
max_allowed_packet = 16M | ||
thread_stack = 192K | ||
thread_cache_size = 8 | ||
# This replaces the startup script and checks MyISAM tables if needed | ||
# the first time they are touched | ||
myisam-recover = BACKUP | ||
#max_connections = 100 | ||
#table_cache = 64 | ||
#thread_concurrency = 10 | ||
# | ||
# * Query Cache Configuration | ||
# | ||
query_cache_limit = 1M | ||
query_cache_size = 16M | ||
# | ||
# * Logging and Replication | ||
# | ||
# Both location gets rotated by the cronjob. | ||
# Be aware that this log type is a performance killer. | ||
# As of 5.1 you can enable the log at runtime! | ||
#general_log_file = /var/log/mysql/mysql.log | ||
#general_log = 1 | ||
# | ||
# Error log - should be very few entries. | ||
# | ||
log_error = /var/log/mysql/error.log | ||
# | ||
# Here you can see queries with especially long duration | ||
#slow_query_log_file = /var/log/mysql/mysql-slow.log | ||
#slow_query_log = 1 | ||
#long_query_time = 2 | ||
#log_queries_not_using_indexes | ||
# | ||
# The following can be used as easy to replay backup logs or for replication. | ||
# note: if you are setting up a replication slave, see README.Debian about | ||
# other settings you may need to change. | ||
#server-id = 1 | ||
#log_bin = /var/log/mysql/mysql-bin.log | ||
expire_logs_days = 10 | ||
max_binlog_size = 100M | ||
#binlog_do_db = include_database_name | ||
#binlog_ignore_db = include_database_name | ||
# | ||
# * InnoDB | ||
# | ||
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. | ||
# Read the manual for more InnoDB related options. There are many! | ||
# | ||
# * Security Features | ||
# | ||
# Read the manual, too, if you want chroot! | ||
# chroot = /var/lib/mysql/ | ||
# | ||
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca". | ||
# | ||
# ssl-ca=/etc/mysql/cacert.pem | ||
# ssl-cert=/etc/mysql/server-cert.pem | ||
# ssl-key=/etc/mysql/server-key.pem | ||
|
||
|
||
|
||
[mysqldump] | ||
quick | ||
quote-names | ||
max_allowed_packet = 16M | ||
|
||
[mysql] | ||
#no-auto-rehash # faster start of mysql but no tab completition | ||
|
||
[isamchk] | ||
key_buffer = 16M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
/usr/bin/mysqld_safe > /dev/null 2>&1 & | ||
|
||
RET=1 | ||
while [[ RET -ne 0 ]]; do | ||
echo "=> Waiting for confirmation of MySQL service startup" | ||
sleep 5 | ||
mysql -uroot -e "status" > /dev/null 2>&1 | ||
RET=$? | ||
done | ||
|
||
# Create user for myadmin | ||
mysql -uroot -e "CREATE USER 'myadmin'@'%' IDENTIFIED BY 'myadmin'" | ||
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO 'myadmin'@'%'" | ||
# Create database and set root password to match config | ||
mysql -uroot -e "CREATE DATABASE scrum_online" | ||
mysql -uroot -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('passwd');" | ||
|
||
# Create database schema | ||
pushd /var/www/scrumonline | ||
./vendor/bin/doctrine orm:schema-tool:create | ||
./vendor/bin/doctrine orm:generate-proxies | ||
popd |
Oops, something went wrong.