Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1886352: docker config for testing PostgreSQL #114

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions Bugzilla/DaemonControl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use strict;
use warnings;

use Bugzilla::Logging;
use Bugzilla::Constants qw(bz_locations);
use Bugzilla::Constants qw(bz_locations DB_MODULE);
use Cwd qw(realpath);
use English qw(-no_match_vars $PROGRAM_NAME);
use File::Spec::Functions qw(catfile catdir);
Expand Down Expand Up @@ -226,24 +226,27 @@ sub assert_database {
my $loop = IO::Async::Loop->new;
my $lc = Bugzilla::Install::Localconfig::read_localconfig();

for my $var (qw(db_name db_host db_user db_pass)) {
for my $var (qw(db_driver db_name db_host db_user db_pass)) {
return $loop->new_future->die("$var is not set!") unless $lc->{$var};
}
my ($db_driver) = (DB_MODULE->{$lc->{db_driver}}->{dbd}->{module} =~ m/::([^:]+)$/);

my $dsn = "dbi:mysql:database=$lc->{db_name};host=$lc->{db_host}";
my $dsn = "dbi:$db_driver:database=$lc->{db_name};host=$lc->{db_host}";
my $repeat = try_repeat_until_success {
$loop->delay_future(after => 0.25)->then(sub {
my $attrs = {RaiseError => 1, PrintError => 1};
my ($ssl_ca_file, $ssl_ca_path, $ssl_cert, $ssl_key, $ssl_pubkey) =
@$lc{qw(db_mysql_ssl_ca_file db_mysql_ssl_ca_path
db_mysql_ssl_client_cert db_mysql_ssl_client_key db_mysql_ssl_get_pubkey)};
if ($ssl_ca_file || $ssl_ca_path || $ssl_cert || $ssl_key || $ssl_pubkey) {
$attrs->{'mysql_ssl'} = 1;
$attrs->{'mysql_ssl_ca_file'} = $ssl_ca_file if $ssl_ca_file;
$attrs->{'mysql_ssl_ca_path'} = $ssl_ca_path if $ssl_ca_path;
$attrs->{'mysql_ssl_client_cert'} = $ssl_cert if $ssl_cert;
$attrs->{'mysql_ssl_client_key'} = $ssl_key if $ssl_key;
$attrs->{'mysql_get_server_pubkey'} = $ssl_pubkey if $ssl_pubkey;
if ($lc->{db_driver} eq 'mysql') {
my ($ssl_ca_file, $ssl_ca_path, $ssl_cert, $ssl_key, $ssl_pubkey) =
@$lc{qw(db_mysql_ssl_ca_file db_mysql_ssl_ca_path
db_mysql_ssl_client_cert db_mysql_ssl_client_key db_mysql_ssl_get_pubkey)};
if ($ssl_ca_file || $ssl_ca_path || $ssl_cert || $ssl_key || $ssl_pubkey) {
$attrs->{'mysql_ssl'} = 1;
$attrs->{'mysql_ssl_ca_file'} = $ssl_ca_file if $ssl_ca_file;
$attrs->{'mysql_ssl_ca_path'} = $ssl_ca_path if $ssl_ca_path;
$attrs->{'mysql_ssl_client_cert'} = $ssl_cert if $ssl_cert;
$attrs->{'mysql_ssl_client_key'} = $ssl_key if $ssl_key;
$attrs->{'mysql_get_server_pubkey'} = $ssl_pubkey if $ssl_pubkey;
}
}
my $dbh;
eval {
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM bugzilla/bugzilla-perl-slim:20240316.1
FROM bugzilla/bugzilla-perl-slim:20240320.1

ENV DEBIAN_FRONTEND noninteractive

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.bmo-slim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-
&& gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-8.0.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B7B3B788A8D3785C \
&& echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/mysql-8.0.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-8.0' > /etc/apt/sources.list.d/mysql-8.0.list
RUN apt-get update \
&& apt-get install -y libmysqlclient-dev
&& apt-get install -y libmysqlclient-dev libpq-dev

RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot

Expand Down Expand Up @@ -64,6 +64,7 @@ RUN apt-get update \
graphviz \
libcap2-bin \
libmysqlclient21 \
postgresql-client \
rsync \
$(cat /app/PACKAGES) \
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-
&& gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-8.0.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B7B3B788A8D3785C \
&& echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/mysql-8.0.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-8.0' > /etc/apt/sources.list.d/mysql-8.0.list
RUN apt-get update \
&& apt-get install -y libmysqlclient-dev
&& apt-get install -y libmysqlclient-dev libpq-dev

RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot

Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ WriteMakefile(

sub MY::postamble {
return <<"MAKE";
GEN_CPANFILE_ARGS = -D better_xff -D mysql -D jsonrpc -D xmlrpc -D documentation
GEN_CPANFILE_ARGS = -D better_xff -D mysql -D jsonrpc -D xmlrpc -D documentation -D pg
cpanfile: MYMETA.json
\t\$(PERLRUN) gen-cpanfile.pl \$(GEN_CPANFILE_ARGS)

Expand Down
69 changes: 69 additions & 0 deletions docker-compose.test-pg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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:
bmo.test:
build: &bmo_build
context: .
dockerfile: Dockerfile
command: dev_httpd
tmpfs:
- /tmp
- /run
environment:
- 'BMO_inbound_proxies=*'
- BMO_db_driver=pg
- BMO_db_host=bmo.db
- BMO_db_name=bugs
- BMO_db_pass=bugs
- BMO_db_user=bugs
- BMO_memcached_namespace=bugzilla
- BMO_memcached_servers=memcached:11211
- [email protected]
- BMO_ses_password=password123456789!
- BMO_urlbase=AUTOMATIC
- BUGZILLA_ALLOW_INSECURE_HTTP=1
- BZ_ANSWERS_FILE=/app/conf/checksetup_answers.txt
- BZ_QA_ANSWERS_FILE=/app/.circleci/checksetup_answers.txt
- BZ_QA_CONF_FILE=/app/.circleci/selenium_test.conf
- BZ_QA_CONFIG=1
- CI=${CI}
- CIRCLE_SHA1=${CIRCLE_SHA1}
- CIRCLE_BUILD_URL=${CIRCLE_BUILD_URL}
- LOCALCONFIG_ENV=1
- LOG4PERL_CONFIG_FILE=log4perl-test.conf
- LOGGING_PORT=5880
- PORT=8000
- TWD_BROWSER=firefox
- TWD_HOST=selenium
- TWD_PORT=4444
depends_on:
- bmo.db
- memcached
- selenium

bmo.db:
image: postgres:9.0
tmpfs:
- /tmp
logging:
driver: "none"
environment:
- POSTGRES_DB=bugs
- POSTGRES_USER=bugs
- POSTGRES_PASSWORD=bugs

memcached:
image: memcached:latest

selenium:
image: selenium/standalone-firefox:3.141.59
shm_size: '512m'
ports:
- "5900:5900"

volumes:
bmo-pg-db:
Loading