Skip to content

Commit

Permalink
First cut
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Minnee committed Jul 16, 2014
0 parents commit b83cf54
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM debian:wheezy
MAINTAINER Sam Minnee <[email protected]>

### SET UP

# BASE wheezy-backports O/S with some helpful tools
RUN echo "deb http://ftp.us.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list
RUN apt-get -qq update
RUN apt-get -qqy install sudo wget lynx telnet nano curl

# Known hosts
ADD known-hosts /root/.ssh/known-hosts

# APACHE
RUN apt-get -qqy install apache2

# MYSQL
RUN apt-get -qqy install mysql-server-5.5

# PHP AND SUPPORT TOOLS
RUN apt-get -qqy install php5-cli libapache2-mod-php5 php5-mysql php5-mcrypt php5-tidy php5-curl php5-gd php-pear

# - Phpunit
RUN wget https://phar.phpunit.de/phpunit-3.7.37.phar
RUN chmod +x phpunit-3.7.37.phar
RUN mv phpunit-3.7.37.phar /usr/local/bin/phpunit

# - Composer
RUN wget https://getcomposer.org/composer.phar
RUN chmod +x composer.phar
RUN mv composer.phar /usr/local/bin/composer

# - Phing
RUN pear channel-discover pear.phing.info
RUN pear install phing/phing

# SilverStripe Apache Configuration
RUN a2enmod rewrite
RUN rm /var/www/index.html
RUN echo "date.timezone = Pacific/Auckland" > /etc/php5/conf.d/timezone.ini

ADD apache-foreground /usr/local/bin/apache-foreground
ADD apache-default-vhost /etc/apache2/sites-available/default
ADD _ss_environment.php /var/_ss_environment.php

EXPOSE 80

# Run apache in foreground mode, because Docker needs a foreground
WORKDIR /var/www
CMD ["/usr/local/bin/apache-foreground"]

####
## These are not specifically SilverStripe related and could be removed on a more optimised image

# Ruby, RubyGems, Bundler
RUN apt-get -qqy install -t stable ruby
RUN gem install bundler
RUN gem install compass

# NodeJS
apt-get install nodejs-legacy
curl --insecure https://www.npmjs.org/install.sh | bash
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
docker build -t sminnee/silverstripe-lamp .

push: build
docker push sminnee/silverstripe-lamp
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Docker image: sminnee/silverstripe-lamp
=======================================

This is the source of a Docker image fro

* Run a LAMP stack suitable for SilverStripe (including an internal database)
* Uses Debian Wheezy with Backports
* Run SilverStripe tests
* Run SilverStripe release-packaging steps

A number of support tools are available:

* PHPUnit (PHP)
* Phing (PHP)
* Composer (PHP)
* NodeJS (JavaScript)
* NPM (JavaScript)
* Grunt (JavaScript)
* Gulp (JavaScript)
* RubyGems (Ruby)
* Bundler (Ruby)
* Compass (Ruby)

To help with headless download of packages, it has the github.com SSH key loaded as a known host.

Usage
-----

To run a build comment, mount your SilverStrpe root as `/var/www` and execute commands there:

build_dir=`pwd`
docker run -v $build_dir:/var/www sminnee/silverstripe-lamp -c 'composer install; phpunit'

To run a working instance of your SilverStripe code on a fresh database, run the image without
a command. In this example, we have mapped port 3000 to the HTTP port of the container.

build_dir=`pwd`
docker run -dP -p 3000:80 -v $build_dir:/var/www sminnee/silverstripe-lamp

**Note:** This is for development purposes only; the root database user has no password.
14 changes: 14 additions & 0 deletions _ss_environment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/* This file gives SilverStripe information about the environment that it's running in */
define('SS_ENVIRONMENT_TYPE', 'dev');

/* This defines a default database user */
define('SS_DATABASE_SERVER', '127.0.0.1');
define('SS_DATABASE_USERNAME', 'root');
define('SS_DATABASE_PASSWORD', '');

define('SS_DATABASE_NAME', 'silverstripe');

global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING['/var/www'] = 'http://localhost';
31 changes: 31 additions & 0 deletions apache-default-vhost
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
13 changes: 13 additions & 0 deletions apache-foreground
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
echo "Starting MySQL..."
/etc/init.d/mysql start

echo "Running dev/build..."
cd /var/www
sudo -u www-data ./framework/sake dev/build

echo "Starting apache..."
apache2ctl start

echo "Showing access.log..."
tail -f /var/log/apache2/access.log
2 changes: 2 additions & 0 deletions known-hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
|1|ZtfwJuT1UPuspaL3cTABFnAyNcg=|Z//5WJHvyha9+Z9h5xd97Jex/ws= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|1|l9koqpH/QidgSQMxfC//4w2AA+c=|S8tXsRRbjKywyapHBQfDHfSRBCk= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==

0 comments on commit b83cf54

Please sign in to comment.