]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1222497 - Refactor the BMO docker image with new file and script structure while...
authorDavid Lawrence <dkl@mozilla.com>
Fri, 6 Nov 2015 22:21:30 +0000 (22:21 +0000)
committerDavid Lawrence <dkl@mozilla.com>
Fri, 6 Nov 2015 22:21:30 +0000 (22:21 +0000)
16 files changed:
docker/Dockerfile
docker/docker-compose.yml [moved from docker/fig.yml with 60% similarity, mode: 0755]
docker/files/bugzilla.conf [moved from docker/bugzilla.conf with 93% similarity]
docker/files/checksetup_answers.txt [moved from docker/checksetup_answers.txt with 85% similarity]
docker/files/my.cnf [moved from docker/my.cnf with 100% similarity]
docker/files/rpm_list [new file with mode: 0644]
docker/files/sudoers [moved from docker/sudoers with 100% similarity]
docker/files/supervisord.conf [moved from docker/supervisord.conf with 92% similarity]
docker/rpm_list [deleted file]
docker/scripts/bugzilla_config.sh [moved from docker/bugzilla_config.sh with 55% similarity]
docker/scripts/buildbot_step [moved from docker/buildbot_step with 100% similarity]
docker/scripts/generate_bmo_data.pl [moved from docker/generate_bmo_data.pl with 97% similarity]
docker/scripts/install_deps.sh [moved from docker/install_deps.sh with 67% similarity]
docker/scripts/my_config.sh [moved from docker/my_config.sh with 100% similarity]
docker/scripts/runtests.sh [moved from docker/runtests.sh with 68% similarity]
docker/scripts/start.sh [new file with mode: 0755]

index 7c4a96d718461f6114726282228595c362282c6a..ebba20a48341908999104dc243e168c1a41e2db7 100644 (file)
@@ -2,71 +2,51 @@ FROM centos:centos7
 MAINTAINER David Lawrence <dkl@mozilla.com>
 
 # Environment configuration
-ENV BUGS_DB_DRIVER mysql
-ENV BUGS_DB_NAME bugs
-ENV BUGS_DB_PASS bugs
-ENV BUGS_DB_HOST localhost
-
-ENV BUGZILLA_USER bugzilla
-ENV BUGZILLA_HOME /home/$BUGZILLA_USER
-ENV BUGZILLA_ROOT $BUGZILLA_HOME/devel/htdocs/bmo
-ENV BUGZILLA_URL http://localhost/bmo
-
+ENV USER bugzilla
+ENV HOME /home/bugzilla
+ENV BUGZILLA_ROOT $HOME/devel/htdocs/bmo
 ENV GITHUB_BASE_GIT https://github.com/mozilla/webtools-bmo-bugzilla
 ENV GITHUB_BASE_BRANCH master
-ENV GITHUB_QA_GIT https://github.com/mozilla/webtools-bmo-qa
 
-ENV ADMIN_EMAIL admin@mozilla.bugs
-ENV ADMIN_PASS password
+# Copy over all files and scripts
+COPY files /files
+COPY scripts /scripts
 
 # Distribution package installation
-COPY rpm_list /rpm_list
-RUN yum -y -q install https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm \
-    epel-release && yum clean all
-RUN yum -y -q install `cat /rpm_list` && yum clean all
+RUN yum -y -q install https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm epel-release \
+    && yum -y -q install `cat /files/rpm_list` \
+    && yum clean all
 
 # User configuration
-RUN useradd -m -G wheel -u 1000 -s /bin/bash $BUGZILLA_USER \
-    && passwd -u -f $BUGZILLA_USER \
+RUN useradd -m -G wheel -u 1000 -s /bin/bash $USER \
+    && passwd -u -f $USER \
     && echo "bugzilla:bugzilla" | chpasswd
 
-# sshd
-RUN mkdir -p /var/run/sshd \
-    && chmod -rx /var/run/sshd \
-    && ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' \
-    && ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' \
-    && ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' \
-    && sed -ri 's/#UseDNS yes/UseDNS no/'g /etc/ssh/sshd_config
-
 # Apache configuration
