Commit 6967405a authored by David Lawrence's avatar David Lawrence

Bug 1240172 - Move the docker configuration scripts from external github repo…

Bug 1240172 - Move the docker configuration scripts from external github repo into the Bugzilla code tree r=dylan
parent c81a842c
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
FROM centos
MAINTAINER David Lawrence <dkl@mozilla.com>
# Environment configuration
ENV USER bugzilla
ENV HOME /home/$USER
ENV BUGS_DB_DRIVER mysql
ENV BUGZILLA_ROOT $HOME/devel/htdocs/bugzilla
ENV GITHUB_BASE_GIT https://github.com/bugzilla/bugzilla
ENV GITHUB_BASE_BRANCH master
ENV GITHUB_QA_GIT https://github.com/bugzilla/qa
# Distribution package installation
COPY docker_files /docker_files
RUN yum -y -q update \
&& yum -y -q install https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm epel-release \
&& yum -y -q install `cat /docker_files/rpm_list` \
&& yum clean all
# User configuration
RUN useradd -m -G wheel -u 1000 -s /bin/bash $USER \
&& passwd -u -f $USER \
&& echo "bugzilla:bugzilla" | chpasswd
# Apache configuration
RUN cp /docker_files/bugzilla.conf /etc/httpd/conf.d/bugzilla.conf \
&& chown root.root /etc/httpd/conf.d/bugzilla.conf \
&& chmod 440 /etc/httpd/conf.d/bugzilla.conf
# MySQL configuration
RUN cp /docker_files/my.cnf /etc/my.cnf \
&& chmod 644 /etc/my.cnf \
&& chown root.root /etc/my.cnf \
&& rm -rf /etc/mysql \
&& rm -rf /var/lib/mysql/* \
&& /usr/bin/mysql_install_db --user=$USER --basedir=/usr --datadir=/var/lib/mysql
# Sudoer configuration
RUN cp /docker_files/sudoers /etc/sudoers \
&& chown root.root /etc/sudoers \
&& chmod 440 /etc/sudoers
# Clone the code repo initially
RUN su $USER -c "git clone $GITHUB_BASE_GIT -b $GITHUB_BASE_BRANCH $BUGZILLA_ROOT"
# Bugzilla dependencies and setup
RUN /bin/bash /docker_files/install_deps.sh
RUN /bin/bash /docker_files/bugzilla_config.sh
RUN /bin/bash /docker_files/my_config.sh
# Final permissions fix
RUN chown -R $USER.$USER $HOME
# Networking
RUN echo "NETWORKING=yes" > /etc/sysconfig/network
EXPOSE 80
EXPOSE 5900
# Testing scripts for CI
ADD https://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar /selenium-server.jar
# Supervisor
RUN cp /docker_files/supervisord.conf /etc/supervisord.conf \
&& chmod 700 /etc/supervisord.conf
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
bugzilla:
build: .
ports:
- "8080:80"
volumes:
- ".:/home/bugzilla/devel/htdocs/docker"
Docker Bugzilla
===============
Configure a running Bugzilla system using Docker
## Features
* Running latest Centos
* Preconfigured with initial data and test product
* Running Apache2 and MySQL Community Server 5.6
* Code resides in `/home/bugzilla/devel/htdocs/bugzilla and can be updated,
diffed, and branched using standard git commands
## How to install Docker Docker Machine and Docker Compose
* Visit [Docker][docker] and get docker up and running on your system.
## Important docker Notes
Before building, you will need to change value in the checksetup_answers.txt`
file to match the IP address of the Docker Machine VM. You can find the IP
address by running `docker-machine ip`.
For example, using a text editor, change the following line in
`checksetup_answers.txt` from:
` $answer{'urlbase'} = 'http://localhost:8080/bugzilla/';`
to
` $answer{'urlbase'} = 'http://192.168.59.103:8080/bugzilla/';`
## How to build Bugzilla Docker image
To build a fresh image, just change to the directory containing the checked out
files and run the below command:
```bash
$ docker-compose build
```
## How to start Bugzilla Docker image
To start a new container (or rerun your last container) you simply do:
```bash
$ docker-compose up
```
This will stay in the foreground and you will see the output from `supervisord`. You
can use the `-d` option to run the container in the background.
To stop, start or remove the container that was created from the last run, you can do:
```bash
$ docker-compose stop
$ docker-compose start
$ docker-compose rm
```
## How to access the Bugzilla container
If you are using Linux, you can simply point your browser to
`http://localhost:8080/bugzilla` to see the the Bugzilla home page.
If using Docker Machine, you will need to use the IP address of the VM. You can
find the IP address using the `docker-machine ip` command. For example:
```bash
$ docker-machine ip
192.168.59.103
```
So would then point your browser to `http://192.168.59.103:8080/bugzilla`.
The Administrator username is `admin@bugzilla.org` and the password is `password`.
You can use the Administrator account to creat other users, add products or
components, etc.
You can also shell into the container using `docker exec` command. You will need to
determine the container name or ID of the running container. Here is an example:
```bash
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2522438509d3 master_bugzilla "/usr/bin/supervisord" 38 seconds ago Up 37 seconds 5900/tcp, 0.0.0.0:8080->80/tcp master_bugzilla_1
$ docker exec -it master_bugzilla_1 su - bugzlla
Last login: Thu Jan 21 14:24:06 UTC 2016
[bugzilla@2522438509d3 ~]$
```
## TODO
* Enable SSL support.
[docker]: https://docs.docker.com/installation/
User bugzilla
Group bugzilla
ServerName localhost:80
#PerlSwitches -wT
#PerlConfigRequire /home/bugzilla/devel/htdocs/bugzilla/mod_perl.pl
<VirtualHost *:80>
AddHandler cgi-script .cgi
ServerName localhost
DocumentRoot "/home/bugzilla/devel/htdocs"
<Directory "/home/bugzilla/devel/htdocs">
DirectoryIndex index.cgi
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
cd $BUGZILLA_ROOT
# Configure database
/usr/bin/mysqld_safe &
sleep 5
mysql -u root mysql -e "GRANT ALL PRIVILEGES ON *.* TO bugs@localhost IDENTIFIED BY 'bugs'; FLUSH PRIVILEGES;"
mysql -u root mysql -e "CREATE DATABASE bugs CHARACTER SET = 'utf8';"
perl checksetup.pl /docker_files/checksetup_answers.txt
perl checksetup.pl /docker_files/checksetup_answers.txt
mysqladmin -u root shutdown
#! /bin/bash -e
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
buildbot_step_help() {
echo "Run a command and wrap it in buildbot step format"
echo " $0 - <buildbot step> [bash args...]"
}
bb_time() {
# Parser dies if this is longer then 6 chars long.
nano=$(date +%N | cut -c1-6)
echo "$(date '+%Y-%m-%d %H:%M:%S.')$nano"
}
bb_echo() {
echo "========= $1 ========="
}
bb_line() {
local type=$1 # Finished/Started
local step=$2 # Name of step
local code=$3 # Exit code
local duration=$4 # Elapsed time in seconds
local time=$(bb_time)
bb_echo "$type $step (results: $code, elapsed: $duration secs) (at $time)"
}
# Intentionally the full name of this executable so sourcing this file also
# works as expected...
buildbot_step() {
local step=$1
local command=${@:2}
local start_time=$(date +%s)
local exit_code=0
bb_line "Started" "$step" 0 0
if eval "$command";
then
exit_code=$?
else
exit_code=$?
fi
local end_time=$(date +%s)
local duration=$(($end_time-$start_time))
bb_line "Finished" "$step" $exit_code $duration
return $exit_code
}
# When this script is not being sourced invoke command directly.
if [ "$(basename $0)" == "buildbot_step" ];
then
if [ $# -lt 2 ];
then
buildbot_step_help
exit 1
fi
buildbot_step "$@"
exit $?
fi
$answer{'ADMIN_EMAIL'} = 'admin@bugzilla.org';
$answer{'ADMIN_OK'} = 'Y';
$answer{'ADMIN_PASSWORD'} = 'password';
$answer{'ADMIN_REALNAME'} = 'QA Admin';
$answer{'NO_PAUSE'} = 1;
$answer{'create_htaccess'} = '';
$answer{'db_check'} = 1;
$answer{'db_driver'} = 'mysql';
$answer{'db_host'} = 'localhost';
$answer{'db_mysql_ssl_ca_file'} = '';
$answer{'db_mysql_ssl_ca_path'} = '';
$answer{'db_mysql_ssl_client_cert'} = '';
$answer{'db_mysql_ssl_client_key'} = '';
$answer{'db_name'} = 'bugs',
$answer{'db_pass'} = 'bugs';
$answer{'db_port'} = 0;
$answer{'db_sock'} = '';
$answer{'db_user'} = 'bugs';
$answer{'diffpath'} = '/usr/bin';
$answer{'index_html'} = 0;
$answer{'interdiffbin'} = '/usr/bin/interdiff';
$answer{'memcached_servers'} = "localhost:11211";
$answer{'urlbase'} = 'http://localhost:8080/bugzilla/';
$answer{'use_suexec'} = '';
$answer{'webservergroup'} = 'bugzilla';
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
cd $BUGZILLA_ROOT
# Install Perl dependencies
CPANM="cpanm --quiet --notest --skip-satisfied"
perl checksetup.pl --cpanfile
$CPANM --installdeps --with-recommends --with-all-features \
--without-feature oracle --without-feature sqlite --without-feature pg .
# FIXME: These cause error when being installed using cpanfile
$CPANM HTML::Formatter
$CPANM HTML::FormatText::WithLinks
# Building PDF documentation
if [ ! -x "/usr/bin/rst2pdf" ]; then
pip install rst2pdf
fi
# For testing support
$CPANM JSON::XS
$CPANM Test::WWW::Selenium
$CPANM Pod::Coverage
$CPANM Pod::Checker
# Remove CPAN build files to minimize disk usage
rm -rf ~/.cpanm
[mysql]
max_allowed_packet=1G
[mysqld]
user = bugzilla
default_storage_engine = InnoDB
socket = /var/lib/mysql/mysql.sock
pid_file = /var/lib/mysql/mysql.pid
key_buffer_size = 32M
myisam_recover = FORCE,BACKUP
max_allowed_packet = 1G
max_connect_errors = 1000000
innodb = FORCE
datadir = /var/lib/mysql
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
tmp_table_size = 32M
max_heap_table_size = 32M
query_cache_type = 0
query_cache_size = 0
max_connections = 500
thread_cache_size = 50
#open_files_limit = 65535
table_definition_cache = 1024
table_open_cache = 2048
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = 1
innodb_buffer_pool_size = 1G
innodb_flush_neighbors = 0
innodb_flush_log_at_trx_commit = 2
log_error = /var/lib/mysql/mysql-error.log
log_queries_not_using_indexes = 0
slow_query_log = 0
slow_query_log_file = /var/lib/mysql/mysql-slow.log
general_log = 0
general_log_file = /var/lib/mysql/bmo_query.log
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
# Add any custom setup instructions here
aspell-devel
dbus-x11
dejavu-sans-mono-fonts
firefox
gcc
gcc-c++
gd-devel
git
gmp-devel
graphviz
java-1.7.0-openjdk
make
memcached
mod_perl
mod_perl-devel
mysql-community-devel
mysql-community-server
openssl-devel
passwd
patch
perl-App-cpanminus
perl-CPAN
perl-core
postfix
python-pip
python-reportlab
python-sphinx
sudo
supervisor
tar
tigervnc-server-minimal
unzip
vim-enhanced
wget
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
if [ -z "$TEST_SUITE" ]; then
TEST_SUITE=sanity
fi
set -e
# Output to log file as well as STDOUT/STDERR
exec > >(tee /runtests.log) 2>&1
echo "== Retrieving Bugzilla code"
echo "Checking out $GITHUB_BASE_GIT $GITHUB_BASE_BRANCH ..."
mv $BUGZILLA_ROOT "${BUGZILLA_ROOT}.back"
git clone $GITHUB_BASE_GIT --single-branch --depth 1 --branch $GITHUB_BASE_BRANCH $BUGZILLA_ROOT
cd $BUGZILLA_ROOT
if [ "$GITHUB_BASE_REV" != "" ]; then
echo "Switching to revision $GITHUB_BASE_REV ..."
git checkout -q $GITHUB_BASE_REV
fi
echo -e "\n== Checking dependencies for changes"
/docker_files/install_deps.sh
if [ "$TEST_SUITE" = "sanity" ]; then
cd $BUGZILLA_ROOT
/bin/bash /docker_files/buildbot_step "Sanity" prove -f -v t/*.t
exit $?
fi
if [ "$TEST_SUITE" = "docs" ]; then
cd $BUGZILLA_ROOT/docs
/bin/bash /docker_files/buildbot_step "Documentation" perl makedocs.pl --with-pdf
exit $?
fi
echo -e "\n== Cloning QA test suite"
cd $BUGZILLA_ROOT
echo "Cloning git repo $GITHUB_QA_GIT branch $GITHUB_BASE_BRANCH ..."
git clone $GITHUB_QA_GIT -b $GITHUB_BASE_BRANCH qa
echo -e "\n== Starting database"
/usr/bin/mysqld_safe &
sleep 3
echo -e "\n== Starting memcached"
/usr/bin/memcached -u memcached -d
sleep 3
echo -e "\n== Updating configuration"
sed -e "s?%DB%?$BUGS_DB_DRIVER?g" --in-place qa/config/checksetup_answers.txt
sed -e "s?%DB_NAME%?bugs_test?g" --in-place qa/config/checksetup_answers.txt
sed -e "s?%USER%?$USER?g" --in-place qa/config/checksetup_answers.txt
sed -e "s?%TRAVIS_BUILD_DIR%?$BUGZILLA_ROOT?g" --in-place qa/config/selenium_test.conf
echo "\$answer{'memcached_servers'} = 'localhost:11211';" >> qa/config/checksetup_answers.txt
if [ "$TEST_SUITE" == "checksetup" ]; then
cd $BUGZILLA_ROOT/qa
/bin/bash /docker_files/buildbot_step "Checksetup" ./test_checksetup.pl config/config-checksetup-$BUGS_DB_DRIVER
exit $?
fi
echo -e "\n== Running checksetup"
cd $BUGZILLA_ROOT
./checksetup.pl qa/config/checksetup_answers.txt
./checksetup.pl qa/config/checksetup_answers.txt
echo -e "\n== Generating test data"
cd $BUGZILLA_ROOT/qa/config
perl generate_test_data.pl
echo -e "\n== Starting web server"
sed -e "s?^#Perl?Perl?" --in-place /etc/httpd/conf.d/bugzilla.conf
/usr/sbin/httpd &
sleep 3
if [ "$TEST_SUITE" = "selenium" ]; then
export DISPLAY=:0
# Setup dbus for Firefox
dbus-uuidgen > /var/lib/dbus/machine-id
echo -e "\n== Starting virtual frame buffer and vnc server"
Xvnc $DISPLAY -screen 0 1280x1024x16 -ac -SecurityTypes=None \
-extension RANDR 2>&1 | tee /xvnc.log &
sleep 5
echo -e "\n== Starting Selenium server"
java -jar /selenium-server.jar -log /selenium.log > /dev/null 2>&1 &
sleep 5
# Set NO_TESTS=1 if just want selenium services
# but no tests actually executed.
[ $NO_TESTS ] && exit 0
cd $BUGZILLA_ROOT/qa/t
/bin/bash /docker_files/buildbot_step "Selenium" prove -f -v -I$BUGZILLA_ROOT/lib test_*.t
exit $?
fi
if [ "$TEST_SUITE" = "webservices" ]; then
cd $BUGZILLA_ROOT/qa/t
/bin/bash /docker_files/buildbot_step "Webservices" prove -f -v -I$BUGZILLA_ROOT/lib {rest,webservice}_*.t
exit $?
fi
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
root ALL=(ALL) ALL
%wheel ALL=(ALL) NOPASSWD: ALL
[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=debug
pidfile=/var/run/supervisord.pid
minfds=1024
minprocs=200
[program:httpd]
command=/usr/sbin/httpd -DFOREGROUND
[program:mysqld]
command=/usr/bin/mysqld_safe
[program:postfix]
command = /usr/sbin/postfix start
startsecs = 0
autorestart = false
[program:memcached]
command=/usr/bin/memcached -u memcached
stderr_logfile=/var/log/supervisor/memcached.log
stdout_logfile=/var/log/supervisor/memcached.log
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