Skip to content

Commit

Permalink
(no bug) remove database drivers from "slim" Docker image (#124)
Browse files Browse the repository at this point in the history
Adds other images that include them, per DB vendor.
  • Loading branch information
justdave committed Apr 28, 2024
1 parent 32d6e57 commit a35739b
Show file tree
Hide file tree
Showing 18 changed files with 488 additions and 35 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
# - name: Build the Docker images
# run: docker compose -f docker-compose.test.yml build
# - name: Run webservice tests
# run: docker-compose -f docker-compose.test.yml run bugzilla6.test test_webservices
# run: docker compose -f docker-compose.test.yml run bugzilla6.test test_webservices

test_bugzilla6_mysql:
runs-on: ubuntu-latest
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Build the Docker images
run: docker compose -f docker-compose.test.yml build
- name: Run bmo specific tests
run: docker-compose -f docker-compose.test.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t
run: docker compose -f docker-compose.test.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t

test_bugzilla6_pg:
runs-on: ubuntu-latest
Expand All @@ -46,5 +46,16 @@ jobs:
- name: Build the Docker images
run: docker compose -f docker-compose.test-pg.yml build
- name: Run bmo specific tests
run: docker-compose -f docker-compose.test-pg.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t
run: docker compose -f docker-compose.test-pg.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t

test_bugzilla6_sqlite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install docker-compose
run: sudo apt update && sudo apt install -y docker-compose
- name: Build the Docker images
run: docker compose -f docker-compose.test-sqlite.yml build
- name: Run bmo specific tests
run: docker compose -f docker-compose.test-sqlite.yml run -e CI=1 bugzilla6.test test_bmo -q -f t/bmo/*.t

7 changes: 7 additions & 0 deletions Bugzilla/DaemonControl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ sub assert_database {
my $repeat = try_repeat_until_success {
$loop->delay_future(after => 0.25)->then(sub {
my $attrs = {RaiseError => 1, PrintError => 1};
if ($lc->{db_driver} eq 'sqlite') {
# If we're using sqlite, just assume we're connected, since it's just a
# file on the local filesystem. The driver will automatically create
# the DB file if it doesn't exist yet when checksetup runs.
Future->wrap("done");
return;
}
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
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM bugzilla/bugzilla-perl-slim:20240322.1
ARG BZDB="-mysql8"
FROM bugzilla/bugzilla-perl-slim${BZDB}:20240410.1

ENV DEBIAN_FRONTEND noninteractive

Expand Down
6 changes: 6 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ my %optional_features = (
runtime => {requires => {'File::Which' => 0, 'File::Copy::Recursive' => 0,}}
},
},
docker => {
description => 'Run Bugzilla inside Docker',
prereqs => {
runtime => {requires => {'File::Copy::Recursive' => 0,}}
},
},
graphical_reports => {
description => 'Graphical Reports',
prereqs => {
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.test-pg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ version: '3.6'
services:
bugzilla6.test:
build:
args:
- BZDB=-pg9
context: .
dockerfile: Dockerfile
command: dev_httpd
Expand Down Expand Up @@ -59,5 +61,5 @@ services:
selenium:
image: selenium/standalone-firefox:3.141.59
shm_size: '512m'
ports:
- "5900:5900"
#ports:
# - "5900:5900"
53 changes: 53 additions & 0 deletions docker-compose.test-sqlite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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:
bugzilla6.test:
build:
args:
- BZDB=
context: .
dockerfile: Dockerfile
command: dev_httpd
tmpfs:
- /tmp
- /run
environment:
- 'BMO_inbound_proxies=*'
- BMO_db_driver=sqlite
- BMO_db_host=localhost
- BMO_db_name=bugs
- BMO_db_pass=bugs
- BMO_db_user=bugs
- BMO_memcached_namespace=bugzilla
- BMO_memcached_servers=memcached:11211
- BMO_ses_username=ses@mozilla.bugs
- 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/.github/checksetup_answers.txt
- BZ_QA_CONF_FILE=/app/.github/selenium_test.conf
- BZ_QA_CONFIG=1
- 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:
- memcached
- selenium

memcached:
image: memcached:latest

selenium:
image: selenium/standalone-firefox:3.141.59
shm_size: '512m'
#ports:
# - "5900:5900"
8 changes: 5 additions & 3 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ services:
- selenium

bugzilla6.mysql8:
image: mysql:8
build:
context: .
dockerfile: docker/images/Dockerfile.mysql8
tmpfs:
- /tmp
logging:
Expand All @@ -60,5 +62,5 @@ services:
selenium:
image: selenium/standalone-firefox:3.141.59
shm_size: '512m'
ports:
- "5900:5900"
#ports:
# - "5900:5900"
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ services:
bugzilla6.mysql8:
build:
context: .
dockerfile: Dockerfile.mysql8
dockerfile: docker/images/Dockerfile.mysql8
volumes:
- bugzilla6-mysql-db:/var/lib/mysql
tmpfs:
Expand Down
13 changes: 10 additions & 3 deletions docker/gen-bugzilla-perl-slim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,20 @@ if [ $? != 0 ]; then
echo
exit -1
fi
if [ ! -f "docker/images/Dockerfile.bugzilla-slim" ]; then
echo
echo "Can't locate the Dockerfile, try running from the root of"
echo "your Bugzilla checkout."
echo
exit -1
fi

export DOCKER_CLI_HINTS=false
export CI=""
export CIRCLE_SHA1=""
export CIRCLE_BUILD_URL=""
$DOCKER build -t bugzilla-cpanfile -f Dockerfile.cpanfile .
$DOCKER run -it -v "$(pwd):/app/result" bugzilla-cpanfile cp cpanfile cpanfile.snapshot /app/result
#$DOCKER build -t bugzilla-cpanfile -f Dockerfile.cpanfile .
#$DOCKER run -it -v "$(pwd):/app/result" bugzilla-cpanfile cp cpanfile cpanfile.snapshot /app/result

# Figure out the tag name to use for the image. We'll do this by generating
# a code based on today's date, then attempt to pull it from DockerHub. If
Expand All @@ -66,7 +73,7 @@ while [ $? == 0 ]; do
((ITER++))
$DOCKER pull bugzilla/bugzilla-perl-slim:${DATE}.${ITER} >/dev/null 2>/dev/null
done
$DOCKER build -t bugzilla/bugzilla-perl-slim:${DATE}.${ITER} -f Dockerfile.bugzilla-slim .
$DOCKER build -t bugzilla/bugzilla-perl-slim:${DATE}.${ITER} -f docker/images/Dockerfile.bugzilla-slim .
if [ $? == 0 ]; then
echo
echo "The build appears to have succeeded. Don't forget to change the FROM line"
Expand Down
113 changes: 113 additions & 0 deletions docker/gen-bugzilla-slim-mysql8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/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 [ ! -e 'Makefile.PL' ]; then
echo
echo "Please run this from the root of the Bugzilla source tree."
echo
exit -1
fi
if [ -z "$DOCKER" ]; then
DOCKER=`which docker`
fi
if [ ! -x "$DOCKER" ]; then
echo
echo "You specified a custom Docker executable via the DOCKER"
echo "environment variable at $DOCKER"
echo "which either does not exist or is not executable."
echo "Please fix it to point at a working Docker or remove the"
echo "DOCKER environment variable to use the one in your PATH"
echo "if it exists."
echo
exit -1
fi
if [ -z "$DOCKER" ]; then
echo
echo "You do not appear to have docker installed or I can't find it."
echo "Windows and Mac versions can be downloaded from"
echo "https://www.docker.com/products/docker-desktop"
echo "Linux users can install using your package manager."
echo
echo "Please install docker or specify the location of the docker"
echo "executable in the DOCKER environment variable and try again."
echo
exit -1
fi
$DOCKER info 1>/dev/null 2>/dev/null
if [ $? != 0 ]; then
echo
echo "The docker daemon is not running or I can't connect to it."
echo "Please make sure it's running and try again."
echo
exit -1
fi
if [ ! -f "docker/images/Dockerfile.bugzilla-mysql8" ]; then
echo
echo "Can't locate the Dockerfile, try running from the root of"
echo "your Bugzilla checkout."
echo
exit -1
fi

export DOCKER_CLI_HINTS=false
export CI=""
export CIRCLE_SHA1=""
export CIRCLE_BUILD_URL=""

# Figure out the tag name to use for the image. We'll do this by generating
# a code based on today's date, then attempt to pull it from DockerHub. If
# we successfully pull, then it already exists, and we bump the interation
# number on the end.
DATE=`date +"%Y%m%d"`
ITER=1
$DOCKER pull bugzilla/bugzilla-perl-slim-mysql8:${DATE}.${ITER} >/dev/null 2>/dev/null
while [ $? == 0 ]; do
# as long as we succesfully pull, keep bumping the number on the end
((ITER++))
$DOCKER pull bugzilla/bugzilla-perl-slim-mysql8:${DATE}.${ITER} >/dev/null 2>/dev/null
done
$DOCKER build -t bugzilla/bugzilla-perl-slim-mysql8:${DATE}.${ITER} -f docker/images/Dockerfile.bugzilla-mysql8 .
if [ $? == 0 ]; then
echo
echo "The build appears to have succeeded. Don't forget to change the FROM line"
echo "at the top of Dockerfile to use:"
echo " bugzilla/bugzilla-perl-slim-mysql8:${DATE}.${ITER}"
echo "to make use of this image."
echo
# check if the user is logged in
if [ -z "$PYTHON" ]; then
PYTHON=`which python`
fi
if [ -z "$PYTHON" ]; then
PYTHON=`which python3`
fi
if [ ! -x "$PYTHON" ]; then
echo "The python executable specified in your PYTHON environment value or your PATH is not executable or I can't find it."
exit -1
fi
AUTHINFO=`$PYTHON -c "import json; print(len(json.load(open('${HOME}/.docker/config.json','r',encoding='utf-8'))['auths']))"`
if [ $AUTHINFO -gt 0 ]; then
# user is logged in
read -p "Do you wish to push to DockerHub? [y/N]: " yesno
case $yesno in
[Yy]*)
echo "Pushing..."
$DOCKER push bugzilla/bugzilla-perl-slim-mysql8:${DATE}.${ITER}
;;
*)
echo "Not pushing. You can just run this script again when you're ready"
echo "to push. The prior build result is cached."
;;
esac
fi
else
echo
echo "Docker build failed. See output above."
echo
exit -1
fi

0 comments on commit a35739b

Please sign in to comment.