-COPY bugzilla.conf /etc/httpd/conf.d/bugzilla.conf
+RUN cp /files/bugzilla.conf /etc/httpd/conf.d/bugzilla.conf
 
 # MySQL configuration
-COPY my.cnf /etc/my.cnf
-RUN chmod 644 /etc/my.cnf \
+RUN cp /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=$BUGZILLA_USER --basedir=/usr --datadir=/var/lib/mysql
+    && /usr/bin/mysql_install_db --user=$USER --basedir=/usr --datadir=/var/lib/mysql
 
 # Sudoer configuration
-COPY sudoers /etc/sudoers
-RUN chown root.root /etc/sudoers && chmod 440 /etc/sudoers
+RUN cp /files/sudoers /etc/sudoers \
+    && chown root.root /etc/sudoers \
+    && chmod 440 /etc/sudoers
 
 # Clone the code repo
 RUN su $BUGZILLA_USER -c "git clone $GITHUB_BASE_GIT -b $GITHUB_BASE_BRANCH $BUGZILLA_ROOT"
 
-# Copy setup and test scripts
-COPY *.sh buildbot_step generate_bmo_data.pl checksetup_answers.txt /
-RUN chmod 755 /*.sh /buildbot_step
-
 # Bugzilla dependencies and setup
-RUN /install_deps.sh
-RUN /bugzilla_config.sh
-RUN /my_config.sh
-
-# Final permissions fix
-RUN chown -R $BUGZILLA_USER.$BUGZILLA_USER $BUGZILLA_HOME
+RUN chmod a+x /scripts/*
+RUN /scripts/install_deps.sh
+RUN /scripts/bugzilla_config.sh
+RUN /scripts/my_config.sh
+RUN chown -R $USER.$USER $HOME
 
 # Networking
 RUN echo "NETWORKING=yes" > /etc/sysconfig/network
@@ -78,6 +58,6 @@ EXPOSE 5900
 ADD https://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar /selenium-server.jar
 
 # Supervisor
-COPY supervisord.conf /etc/supervisord.conf
+RUN cp /files/supervisord.conf /etc/supervisord.conf
 RUN chmod 700 /etc/supervisord.conf
 CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
old mode 100644 (file)
new mode 100755 (executable)
similarity index 60%
rename from docker/fig.yml
rename to docker/docker-compose.yml
index b4e9ed1..e6e9ac8
@@ -2,5 +2,6 @@ bugzilla:
   build: .
   ports:
     - "8080:80"
-    - "2222:22"
     - "5900:5900"
+  environment:
+    - "TEST_SUITE=sanity"
similarity index 93%
rename from docker/bugzilla.conf
rename to docker/files/bugzilla.conf
index 1b2b3f2e090dfd809d00f94ec31613dbdec624c7..857f79d17cdcb8bd436f902c2c574f64e90e9a1e 100644 (file)
@@ -1,9 +1,12 @@
 User bugzilla
 Group bugzilla
 ServerName localhost:80
+
 #PerlSwitches -wT
 #PerlConfigRequire /home/bugzilla/devel/htdocs/bmo/mod_perl.pl
+
 <VirtualHost *:80>
+    #AddHandler perl-script .cgi
     AddHandler cgi-script .cgi
     ServerName localhost
     DocumentRoot "/home/bugzilla/devel/htdocs"
similarity index 85%
rename from docker/checksetup_answers.txt
rename to docker/files/checksetup_answers.txt
index bda62f8833e1277acf3df4959c03e8690c52ca8f..0ab75aac9051a8bc26735d4b026385178b8a1dc8 100644 (file)
@@ -1,7 +1,7 @@
-$answer{'ADMIN_EMAIL'} = 'admin@mozilla.bugs';
+$answer{'ADMIN_EMAIL'} = 'admin@mozilla.test';
 $answer{'ADMIN_OK'} = 'Y';
 $answer{'ADMIN_PASSWORD'} = 'password';
-$answer{'ADMIN_REALNAME'} = 'Admin';
+$answer{'ADMIN_REALNAME'} = 'QA Admin';
 $answer{'NO_PAUSE'} = 1;
 $answer{'bugzilla_version'} = '4.2';
 $answer{'create_htaccess'} = '';
@@ -22,6 +22,6 @@ $answer{'diffpath'} = '/usr/bin';
 $answer{'index_html'} = 0;
 $answer{'interdiffbin'} = '/usr/bin/interdiff';
 $answer{'memcached_servers'} = "localhost:11211";
-$answer{'urlbase'} = 'http://localhost:8080/bmo/';
+$answer{'urlbase'} = 'http://localhost/bmo/';
 $answer{'use_suexec'} = '';
 $answer{'webservergroup'} = 'bugzilla';
similarity index 100%
rename from docker/my.cnf
rename to docker/files/my.cnf
diff --git a/docker/files/rpm_list b/docker/files/rpm_list
new file mode 100644 (file)
index 0000000..3b15596
--- /dev/null
@@ -0,0 +1,34 @@
+ImageMagick-perl
+bzip2
+ctags
+dbus-x11
+firefox
+gcc
+gcc-c++
+git
+graphviz
+java-1.7.0-openjdk
+make
+memcached
+mod_perl
+mod_perl-devel
+mpfr-devel
+mysql-community-server
+openssl-devel
+passwd
+patch
+patchutils
+perl-App-cpanminus
+perl-CPAN
+perl-DBD-MySQL
+perl-GD
+perl-GSSAPI
+perl-core
+postfix
+python-sphinx
+sudo
+supervisor
+tigervnc-server-minimal
+unzip
+vim-enhanced
+wget
similarity index 100%
rename from docker/sudoers
rename to docker/files/sudoers
similarity index 92%
rename from docker/supervisord.conf
rename to docker/files/supervisord.conf
index b3007daf36a48af5223f329ee5172638b1b7e125..4a3d49fcd0d9454b40a47644d9dc71218cb953e3 100644 (file)
@@ -8,9 +8,6 @@ pidfile=/var/run/supervisord.pid
 minfds=1024
 minprocs=200
 
-[program:sshd]
-command=/usr/sbin/sshd -D
-
 [program:httpd]
 command=/usr/sbin/httpd -DFOREGROUND
 
diff --git a/docker/rpm_list b/docker/rpm_list
deleted file mode 100644 (file)
index 4a9a29e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-ImageMagick-devel
-asciidoc
-aspell-devel
-bzip2
-dblatex
-dbus-x11
-docbook-style-dsssl
-firefox
-gcc
-gcc-c++
-gd-devel
-git
-gmp-devel
-graphviz
-jade
-java-1.7.0-openjdk
-lynx
-make
-memcached
-mod_perl
-mod_perl-devel
-mpfr-devel
-mysql-community-devel
-mysql-community-server
-openssh
-openssh-server
-openssl-devel
-passwd
-patch
-perl-App-cpanminus
-perl-CPAN
-perl-core
-postfix
-python-sphinx
-sudo
-supervisor
-tar
-texlive-cmap
-texlive-cyrillic
-texlive-framed
-texlive-mdwtools
-texlive-parskip
-texlive-tex4ht
-texlive-threeparttable
-texlive-ucs
-texlive-wrapfig
-tigervnc-server-minimal
-unzip
-vim-enhanced
-wget
-xmlto
similarity index 55%
rename from docker/bugzilla_config.sh
rename to docker/scripts/bugzilla_config.sh
index 818e34c635cccf057a24ecc808f97c1f750b9b34..d1ca0db0e97a50cb8addadf39cdc1cfe69e724b1 100755 (executable)
@@ -2,14 +2,16 @@
 
 cd $BUGZILLA_ROOT
 
-# Configure database
+# Start and initialize 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 /checksetup_answers.txt
-perl checksetup.pl /checksetup_answers.txt
-perl /generate_bmo_data.pl
+# Setup default Bugzilla database
+perl checksetup.pl /files/checksetup_answers.txt
+perl checksetup.pl /files/checksetup_answers.txt
+perl /scripts/generate_bmo_data.pl
 
+# Shutdown database
 mysqladmin -u root shutdown
similarity index 97%
rename from docker/generate_bmo_data.pl
rename to docker/scripts/generate_bmo_data.pl
index 90294c08040f9470f33cca9d93fd1e44e24a0d0c..178d8353e662a39f70d702c43946d08598280145 100755 (executable)
@@ -27,7 +27,7 @@ my $dbh = Bugzilla->dbh;
 # set Bugzilla usage mode to USAGE_MODE_CMDLINE
 Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
 
-Bugzilla->set_user(Bugzilla::User->new({ name => 'admin@mozilla.bugs' }));
+Bugzilla->set_user(Bugzilla::User->new({ name => 'admin@mozilla.test' }));
 
 ##########################################################################
 #  Set Default User Preferences
@@ -325,27 +325,6 @@ for my $product (@products) {
 # Create Groups
 ##########################################################################
 my @groups = (
-    {
-        name         => 'core-security',
-        description  => 'Security-Sensitive Core Bug',
-        no_admin     => 1,
-        bug_group    => 1,
-        all_products => 1,
-    },
-    {
-        name         => 'core-security-release',
-        description  => 'Release-track Client Security Bug',
-        no_admin     => 1,
-        bug_group    => 1,
-        all_products => 1,
-    },
-    {
-        name         => 'core-security-release',
-        description  => 'Release-track Client Security Bug',
-        no_admin     => 1,
-        bug_group    => 1,
-        all_products => 1,
-    },
     {
         name         => 'core-security-release',
         description  => 'Release-track Client Security Bug',
similarity index 67%
rename from docker/install_deps.sh
rename to docker/scripts/install_deps.sh
index a27344b086da7856b1675bd2c59edd09fa03964b..232bfea10e293033547b66ffd61e045766df3777 100755 (executable)
@@ -5,20 +5,11 @@ cd $BUGZILLA_ROOT
 # Install Perl dependencies
 CPANM="cpanm --quiet --notest --skip-satisfied"
 
-# Force version due to problem with CentOS ImageMagick-devel
-$CPANM Image::Magick@6.77
-
 perl checksetup.pl --cpanfile
 $CPANM --installdeps --with-recommends --with-all-features \
     --without-feature oracle --without-feature sqlite --without-feature pg .
 
 # These are not picked up by cpanm --with-all-features for some reason
-$CPANM Template::Plugin::GD::Image
-$CPANM MIME::Parser
-$CPANM SOAP::Lite
-$CPANM JSON::RPC
-$CPANM Email::MIME::Attachment::Stripper
-$CPANM TheSchwartz
 $CPANM XMLRPC::Lite
 
 # For testing support
@@ -26,6 +17,8 @@ $CPANM File::Copy::Recursive
 $CPANM Test::WWW::Selenium
 $CPANM Pod::Coverage
 $CPANM Pod::Checker
+$CPANM Test::LWP::UserAgent
+$CPANM Test::MockObject
 
 # Remove CPAN build files to minimize disk usage
-rm -rf /root/.cpanm
+rm -rf ~/.cpanm
similarity index 68%
rename from docker/runtests.sh
rename to docker/scripts/runtests.sh
index f554b9b6b252b13d3f5d1dcd7e381a62c32d4583..a2b5773b8fce0cd069e26265eb3ca5436edad8ad 100755 (executable)
@@ -3,6 +3,8 @@
 # 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/.
 
+BUILDBOT=$BUGZILLA_ROOT/docker/scripts/buildbot_step
+
 if [ -z "$TEST_SUITE" ]; then
     TEST_SUITE=sanity
 fi
@@ -23,11 +25,10 @@ if [ "$GITHUB_BASE_REV" != "" ]; then
 fi
 
 echo -e "\n== Checking dependencies for changes"
-/install_deps.sh
+$BUGZILLA_ROOT/docker/scripts/install_deps.sh
 
 if [ "$TEST_SUITE" = "sanity" ]; then
-    cd $BUGZILLA_ROOT
-    /buildbot_step "Sanity" prove -f -v t/*.t
+    $BUILDBOT "Sanity" prove -f -v t/*.t
     exit $?
 fi
 
@@ -35,38 +36,25 @@ if [ "$TEST_SUITE" = "docs" ]; then
     export JADE_PUB=/usr/share/sgml
     export LDP_HOME=/usr/share/sgml/docbook/dsssl-stylesheets-1.79/dtds/decls
     cd $BUGZILLA_ROOT/docs
-    /buildbot_step "Documentation" perl makedocs.pl --with-pdf
+    $BUILDBOT "Documentation" perl makedocs.pl --with-pdf
     exit $?
 fi
 
 echo -e "\n== Starting database"
 /usr/bin/mysqld_safe &
 sleep 3
+mysql -u root mysql -e "CREATE DATABASE bugs_test CHARACTER SET = 'utf8';"
 
 echo -e "\n== Starting memcached"
 /usr/bin/memcached -u memcached -d
 sleep 3
 
-echo -e "\n== Updating configuration"
-mysql -u root mysql -e "CREATE DATABASE bugs_test CHARACTER SET = 'utf8';"
-sed -e "s?%DB%?$BUGS_DB_DRIVER?g" --in-place $BUGZILLA_ROOT/qa/config/checksetup_answers.txt
-sed -e "s?%DB_NAME%?bugs_test?g" --in-place $BUGZILLA_ROOT/qa/config/checksetup_answers.txt
-sed -e "s?%USER%?$BUGZILLA_USER?g" --in-place $BUGZILLA_ROOT/qa/config/checksetup_answers.txt
-echo "\$answer{'memcached_servers'} = 'localhost:11211';" >> $BUGZILLA_ROOT/qa/config/checksetup_answers.txt
-
-if [ "$TEST_SUITE" == "checksetup" ]; then
-    cd $BUGZILLA_ROOT/qa
-    /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
+perl checksetup.pl $BUGZILLA_ROOT/qa/config/checksetup_answers.txt
+perl checksetup.pl $BUGZILLA_ROOT/qa/config/checksetup_answers.txt
 
 echo -e "\n== Generating bmo data"
-perl /generate_bmo_data.pl
+perl $BUGZILLA_ROOT/docker/scripts/generate_bmo_data.pl
 
 echo -e "\n== Generating test data"
 cd $BUGZILLA_ROOT/qa/config
@@ -97,12 +85,12 @@ if [ "$TEST_SUITE" = "selenium" ]; then
     [ $NO_TESTS ] && exit 0
 
     cd $BUGZILLA_ROOT/qa/t
-    /buildbot_step "Selenium" prove -f -v -I$BUGZILLA_ROOT/lib test_*.t
+    $BUILDBOT "Selenium" prove -f -v -I$BUGZILLA_ROOT/lib test_*.t
     exit $?
 fi
 
 if [ "$TEST_SUITE" = "webservices" ]; then
     cd $BUGZILLA_ROOT/qa/t
-    /buildbot_step "Webservices" prove -f -v -I$BUGZILLA_ROOT/lib webservice_*.t
+    $BUILDBOT "Webservices" prove -f -v -I$BUGZILLA_ROOT/lib webservice_*.t
     exit $?
 fi
diff --git a/docker/scripts/start.sh b/docker/scripts/start.sh
new file mode 100755 (executable)
index 0000000..0778701
--- /dev/null
@@ -0,0 +1,8 @@
+docker run -d \
+    --name dkl_bugzilla_1 \
+    --hostname dkl_bugzilla_1 \
+    --publish 80:80 \
+    --publish 2222:22 \
+    --volume /home/dkl/devel:/home/bugzilla/devel \
+    --volume /home/dkl/data/bzdev/mysql:/var/lib/mysql \
+    dkl_bugzilla