Skip to content
Permalink
Browse files

Adds prod/dev env switch and runs cron server

Running prod:
 - docker-compose build
 - docker-compose up

Running dev:
 - docker-compose -f docker-compose-dev.yml build
 - docker-compose -f docker-compose-dev.yml up
  • Loading branch information...
m038 committed Jun 22, 2015
1 parent 9d454bd commit ddd3d7ca6282f9d9b78edcc8adf553b14f9616a0
Showing with 87 additions and 30 deletions.
  1. +6 −2 Dockerfile
  2. +14 −0 docker-compose-dev.yml
  3. +7 −12 docker-compose.yml
  4. +20 −5 docker/docker-entrypoint.sh
  5. +15 −0 docker/docker-newscoop.yml
  6. +14 −0 docker/newscoop-dev.conf
  7. +11 −11 docker/newscoop.conf
@@ -18,16 +18,20 @@ WORKDIR /usr/share/newscoop
#VOLUME /var/www

# copy virtual host config and source code
ADD docker/newscoop.conf /etc/apache2/sites-enabled/newscoop.conf
ADD docker/newscoop.conf /etc/apache2/sites-available/newscoop.conf
ADD docker/newscoop-dev.conf /etc/apache2/sites-available/newscoop-dev.conf
ADD newscoop /var/www/newscoop

# Enable production env
RUN a2ensite newscoop

# add management scripts
ADD docker /usr/share/newscoop

# update permissions
# 1000 needs to be a dynamic var for the userid of the files
# on the host
RUN usermod -u 1000 www-data
RUN usermod -u 1000 www-data

# turn on mod_rewrite, update php config
#RUN a2ensite newscoop.conf
@@ -0,0 +1,14 @@
newscoop:
extends:
file: docker/docker-newscoop.yml
service: newscoop
links:
- mysql
environment:
- APPLICATION_ENVIRONMENT=dev

mysql:
extends:
file: docker/docker-newscoop.yml
service: mysql

@@ -1,17 +1,12 @@
newscoop:
build: .
command: newscoop
extends:
file: docker/docker-newscoop.yml
service: newscoop
links:
- mysql
ports:
- "80:80"
volumes:
- ./newscoop:/var/www/newscoop

mysql:
image: "mysql:5"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: newscoop
volumes:
- ./data/mysqldb:/var/lib/mysql
extends:
file: docker/docker-newscoop.yml
service: mysql

@@ -3,30 +3,45 @@
if [ "$1" = 'newscoop' ]; then
# install composer and install PHP dependencies
if [ ! -f /var/www/newscoop/composer.phar ]; then
cd /var/www/newscoop && curl -s https://getcomposer.org/installer | php
cd /var/www/newscoop && curl -sS https://getcomposer.org/installer | php
fi
if [ "$APPLICATION_ENVIRONMENT" = "dev" ]; then
# Disable production, enable dev
a2dissite newscoop
a2ensite newscoop-dev
cd /var/www/newscoop && /usr/bin/php composer.phar install
else
cd /var/www/newscoop && /usr/bin/php composer.phar install --no-dev
fi
cd /var/www/newscoop && /usr/bin/php composer.phar install --no-dev
chown -R www-data:www-data /var/www/newscoop

# check if we should install
if [ -f /var/www/newscoop/conf/installation.php ]; then
/usr/share/newscoop/import-newscoop.sh
/usr/share/newscoop/import-newscoop.sh
fi

# catch signlas
trap "echo 'caught signal'" HUP INT QUIT KILL TERM

start cron

#/usr/sbin/apachectl -D FOREGROUND
/usr/sbin/apachectl start

tail -F /var/www/newscoop/log/prod.log
if [ "$APPLICATION_ENVIRONMENT" = "dev" ]; then
tail -F /var/www/newscoop/log/dev.log
else
tail -F /var/www/newscoop/log/prod.log
fi

echo "[hit enter key to exit] or run docker stop <container>'"
read

echo "stopping apache"
/usr/sbin/apachectl stop

echo "stopping cron"
stop cron

echo "exited $0"
fi

@@ -0,0 +1,15 @@
newscoop:
build: ../
command: newscoop
ports:
- "80:80"
volumes:
- ../newscoop:/var/www/newscoop

mysql:
image: "mysql:5"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: newscoop
volumes:
- ../data/mysqldb:/var/lib/mysql
@@ -0,0 +1,14 @@
<VirtualHost *:80>
DocumentRoot /var/www/newscoop
ServerName newscoop.docker
ServerAlias localhost boot2docker *.boot2docker newscoop.docker *.newscoop.docker newscoop.dckr *.newscoop.dckr
DirectoryIndex index.php index.html
<Directory /var/www/newscoop>
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
@@ -1,13 +1,13 @@
<VirtualHost *:80>
DocumentRoot /var/www/newscoop
ServerName newscoop.docker
ServerAlias localhost boot2docker *.boot2docker newscoop.docker *.newscoop.docker
DirectoryIndex index.php index.html
<Directory /var/www/newscoop>
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
DocumentRoot /var/www/newscoop
ServerName newscoop.docker
ServerAlias localhost boot2docker *.boot2docker newscoop.docker *.newscoop.docker newscoop.dckr *.newscoop.dckr
DirectoryIndex index.php index.html
<Directory /var/www/newscoop>
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>

0 comments on commit ddd3d7c

Please sign in to comment.
You can’t perform that action at this time.