]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
[5.2] Bug 1888068: Run development copy in Docker (#105)
authorDave Miller <justdave@bugzilla.org>
Sat, 30 Mar 2024 06:19:54 +0000 (02:19 -0400)
committerGitHub <noreply@github.com>
Sat, 30 Mar 2024 06:19:54 +0000 (02:19 -0400)
Dockerfile [new file with mode: 0644]
Dockerfile.mariadb [new file with mode: 0644]
README
docker-compose.yml [new file with mode: 0644]
docker/000-default.conf [new file with mode: 0644]
docker/checksetup_answers.txt [new file with mode: 0644]
docker/my.cnf [new file with mode: 0644]
docker/mysql/bugzilla.cnf [new file with mode: 0644]
docker/startup.sh [new file with mode: 0755]

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..ad8d627
--- /dev/null
@@ -0,0 +1,69 @@
+FROM ubuntu:22.04
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get update && apt-get -y dist-upgrade
+RUN apt-get -y install \
+ apache2 \
+ mariadb-client \
+ netcat-traditional \
+ libappconfig-perl \
+ libdate-calc-perl \
+ libtemplate-perl \
+ build-essential \
+ libdatetime-timezone-perl \
+ libdatetime-perl \
+ libemail-address-perl \
+ libemail-sender-perl \
+ libemail-mime-perl \
+ libemail-mime-modifier-perl \
+ libdbi-perl \
+ libdbix-connector-perl \
+ libdbd-mysql-perl \
+ libcgi-pm-perl \
+ liblocale-codes-perl \
+ libmath-random-isaac-perl \
+ libmath-random-isaac-xs-perl \
+ libapache2-mod-perl2 \
+ libapache2-mod-perl2-dev \
+ libchart-perl \
+ libxml-perl \
+ libxml-twig-perl \
+ perlmagick \
+ libgd-graph-perl \
+ libtemplate-plugin-gd-perl \
+ libsoap-lite-perl \
+ libhtml-scrubber-perl \
+ libjson-rpc-perl \
+ libdaemon-generic-perl \
+ libtheschwartz-perl \
+ libtest-taint-perl \
+ libauthen-radius-perl \
+ libfile-slurp-perl \
+ libencode-detect-perl \
+ libmodule-build-perl \
+ libnet-ldap-perl \
+ libauthen-sasl-perl \
+ libfile-mimeinfo-perl \
+ libhtml-formattext-withlinks-perl \
+ libgd-dev \
+ libmysqlclient-dev \
+ graphviz \
+ vim-common
+
+# Ubuntu22 doesn't ship a new enough Template::Toolkit, so install this one manually
+RUN cpan install Template::Toolkit
+
+WORKDIR /var/www/html
+COPY --chown=root:www-data . /var/www/html
+COPY ./docker/000-default.conf /etc/apache2/sites-available/000-default.conf
+COPY ./docker /root/docker
+
+# we don't want Docker droppings accessible by the web browser since they
+# might contain setup info you don't want public
+RUN rm -rf /var/www/html/docker* /var/www/html/Dockerfile*
+RUN rm -rf /var/www/html/data /var/www/html/localconfig /var/www/html/index.html && \
+    mkdir /var/www/html/data
+RUN a2enmod expires && a2enmod headers && a2enmod rewrite && a2dismod mpm_event && a2enmod mpm_prefork
+EXPOSE 80/tcp
+CMD docker/startup.sh
diff --git a/Dockerfile.mariadb b/Dockerfile.mariadb
new file mode 100644 (file)
index 0000000..68256ea
--- /dev/null
@@ -0,0 +1,4 @@
+FROM mariadb:10.5.12
+COPY docker/my.cnf /etc/my.cnf
+COPY docker/mysql /etc/mysql/conf.d
+RUN apt update && apt -y dist-upgrade
diff --git a/README b/README
index 335631e5df6746aac0a18ef9dfa9b32cd5e5bc37..b867a994d9b3571b6662e2433375d154d23d6804 100644 (file)
--- a/README
+++ b/README
@@ -13,6 +13,15 @@ Bugzilla's comprehensive documentation, including installation instructions,
 can be found here:
 http://www.bugzilla.org/docs/
 
+Docker Quick Start
+==================
+
+If you have Docker installed and just want to take a quick look around Bugzilla
+you can cd into the bugzilla directory (same directory containing this README)
+and type `docker compose up`. The URL to access and the username and password
+for the default admin account will be shown on the console once it finishes
+setting it up.
+
 Reporting Bugs
 ==============
 
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644 (file)
index 0000000..eb2e685
--- /dev/null
@@ -0,0 +1,49 @@
+# 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/.
+
+version: '3.6'
+
+services:
+  bugzilla5.web:
+    build:
+      context: .
+      dockerfile: Dockerfile
+    command: /root/docker/startup.sh
+    volumes:
+      - bugzilla5-data-dir:/var/www/html/data
+      - .:/mnt/sync
+    tmpfs:
+      - /tmp
+      - /run/lock
+    ports:
+      - 8080:80
+    depends_on:
+      - bugzilla5.db
+    environment: &bugzilla_env
+      - BZ_ADMIN_EMAIL=admin@bugzilla.test
+      - BZ_ADMIN_PASSWORD=password01!
+      - BZ_ADMIN_REALNAME=Test Admin
+      - BZ_URLBASE=http://127.0.0.1:8080/
+      - BZ_DB_HOST=bugzilla5.db
+      - BZ_DB_PORT=3306
+      - BZ_DB_USER=bugs
+      - BZ_DB_NAME=bugs
+      - BZ_DB_PASS=bugzilla
+      - MARIADB_ROOT_HOST=%
+      - MARIADB_ROOT_PASSWORD=bugzilla
+
+  bugzilla5.db:
+    build:
+      context: .
+      dockerfile: Dockerfile.mariadb
+    volumes:
+      - bugzilla5-mysql-db:/var/lib/mysql
+    tmpfs:
+      - /tmp
+      - /var/lock
+    environment: *bugzilla_env
+
+volumes:
+  bugzilla5-mysql-db:
+  bugzilla5-data-dir:
diff --git a/docker/000-default.conf b/docker/000-default.conf
new file mode 100644 (file)
index 0000000..8d4d592
--- /dev/null
@@ -0,0 +1,37 @@
+PerlSwitches -w -T
+ServerName localhost
+<VirtualHost *:80>
+       # The ServerName directive sets the request scheme, hostname and port that
+       # the server uses to identify itself. This is used when creating
+       # redirection URLs. In the context of virtual hosts, the ServerName
+       # specifies what hostname must appear in the request's Host: header to
+       # match this virtual host. For the default virtual host (this file) this
+       # value is not decisive as it is used as a last resort host regardless.
+       # However, you must set it for any further virtual host explicitly.
+ServerName 172.17.0.3
+
+       ServerAdmin webmaster@localhost
+       DocumentRoot /var/www/html
+
+       # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
+       # error, crit, alert, emerg.
+       # It is also possible to configure the loglevel for particular
+       # modules, e.g.
+       #LogLevel info ssl:warn
+
+       ErrorLog ${APACHE_LOG_DIR}/error.log
+       CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+       # For most configuration files from conf-available/, which are
+       # enabled or disabled at a global level, it is possible to
+       # include a line for only one particular virtual host. For example the
+       # following line enables the CGI configuration for this host only
+       # after it has been globally disabled with "a2disconf".
+       #Include conf-available/serve-cgi-bin.conf
+
+PerlSwitches -w -T
+PerlConfigRequire /var/www/html/mod_perl.pl
+
+</VirtualHost>
+
+# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
diff --git a/docker/checksetup_answers.txt b/docker/checksetup_answers.txt
new file mode 100644 (file)
index 0000000..8c28ddd
--- /dev/null
@@ -0,0 +1,39 @@
+$answer{'ADMIN_EMAIL'}          = %%BZ_ADMIN_EMAIL%%;
+$answer{'ADMIN_OK'}             = 'Y';
+$answer{'ADMIN_PASSWORD'}       = %%BZ_ADMIN_PASSWORD%%;
+$answer{'ADMIN_REALNAME'}       = %%BZ_ADMIN_REALNAME%%;
+$answer{'webservergroup'}       = 'www-data';
+$answer{'use_suexec'}           = '0';
+$answer{'db_driver'}            = 'mysql';
+$answer{'db_host'}              = %%BZ_DB_HOST%%;
+$answer{'db_port'}              = %%BZ_DB_PORT%%;
+$answer{'db_sock'}              = '';
+$answer{'db_name'}              = %%BZ_DB_NAME%%;
+$answer{'db_user'}              = %%BZ_DB_USER%%;
+$answer{'db_pass'}              = %%BZ_DB_PASS%%;
+$answer{'size_limit'}           = 750000;
+$answer{'bugzilla_version'}     = '1';
+$answer{'create_htaccess'}      = '1';
+$answer{'db_check'}             = 1;
+$answer{'diffpath'}             = '/usr/bin';
+$answer{'index_html'}           = 0;
+$answer{'interdiffbin'}         = '/usr/bin/interdiff';
+$answer{'user_info_class'}      = 'CGI';
+$answer{'user_verify_class'}    = 'DB';
+$answer{'use_mailer_queue'}     = 0;
+$answer{'useclassification'}    = 1;
+$answer{'usebugaliases'}        = 1;
+$answer{'upgrade_notification'} = 'disabled';
+$answer{'usestatuswhiteboard'}  = 1;
+$answer{'usetargetmilestone'}   = 1;
+$answer{'webdotbase'}           = '/usr/bin/dot';
+$answer{'insidergroup'}         = 'admin';
+$answer{'default_bug_type'}     = '--';
+$answer{'defaultpriority'}      = '--';
+$answer{'defaultseverity'}      = 'normal';
+$answer{'urlbase'}              = %%BZ_URLBASE%%;
+$answer{'docs_urlbase'}         = 'https://bugzilla.readthedocs.io/en/5.0/';
+$answer{'db_mysql_ssl_ca_file'}     = '';
+$answer{'db_mysql_ssl_ca_path'}     = '';
+$answer{'db_mysql_ssl_client_cert'} = '';
+$answer{'db_mysql_ssl_client_key'}  = '';
diff --git a/docker/my.cnf b/docker/my.cnf
new file mode 100644 (file)
index 0000000..1c8dab4
--- /dev/null
@@ -0,0 +1,31 @@
+[mysqld]
+#
+# Remove leading # and set to the amount of RAM for the most important data
+# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
+# innodb_buffer_pool_size = 128M
+#
+# Remove leading # to turn on a very important data integrity option: logging
+# changes to the binary log between backups.
+# log_bin
+#
+# Remove leading # to set options mainly useful for reporting servers.
+# The server defaults are faster for transactions and fast SELECTs.
+# Adjust sizes as needed, experiment to find the optimal values.
+# join_buffer_size = 128M
+# sort_buffer_size = 2M
+# read_rnd_buffer_size = 2M
+skip-host-cache
+skip-name-resolve
+datadir=/var/lib/mysql
+socket=/var/lib/mysql/mysql.sock
+secure-file-priv=/var/lib/mysql
+user=mysql
+wait-timeout=28800
+
+# Disabling symbolic-links is recommended to prevent assorted security risks
+symbolic-links=0
+
+log-error=/var/log/mysqld.log
+pid-file=/var/run/mysqld/mysqld.pid
+lower_case_table_names=1
+max_allowed_packet=1G
diff --git a/docker/mysql/bugzilla.cnf b/docker/mysql/bugzilla.cnf
new file mode 100644 (file)
index 0000000..670385b
--- /dev/null
@@ -0,0 +1,7 @@
+[mysqld]
+max_allowed_packet = 1G
+innodb_file_per_table = 1
+innodb_large_prefix   = 1
+
+[mysql]
+max_allowed_packet = 1G
diff --git a/docker/startup.sh b/docker/startup.sh
new file mode 100755 (executable)
index 0000000..2056138
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+[ -z "$BZ_DB_HOST" ] && echo "Missing Docker Environment, check docker-compose.yml" && exit -1
+cd /var/www/html
+apachectl start
+while :
+do
+  echo "Waiting for database to be available..."
+  nc -z $BZ_DB_HOST $BZ_DB_PORT
+  [ $? -eq 0 ] && break
+  sleep 2
+done
+echo "Checking database..."
+cat - >/root/docker/myclient-root.cnf <<EOF
+[client]
+host='$BZ_DB_HOST'
+port=$BZ_DB_PORT
+user='root'
+password='$MARIADB_ROOT_PASSWORD'
+EOF
+TESTSQL="show databases like '$BZ_DB_NAME'"
+DBEXISTS=`echo "$TESTSQL" | mysql --defaults-file=/root/docker/myclient-root.cnf -BN`
+[ -z "$DBEXISTS" ] && (
+  echo "Database not found, creating..."
+  CREATESQL="
+CREATE DATABASE \`$BZ_DB_NAME\`;
+GRANT SELECT, INSERT,
+UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,
+CREATE TEMPORARY TABLES, DROP, REFERENCES ON \`$BZ_DB_NAME\`.*
+TO '$BZ_DB_USER'@'%' IDENTIFIED BY '$BZ_DB_PASS';
+FLUSH PRIVILEGES;
+"
+  echo "$CREATESQL" | mysql --defaults-file=/root/docker/myclient-root.cnf -BN
+)
+echo "Beginning checksetup..."
+perl -pi -e "
+s/%%BZ_ADMIN_EMAIL%%/'${BZ_ADMIN_EMAIL//@/\\@}'/;
+s/%%BZ_ADMIN_PASSWORD%%/'${BZ_ADMIN_PASSWORD//@/\\@//$/\\$}'/;
+s/%%BZ_ADMIN_REALNAME%%/'${BZ_ADMIN_REALNAME//@/\\@//$/\\$}'/;
+s/%%BZ_DB_HOST%%/'$BZ_DB_HOST'/;
+s/%%BZ_DB_PORT%%/$BZ_DB_PORT/;
+s/%%BZ_DB_NAME%%/'$BZ_DB_NAME'/;
+s/%%BZ_DB_USER%%/'$BZ_DB_USER'/;
+s/%%BZ_DB_PASS%%/'${BZ_DB_PASS//@/\\@//$/\\$}'/;
+s@%%BZ_URLBASE%%@'${BZ_URLBASE//@/\\@}'@;
+" /root/docker/checksetup_answers.txt
+perl checksetup.pl /root/docker/checksetup_answers.txt
+echo "Checksetup completed."
+
+LOGIN_USER="Admin user: $BZ_ADMIN_EMAIL"
+LOGIN_PASS="Admin password: $BZ_ADMIN_PASSWORD"
+cat - <<EOF
+#########################################
+##                                     ##
+##  Your Bugzilla installation should  ##
+##         now be reachable at:        ##
+##                                     ##
+EOF
+printf "##%*s%*s##\n" $(( (${#BZ_URLBASE} + 37) / 2)) $BZ_URLBASE $(( 37 - ((${#BZ_URLBASE} + 37) / 2)  )) " "
+cat - <<EOF
+##                                     ##
+EOF
+printf "##%*s%*s##\n" $(( (${#LOGIN_USER} + 37) / 2)) "$LOGIN_USER" $(( 37 - ((${#LOGIN_USER} + 37) / 2)  )) " "
+printf "##%*s%*s##\n" $(( (${#LOGIN_PASS} + 37) / 2)) "$LOGIN_PASS" $(( 37 - ((${#LOGIN_PASS} + 37) / 2)  )) " "
+cat - <<EOF
+##                                     ##
+##   user/password only valid if you   ##
+##    haven't already changed them.    ##
+##                                     ##
+#########################################
+EOF
+# don't exit docker
+while [ 1 ]; do sleep 1000; done