Page MenuHomeDevCentral

D1852.id4674.diff
No OneTemporary

D1852.id4674.diff

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,36 @@
+FROM fedora:28
+MAINTAINER Sébastien Santoro aka Dereckson <dereckson+nasqueron-docker@espace-win.org>
+
+RUN dnf -y install mod_perl git sudo perl-App-cpanminus perl-CPAN \
+ gcc gcc-c++ make vim-enhanced perl-Software-License gd-devel \
+ openssl-devel ImageMagick-devel graphviz patch && \
+ perl-GD perl-GDGraph perl-GDTextUtil && \
+ dnf -y install https://dev.mysql.com/get/mysql-community-client-8.0.12-1.fc28.x86_64.rpm \
+ https://dev.mysql.com/get/mysql-community-libs-8.0.12-1.fc28.x86_64.rpm \
+ https://dev.mysql.com/get/mysql-community-devel-8.0.12-1.fc28.x86_64.rpm \
+ https://dev.mysql.com/get/mysql-community-common-8.0.12-1.fc28.x86_64.rpm && \
+ dnf -y update && \
+ dnf clean all
+
+RUN useradd -m -G wheel -u 1000 -s /bin/bash bugzilla && \
+ cpanm --quiet --notest --skip-installed DateTime && \
+ cpanm --quiet --notest --skip-installed Module::Build && \
+ cpanm --quiet --notest --skip-installed Software::License && \
+ cpanm --quiet --notest --skip-installed Pod::Coverage && \
+ cpanm --quiet --notest --skip-installed Cache::Memcached::GetParserXS && \
+ cpanm --quiet --notest --skip-installed XMLRPC::Lite && \
+ cpanm --quiet --notest --skip-installed DBD::mysql && \
+ cpanm --quiet --notest --skip-installed Memoize && \
+ cpanm --quiet --notest --skip-installed HTML::FormatText::WithLinks && \
+ cpanm --quiet --notest --skip-installed Chart::Lines && \
+ cpanm --quiet --notest --skip-installed Template::Plugin::GD::Image && \
+ git clone -b 5.0 https://github.com/bugzilla/bugzilla.git /opt/bugzilla && \
+ cd /opt/bugzilla && cpanm --quiet --notest --skip-installed --installdeps --with-recommends . && \
+ chown -R bugzilla:bugzilla /opt/bugzilla && \
+ rm /etc/httpd/conf.d/welcome.conf
+
+COPY files /
+
+EXPOSE 80
+
+CMD ["/usr/local/sbin/init-container"]
diff --git a/README.md b/README.md
new file mode 100644
--- /dev/null
+++ b/README.md
@@ -0,0 +1,16 @@
+## Bugzilla Docker image
+
+Provide a Bugzilla stable version, with CPAN modules.
+
+### Usage
+
+To start a container linked against a MySQL container:
+
+```bash
+$ docker run -dt -p 8080:80 --link mysql:somemysqlcontainer \
+ -e DB_HOST=mysql -e DB_USER=bugs -e DB_PASSWORD=bugs \
+ -e BUGZILLA_URL=https://bugzilla.domain.tld
+ nasqueron/bugzilla
+```
+
+To use networks, replace the `--link` option by a network configuration.
diff --git a/files/etc/httpd/conf.d/bugzilla.conf b/files/etc/httpd/conf.d/bugzilla.conf
new file mode 100644
--- /dev/null
+++ b/files/etc/httpd/conf.d/bugzilla.conf
@@ -0,0 +1,26 @@
+# -------------------------------------------------------------
+# Bugzilla - General Apache configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+User bugzilla
+Group bugzilla
+
+ServerName localhost:80
+
+PerlSwitches -w -T
+PerlConfigRequire /opt/bugzilla/mod_perl.pl
+
+<VirtualHost *:80>
+ ServerName localhost
+ DocumentRoot "/opt/bugzilla"
+
+ AddHandler cgi-script .cgi
+
+ <Directory "/opt/bugzilla">
+ DirectoryIndex index.cgi
+
+ Options Indexes FollowSymLinks MultiViews ExecCGI
+ AllowOverride All
+ Require all granted
+ </Directory>
+</VirtualHost>
diff --git a/files/etc/httpd/conf.modules.d/00-mpm.conf b/files/etc/httpd/conf.modules.d/00-mpm.conf
new file mode 100644
--- /dev/null
+++ b/files/etc/httpd/conf.modules.d/00-mpm.conf
@@ -0,0 +1,6 @@
+# -------------------------------------------------------------
+# Bugzilla - Apache MPM configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+# Apache2::SizeLimit requires a non-threaded MPM.
+LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
diff --git a/files/usr/local/bin/setup-bugzilla b/files/usr/local/bin/setup-bugzilla
new file mode 100755
--- /dev/null
+++ b/files/usr/local/bin/setup-bugzilla
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+pushd /opt/bugzilla
+perl checksetup.pl /usr/local/lib/bugzilla/provide_configuration.pl
+popd
+
+touch .initialized
diff --git a/files/usr/local/lib/bugzilla/provide_configuration.pl b/files/usr/local/lib/bugzilla/provide_configuration.pl
new file mode 100755
--- /dev/null
+++ b/files/usr/local/lib/bugzilla/provide_configuration.pl
@@ -0,0 +1,103 @@
+#!/usr/bin/env perl
+
+# -------------------------------------------------------------
+# Bugzilla - provide configuration from environment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2018-10-05
+# License: Trivial work, not eligible to copyright
+# Description: To wrap Bugzilla into a 12-factor app or to
+# package it as a Docker container, extract the
+# configuration from the environment to provide
+# to the checksetup.pl script.
+# -------------------------------------------------------------
+
+use feature 'say';
+use strict;
+use warnings;
+
+# -------------------------------------------------------------
+# Check environment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+my @mandatory_variables = ("DB_HOST", "DB_USER", "DB_PASSWORD", "DB_DATABASE", "BUGZILLA_URL");
+
+my $isEnviromentValid = 1;
+foreach my $key (@mandatory_variables) {
+ if (!exists $ENV{$key}) {
+ say STDERR "Key missing: ", $key;
+ $isEnviromentValid = 0;
+ }
+}
+
+if ($isEnviromentValid eq 0) {
+ exit 1;
+}
+
+# -------------------------------------------------------------
+# Helper methods
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+sub generate_random_password {
+ my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
+ return join '', map $alphanumeric[rand @alphanumeric], 0..16;
+}
+
+# -------------------------------------------------------------
+# Provide configuration hints
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+my %answer = ();
+$answer{'db_host'} = $ENV{"DB_HOST"};
+$answer{'db_driver'} = 'mysql';
+$answer{'db_port'} = 3306;
+$answer{'db_name'} = $ENV{"DB_DATABASE"};
+$answer{'db_user'} = $ENV{"DB_USER"};
+$answer{'db_pass'} = $ENV{"DB_PASSWORD"};
+$answer{'db_sock'} = '';
+$answer{'db_check'} = 1;
+
+$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{'urlbase'} = $ENV{"BUGZILLA_URL"};
+$answer{'create_htaccess'} = '';
+$answer{'use_suexec'} = '';
+$answer{'index_html'} = 0;
+
+$answer{'cvsbin'} = '/usr/bin/cvs';
+$answer{'interdiffbin'} = '/usr/bin/interdiff';
+$answer{'diffpath'} = '/usr/bin';
+
+$answer{'webservergroup'} = 'bugzilla';
+
+$answer{'ADMIN_OK'} = 'Y';
+$answer{'ADMIN_EMAIL'} = $ENV{"ADMIN_EMAIL"} || 'admin@domain.tld';
+$answer{'ADMIN_PASSWORD'} = $ENV{"ADMIN_PASSWORD"} || generate_random_password();
+$answer{'ADMIN_REALNAME'} = $ENV{"ADMIN_REALNAME"} ||'Admin';
+
+my $logAdminPassword = 0;
+if (exists $ENV{"ADMIN_PASSWORD"}) {
+ $answer{'ADMIN_PASSWORD'} = $ENV{"ADMIN_PASSWORD"};
+} else {
+ $answer{'ADMIN_PASSWORD'} = generate_random_password();
+ $logAdminPassword = 1;
+}
+
+$answer{'NO_PAUSE'} = 1;
+
+# -------------------------------------------------------------
+# Report extra information when needed
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if ($logAdminPassword) {
+ say STDERR "";
+ say STDERR "\e[31mAdministrator account has not been provided in the configuration.";
+ say STDERR "If no admin account is already defined in your database, this one will be created:";
+ say STDERR "";
+ say STDERR "\tE-mail ..... ", $answer{"ADMIN_EMAIL"};
+ say STDERR "\tPassword ... ", $answer{'ADMIN_PASSWORD'};
+ say STDERR "\e[0m";
+}
diff --git a/files/usr/local/sbin/init-container b/files/usr/local/sbin/init-container
new file mode 100755
--- /dev/null
+++ b/files/usr/local/sbin/init-container
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ ! -f .initialized ]; then
+ # Container is initialized according the environment variables
+ # passed to the container to setup Phabricator.
+ /usr/local/bin/setup-bugzilla
+fi
+
+/usr/sbin/httpd -DFOREGROUND

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 11:55 (20 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262458
Default Alt Text
D1852.id4674.diff (8 KB)

Event Timeline