Commit be9b835e authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'docker' into 7.x

parents 4746fff8 ac2b1e52
......@@ -20,6 +20,12 @@ deploy/id_rsa*
# Ignore test logs directory
logs
# Ignore IDES folders
nbproject
# Ignore ides directories
/nbproject
.idea
# Ignore profile directory
sflinux
# Ignore ssh keys
deploy/id_rsa*
[submodule "drupalizer"]
path = drupalizer
url = git@gitlab.savoirfairelinux.com:drupal/drupalizer.git
# docker Drupal
# VERSION 0.3
FROM sflinux/baseimage
MAINTAINER Ernesto Rodriguez Ortiz <ernesto.rodriguezortiz@savoirfairelinuc.com>
# Create project root directory and copy the structure
RUN mkdir /opt/sfl-boilerplate
COPY . /opt/sfl-boilerplate
# Setup ssh keys to clone git repo
RUN mv /opt/sfl-boilerplate/deploy/id_rsa* /root/.ssh/
RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
RUN chmod 600 /root/.ssh/id_rsa*
RUN exec ssh-agent /bin/bash && ssh-add /root/.ssh/id_rsa
RUN ssh-keyscan gitlab.savoirfairelinux.com >> /root/.ssh/known_hosts
#Copy vhost configuration and enable modules
RUN cp /opt/sfl-boilerplate/deploy/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite vhost_alias
\ No newline at end of file
# Installation
## Création d'une nouvelle instance
Le script site-install va créer un nouveau site dans le répertoire src/drupal.
<code>
./site-install
</code>
### Restore the latest database dump
<code>
cd src/drupal
zcat ../../build/sfl_boilerplate_dbdump_latest.sql.gz | mysql -u <user> -p <dbname>
</code>
## Mise à jour d'un site existant
<code>
cd src/drupal
drush make --no-core ../../build/sfl_boilerplate .
drush updatedb
</code>
Docker-Drupal-sflboilerplate
============================
This repo contains a recipe for making a [Docker](http://docker.io) image for Drupal.
To build, make sure you have Docker [installed](http://www.docker.io/gettingstarted/).
This will try to go in line with [Drupal automated-testing](https://drupal.org/automated-testing).
## Install docker:
First, check that your APT system can deal with https URLs: the file /usr/lib/apt/methods/https should exist. If it doesn't, you need to install the package apt-transport-https.
```
[ -e /usr/lib/apt/methods/https ] || {
apt-get update
apt-get install apt-transport-https
}
```
Then, add the Docker repository key to your local keychain.
```
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
```
Add the Docker repository to your apt sources list, update and install the lxc-docker package.
```
sudo sh -c "echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker
```
Add your user to the docker group to be able to execute docker command wihtout sudo
```
adduser <user> docker
```
## This project depend of [Docker-BaseImage](https://gitlab.savoirfairelinux.com/erortiz/docker-lampd/tree/master).
This project use like [Docker-BaseImage](https://gitlab.savoirfairelinux.com/erortiz/docker-lampd/tree/master) base image. Then we first need to clone this project and build the sflinux/baseimage. Information about build this image is here [Docker-BaseImage](https://gitlab.savoirfairelinux.com/erortiz/docker-lampd/tree/master), but in resume you need:
Clone the repo some where
```
git clone https://gitlab.savoirfairelinux.com/erortiz/docker-lampd.git
cd docker-lampd
```
and then build it:
```
sudo docker build -t sflinux/baseimage .
```
This can take a while but should eventually return a command prompt. It's done when it says "Successfully built {hash}"
That's it!
## Now is time to build our project sfl-boilerplate.
Is almost the same procedure
Clone the repo some where but you need to clone the branch docker
```
git clone -b docker https://gitlab.savoirfairelinux.com/drupal/sfl-boilerplate.git
```
Get the submodule to deploy the site:
```
cd sfl-boilerplate
git submodule init
git submodule update
```
Copy and change at your needs the file local_vars.py from the directory /deploy to /drupy:
```
cp deploy/local_vars.py drupy/local_vars.py
nano drupay/local_vars.py
```
Build the site and setup all configurations:
```
cd drupy
fab local_setup
```
That's it!
## Contributing
Feel free to fork and contribute to this code. :)
## Authors
Created and maintained by [Ernesto Rodriguez Ortiz][author] (ernesto.rodriguezortiz@savoirfairelinux.com>)
## License
GPL v2
Voir INSTALL.txt pour les instructions d'installation.
Jenkin job: https://test.savoirfairelinux.com/view/Drupal/job/drupal-sfl-boilerplate
\ No newline at end of file
Copy patches that can be applied in the site.
Patches that must be applied should be specified in the Makefile.
core = 7.x
projects[] = drupal
api = 2
; SFLinux installation profile
projects[sflinux][type] = profile
projects[sflinux][download][type] = git
projects[sflinux][download][url] = git@gitlab.savoirfairelinux.com:drupal/sflinux.git
projects[sflinux][download][branch] = 7.x
......@@ -7,11 +7,11 @@
* Drush aliases definition.
*/
$aliases['staging'] = array(
'root' => '/var/www/html/drupal',
'uri' => 'http://example.com',
'remote-host' => 'http://example.com',
'remote-user' => 'webmaster',
$aliases['dk'] = array(
'root' => '/var/www/drupal',
'uri' => 'http://local.boilerplate.sfl',
'remote-host' => 'local.boilerplate.sfl',
'remote-user' => 'root',
'path-aliases' => array(
'%files' => 'sites/default/files',
),
......
#!/bin/bash
set -e
# Check this for long args example https://gist.github.com/cosimo/3760587
# Get params from build
TAG=$1
# Change this if needed
if [ -r .drush-deploy.rc ]; then
source .drush-deploy.rc
elif [ -r ~/.drush-deploy.rc ]; then
source ~/.drush-deploy.rc
else
DB_USER=testuser
DB_PASS=testuser
fi
DRUPAL_ROOT="$WORKSPACE"/src/drupal
CUSTOMDIR=$DRUPAL_ROOT/sites/all/modules/custom
# Do not edit after
EN_CODER=0
EN_PHPCPD=0
EN_PHPMD=0
EN_TESTS=0
EN_BEHAT=0
EN_AUDIT=0
E_OPTERR=65
function display_usage {
echo "Usage :
-c, --coder
Checkstyle of custom modules
Report type : Checkstyle results
files -> logs/coder-*.xml
-d, --phpcpd
Copy paste detector of custom modules
Report type : PMD results
file -> logs/phpmd-drupal.xml
-m, --phpmd
Check Duplicate code of custom modules
Report type : Duplicate code results
file -> logs/phpcpd-drupal.xml
-t, --tests
Run Simple test
Report type : XML report Junits
files -> logs/tests/*.xml
-b, --behat
Run behat unitary tests
Report type : XML report Junits
files -> logs/behat/*.xml
-l, --legacy
Enable Legacy drupal Organisation Folders
Example :
./jenkins.sh -c -d -m -t -b
./jenkins.sh -cdmtb
./jenkins.sh --coder --phpcpd --phpmd --tests --behat
"
}
function drupal_install {
# We need to create an empty DB for drupal using our test user account
mysqladmin -f -u$DB_USER -p$DB_PASS drop $DB_NAME
mysqladmin -u$DB_USER -p$DB_PASS create $DB_NAME
cd $DRUPAL_ROOT
# Launch site installation. It will create database structure and edit settings.php
# Install site
if ! drush si --yes --locale="fr" --db-url="mysql://$DB_USER:$DB_PASS@localhost/${DB_NAME}" --site-name="SFL Boilerplate" standard --account-name=admin --account-pass=admin --clean-url=1
then
echo "Fail to site install"
exit 1
fi
# Setup signal handler so DB are always deleted
trap script_end 0
trap "exit 2" 1 2 3 13 15
if ! drush status
then
echo "Failed to get status"
exit 1
fi
}
function script_end {
# Drop this build database
echo "Nothing to do here."
}
function fix_permissions {
# Permissions
# chown jenkins:www-data $DRUPAL_ROOT/sites/default
# Directory for tests output
if [ ! -d "$WORKSPACE/output" ]; then
mkdir $WORKSPACE/output
fi
}
function run_coder {
echo "run_coder START"
if [ -d "$CUSTOMDIR" ]; then
mkdir -p ${WORKSPACE}/logs/coder
cd $DRUPAL_ROOT
drush dl coder --yes
drush en coder coder_review --yes
MODULES=$(ls -d $CUSTOMDIR)
#Run coder against our modules
for MOD in $MODULES; do
drush coder-review --checkstyle --major --severity --comment --druplart --security --sql --sniffer --style $MOD > ${WORKSPACE}/logs/coder/coder-$MOD.xml 2> /dev/null
done
else
echo "Nothing for coder in $CUSTOMDIR"
fi
}
function run_phpcpd {
echo "run_phpcpd START"
if [ -d "$CUSTOMDIR" ]; then
mkdir -p ${WORKSPACE}/logs/phpcpd
# Run Copy/Paste detector
phpcpd --log-pmd ${WORKSPACE}/logs/phpcpd/phpcpd-drupal.xml $CUSTOMDIR
else
echo "Nothing for phpcpd in $CUSTOMDIR"
fi
}
function run_phpmd {
echo "run_phpmd START"
if [ -d "$CUSTOMDIR" ]; then
mkdir -p ${WORKSPACE}/logs/phpmd
# Run PHP MEss Detector on our custom modules
phpmd $CUSTOMDIR xml codesize,unusedcode,naming --reportfile ${WORKSPACE}/logs/phpmd/phpmd-drupal.xml 2> /dev/null
else
echo "Nothing for phpmd in $CUSTOMDIR"
fi
}
function run_tests {
echo "run_tests START"
mkdir -p ${WORKSPACE}/logs/tests
cd $DRUPAL_ROOT
drush en simpletest --yes
drush vset clean_url 0
php scripts/run-tests.sh --php /usr/bin/php --color --url http://test-amideploy --verbose --xml ${WORKSPACE}/logs/tests System
}
function run_behat {
echo "run_behat START"
mkdir -p ${WORKSPACE}/logs/behat
#Behat tests
#Init for initialise the yml config of behat
cd ${WORKSPACE}/test/behat
./behat --ansi --format junit,pretty --out ${WORKSPACE}/logs/behat,
}
function site_audit {
# Full report using site_audit drush module
drush aa --html --bootstrap --detail --skip=insights > $WORKSPACE/output/site_audit.html
}
function run_all_tests {
if [ $EN_CODER -eq 1 ]; then
run_coder
fi
if [ $EN_PHPCPD -eq 1 ]; then
run_phpcpd
fi
if [ $EN_PHPMD -eq 1 ]; then
run_phpmd
fi
if [ $EN_TESTS -eq 1 ]; then
run_tests
fi
if [ $EN_BEHAT -eq 1 ]; then
run_behat
fi
if [ $EN_AUDIT -eq 1 ]; then
site_audit
fi
}
function build_artefacts {
# Export code and database. This is a test for Pantheon
# Creating a code archive
# Specify the destination folder
TARGET=$WORKSPACE/build
# Specify the source folder
SOURCE=$WORKSPACE/src
# Change directory to the source folder
cd $SOURCE
# Create an archive that excludes sites/default/files
drush archive-dump --tar-options="--exclude=.git" --destination=$TARGET/sfl_boilerplate-archive.tar.gz --overwrite
# Create a compressed database backup
drush sql-dump | gzip -9 > $TARGET/db.sql.gz
}
if [ -z "$*" ]; then
display_usage
# exit $E_OPTERR
else
OPTS=`getopt -o cdmtbal --long coder,phpcpd,phpmd,tests,behat,audit,legacy -- "$@"`
if [ $? != 0 ] ; then
echo "Failed parsing options."
display_usage
exit $E_OPTERR
fi
eval set -- "$OPTS"
fi
while true; do
case "$1" in
-c | --coder ) EN_CODER=1; shift ;;
-d | --phpcpd ) EN_PHPCPD=1; shift ;;
-m | --phpmd ) EN_PHPMD=1; shift ;;
-t | --tests ) EN_TESTS=1; shift ;;
-b | --behat ) EN_BEHAT=1; shift ;;
-a | --audit ) EN_AUDIT=1; shift ;;
-l | --legacy ) drupal_legacy; shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done
drupal_install
fix_permissions
run_all_tests
# SUCCESS if we are here
exit 0
#********************************
# WARNING WARNING WARNING
#********************************
# YOU MUST COPY THIS FILE IN THE SUBMODULE DIRECTORY FOLDER
# If you want to override the variable definitions of the submodule drupy, you must
# copy and paste this file in the directory of the submodule so it can be imported.
# When you create a file local_vars.py and define the values there, the fabfile.py file will use
# your values and not the values defined in this file.
#********************************
# END WARNING
#********************************
from os import path
# The Apache user
APACHE = 'www-data'
# Variables to use at your local machine
LOCAL_WORKSPACE = path.join(path.dirname(__file__), path.pardir)
LOCAL_DRUPAL_ROOT = '{}/src/drupal'.format(LOCAL_WORKSPACE)
# Variables to use inside the docker container
DOCKER_WORKSPACE = "/opt/sfl_boilerplate"
DOCKER_DRUPAL_ROOT = "/var/www/drupal"
DOCKER_PORT_TO_BIND = 8001
# Database variables
DB_USER = 'dev'
DB_PASS = 'dev'
DB_HOST = 'localhost'
DB_NAME = 'sfl_boilerplate'
# Site variables
SITE_NAME = 'SFL Boilerplate'
SITE_SUBDIR = 'default'
SITE_PROFILE = 'sflinux'
SITE_ADMIN_NAME = 'admin'
SITE_ADMIN_PASS = 'admin'
SITE_ENVIRONMENT = 'local'
SITE_HOSTNAME = 'local.boilerplate.sfl'
# Projects variables
PROJECT_NAME = 'sfl_boilerplate'
PROFILE = {'sflinux':'git@gitlab.savoirfairelinux.com:drupal/sflinux.git'}
PROFILE_MAKE_FILE = 'build/build-sflinux.make'
# Drush commands to be run at the end of the installation process
POST_INSTALL = ['drush d-conf', 'drush fra -y', 'drush po-import fr --custom-only', 'drush cc all']
# Drush commands to be run at the end of the update process
POST_UPDATE = ['drush d-conf', 'drush fra -y', 'drush po-import fr --custom-only', 'drush cc all']
# Test variables
TEST_DB_USER = 'testuser'
TEST_DB_PASS = 'testuser'
TEST_DB_NAME = 'sfl_boilerplate_tests'
TEST_SITE_HOSTNAME = 'tests.local.boilerplate.sfl'
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/drupal
<Directory /var/www/drupal>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/drupal_error.log
CustomLog ${APACHE_LOG_DIR}/drupal_access.log combined
</VirtualHost>
\ No newline at end of file
Subproject commit 692e45c707119e7e144ef763faa2db67e4e8d6ba
#!/bin/bash
# site-install
#
# Script d'installation complète d'un site
#
# Pour installer un nouveau site :
# - rm -R src/drupal/
# - ./site-install
# set -x
# set -e
DRUSH=`which drush`
ME=`whoami`
APACHE=www-data
DB_USER=dev
DB_PASS=dev
DB_NAME=sfl_boilerplate
WORKSPACE=`pwd`
DRUPAL_ROOT=`pwd`/src/drupal
DRUSH_ALIASES=$DRUPAL_ROOT/sites/all/drush
# set default environment if not passed as parameter
DRUPAL_ENV=$1
if [ -z "$1" ]; then
DRUPAL_ENV=local
fi
#if [ -d $DRUPAL_ROOT ]; then
# rm -rf $DRUPAL_ROOT
#fi
# Makefile
drush make --prepare-install --translations=fr build/sfl-boilerplate.make $DRUPAL_ROOT -y || exit 1
# Site installation
cd $DRUPAL_ROOT
# Run drush as the web server user
sudo -u $APACHE drush si sflinux --locale="fr" --db-url=mysql://$DB_USER:$DB_PASS@localhost/$DB_NAME --site-name="SFL Boilerplate" --account-name=admin --account-pass=admin --clean-url=1 -y
# Copy drush aliases
mkdir $DRUSH_ALIASES
cd $DRUSH_ALIASES
ln -s $WORKSPACE/deploy/example.drushrc.aliases.php .
echo "Copy drush aliases in "$DRUSH_ALIASES
# Copy environment settings and call it in settings.php
cp $WORKSPACE/deploy/env/settings.$DRUPAL_ENV.php $DRUPAL_ROOT/sites/default/settings.$DRUPAL_ENV.php
echo "
/**
* Call environment settings file.
*/
require_once 'settings."$DRUPAL_ENV".php';" >> $DRUPAL_ROOT/sites/default/settings.php
echo "Copy environment settings file in "$DRUPAL_ROOT"/sites/default/ and call it in settings.php file"
# Secure settings.php file
chmod 644 $DRUPAL_ROOT/sites/default/settings.php
echo "Secure settings.php file"
# apply environment configuration
drush d-conf
exit 0;
In this directory will be build all the Drupal site and you will find all source code of Drupal core,
contrib modules, custom modules, themes, profiles, etc.
Supports Markdown
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