diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88c3563b3..0b42b44a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 diff --git a/Bugzilla/DaemonControl.pm b/Bugzilla/DaemonControl.pm index 40a1de273..390954649 100644 --- a/Bugzilla/DaemonControl.pm +++ b/Bugzilla/DaemonControl.pm @@ -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 diff --git a/Dockerfile b/Dockerfile index 85fdc8a7b..44cca0f82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile.PL b/Makefile.PL index ae5bc4f6f..1fd18e7f7 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -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 => { diff --git a/docker-compose.test-pg.yml b/docker-compose.test-pg.yml index cd6deee5e..06479194d 100644 --- a/docker-compose.test-pg.yml +++ b/docker-compose.test-pg.yml @@ -7,6 +7,8 @@ version: '3.6' services: bugzilla6.test: build: + args: + - BZDB=-pg9 context: . dockerfile: Dockerfile command: dev_httpd @@ -59,5 +61,5 @@ services: selenium: image: selenium/standalone-firefox:3.141.59 shm_size: '512m' - ports: - - "5900:5900" + #ports: + # - "5900:5900" diff --git a/docker-compose.test-sqlite.yml b/docker-compose.test-sqlite.yml new file mode 100644 index 000000000..18d6e83b7 --- /dev/null +++ b/docker-compose.test-sqlite.yml @@ -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" diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 5a6b06a4c..f4f574066 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -43,7 +43,9 @@ services: - selenium bugzilla6.mysql8: - image: mysql:8 + build: + context: . + dockerfile: docker/images/Dockerfile.mysql8 tmpfs: - /tmp logging: @@ -60,5 +62,5 @@ services: selenium: image: selenium/standalone-firefox:3.141.59 shm_size: '512m' - ports: - - "5900:5900" + #ports: + # - "5900:5900" diff --git a/docker-compose.yml b/docker-compose.yml index 1e2fa04e4..299f951bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/docker/gen-bugzilla-perl-slim.sh b/docker/gen-bugzilla-perl-slim.sh index c1d757d79..95a4ca165 100644 --- a/docker/gen-bugzilla-perl-slim.sh +++ b/docker/gen-bugzilla-perl-slim.sh @@ -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 @@ -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" diff --git a/docker/gen-bugzilla-slim-mysql8.sh b/docker/gen-bugzilla-slim-mysql8.sh new file mode 100644 index 000000000..2341f3360 --- /dev/null +++ b/docker/gen-bugzilla-slim-mysql8.sh @@ -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 diff --git a/docker/gen-bugzilla-slim-pg9.sh b/docker/gen-bugzilla-slim-pg9.sh new file mode 100644 index 000000000..92710d55c --- /dev/null +++ b/docker/gen-bugzilla-slim-pg9.sh @@ -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-pg9" ]; 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-pg9:${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-pg9:${DATE}.${ITER} >/dev/null 2>/dev/null +done +$DOCKER build -t bugzilla/bugzilla-perl-slim-pg9:${DATE}.${ITER} -f docker/images/Dockerfile.bugzilla-pg9 . +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-pg9:${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-pg9:${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 diff --git a/docker/gen-cpanfile-snapshot.sh b/docker/gen-cpanfile-snapshot.sh index 9e1ddc896..38676b4cc 100644 --- a/docker/gen-cpanfile-snapshot.sh +++ b/docker/gen-cpanfile-snapshot.sh @@ -40,8 +40,15 @@ if [ $? != 0 ]; then echo exit -1 fi +if [ ! -f "docker/images/Dockerfile.cpanfile" ]; 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 -$DOCKER build -t bugzilla-cpanfile -f Dockerfile.cpanfile . +$DOCKER build -t bugzilla-cpanfile -f docker/images/Dockerfile.cpanfile . $DOCKER run -it -v "$(pwd):/app/result" bugzilla-cpanfile cp cpanfile cpanfile.snapshot /app/result diff --git a/Dockerfile.bugzilla-slim b/docker/images/Dockerfile.bugzilla-mysql8 similarity index 77% rename from Dockerfile.bugzilla-slim rename to docker/images/Dockerfile.bugzilla-mysql8 index 980b014e7..5d1dff9f6 100644 --- a/Dockerfile.bugzilla-slim +++ b/docker/images/Dockerfile.bugzilla-mysql8 @@ -1,8 +1,8 @@ -FROM perl:5.38.0-slim AS builder +FROM bugzilla/bugzilla-perl-slim:20240410.1 AS builder -RUN apt-get update -RUN apt-get -y dist-upgrade -RUN apt-get install -y \ +RUN apt-get update \ + && apt-get dist-upgrade -y \ + && apt-get install -y \ apt-file \ build-essential \ cmake \ @@ -13,7 +13,9 @@ RUN apt-get install -y \ libgd-dev \ libssl-dev \ openssl \ - zlib1g-dev + zlib1g-dev \ + unzip \ + wget # The Perl image is based on Debian, which doesn't have MySQL 8, and the # current DBD::mysql requires MySQL 8 libraries to build, so we have @@ -23,17 +25,19 @@ 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 libpq-dev - -RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot + && apt-get install -y libmysqlclient-dev WORKDIR /app -COPY cpanfile cpanfile.snapshot /app/ +COPY Makefile.PL Bugzilla.pm gen-cpanfile.pl /app/ +COPY extensions/ /app/extensions/ + +RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot + +RUN perl Makefile.PL +RUN make cpanfile GEN_CPANFILE_ARGS="-D mysql" -RUN cpm install -# secure mail loop fixes -RUN cpm install http://s3.amazonaws.com/moz-devservices-bmocartons/third-party/Crypt-OpenPGP-1.15.tar.gz +RUN carton install RUN apt-file update RUN find local -name '*.so' -exec ldd {} \; \ @@ -43,7 +47,7 @@ RUN find local -name '*.so' -exec ldd {} \; \ | xargs -IFILE apt-file search -l FILE \ | sort -u > PACKAGES -FROM perl:5.38.0-slim +FROM bugzilla/bugzilla-perl-slim:20240410.1 ENV DEBIAN_FRONTEND noninteractive @@ -51,7 +55,12 @@ COPY --from=builder /app/local /app/local COPY --from=builder /app/PACKAGES /app/PACKAGES RUN apt-get update \ - && apt-get install -y gnupg + && apt-get install -y \ + gnupg + +# The Perl image is based on Debian, which doesn't have MySQL 8, and the +# current DBD::mysql requires MySQL 8 libraries to build, so we have +# to get the client libraries from mysql.com RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-8.0.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 5072E1F5 \ && gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-8.0.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3A79BD29 \ && gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql-8.0.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B7B3B788A8D3785C \ @@ -59,14 +68,7 @@ RUN gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mysql- RUN apt-get update \ && apt-get install -y \ - curl \ - git \ - graphviz \ - libcap2-bin \ libmysqlclient21 \ - postgresql-client \ - rsync \ $(cat /app/PACKAGES) \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/* -RUN useradd -u 10001 -U app -m && setcap 'cap_net_bind_service=+ep' /usr/local/bin/perl diff --git a/docker/images/Dockerfile.bugzilla-pg9 b/docker/images/Dockerfile.bugzilla-pg9 new file mode 100644 index 000000000..7698e8514 --- /dev/null +++ b/docker/images/Dockerfile.bugzilla-pg9 @@ -0,0 +1,67 @@ +FROM bugzilla/bugzilla-perl-slim:20240410.1 AS builder + +# reinstall the build prereqs on the temporary image +RUN apt-get update \ + && apt-get dist-upgrade -y \ + && apt-get install -y \ + apt-file \ + build-essential \ + cmake \ + curl \ + git \ + libcairo-dev \ + libexpat-dev \ + libgd-dev \ + libssl-dev \ + openssl \ + zlib1g-dev \ + unzip \ + wget + +# install any custom build prereqs we need for this specific image +# Postgres libraries in this case +RUN apt-get install -y libpq-dev + +WORKDIR /app + +COPY Makefile.PL Bugzilla.pm gen-cpanfile.pl /app/ +COPY extensions/ /app/extensions/ + +RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot + +# GEN_CPANFILE_ARGS here needs to have the list of additional features +# this images is supposed to contain +# Postgres support in this case +RUN perl Makefile.PL +RUN make cpanfile GEN_CPANFILE_ARGS="-D pg" + +RUN carton install + +# make a list of all of the packages needed to run the libraries we've +# installed +RUN apt-file update +RUN find local -name '*.so' -exec ldd {} \; \ + | egrep -v 'not.found|not.a.dynamic.executable' \ + | awk '$3 {print $3}' \ + | sort -u \ + | xargs -IFILE apt-file search -l FILE \ + | sort -u > PACKAGES + +# now we start over with a new image so the final image doesn't contain +# developer tools +FROM bugzilla/bugzilla-perl-slim:20240410.1 + +ENV DEBIAN_FRONTEND noninteractive + +# copy the stuff we built over from the temporary image +COPY --from=builder /app/local /app/local +COPY --from=builder /app/PACKAGES /app/PACKAGES + +# restore the package dependencies we saved earlier, and install any additional packages this image needs to contain. +# The Postgres client libraries in this case. +RUN apt-get update \ + && apt-get install -y \ + postgresql-client \ + $(cat /app/PACKAGES) \ + && rm -rf /var/cache/apt/* /var/lib/apt/lists/* + diff --git a/docker/images/Dockerfile.bugzilla-slim b/docker/images/Dockerfile.bugzilla-slim new file mode 100644 index 000000000..8553134c1 --- /dev/null +++ b/docker/images/Dockerfile.bugzilla-slim @@ -0,0 +1,60 @@ +FROM perl:5.38.0-slim AS builder + +RUN apt-get update \ + && apt-get dist-upgrade -y \ + && apt-get install -y \ + apt-file \ + build-essential \ + cmake \ + curl \ + git \ + libcairo-dev \ + libexpat-dev \ + libgd-dev \ + libssl-dev \ + openssl \ + zlib1g-dev \ + unzip \ + wget + +RUN cpanm --notest --quiet App::cpm Module::CPANfile Carton::Snapshot + +WORKDIR /app + +COPY Makefile.PL Bugzilla.pm gen-cpanfile.pl /app/ +COPY extensions/ /app/extensions/ + +RUN perl Makefile.PL +RUN make cpanfile GEN_CPANFILE_ARGS="-D better_xff -D jsonrpc -D xmlrpc -D docker" + +RUN carton install + +# secure mail loop fixes +RUN cpm install http://s3.amazonaws.com/moz-devservices-bmocartons/third-party/Crypt-OpenPGP-1.15.tar.gz + +RUN apt-file update +RUN find local -name '*.so' -exec ldd {} \; \ + | egrep -v 'not.found|not.a.dynamic.executable' \ + | awk '$3 {print $3}' \ + | sort -u \ + | xargs -IFILE apt-file search -l FILE \ + | sort -u > PACKAGES + +FROM perl:5.38.0-slim + +ENV DEBIAN_FRONTEND noninteractive + +COPY --from=builder /app/local /app/local +COPY --from=builder /app/PACKAGES /app/PACKAGES + +RUN apt-get update \ + && apt-get install -y \ + curl \ + git \ + graphviz \ + libcap2-bin \ + rsync \ + $(cat /app/PACKAGES) \ + && rm -rf /var/cache/apt/* /var/lib/apt/lists/* + +RUN useradd -u 10001 -U app -m && setcap 'cap_net_bind_service=+ep' /usr/local/bin/perl diff --git a/Dockerfile.cpanfile b/docker/images/Dockerfile.cpanfile similarity index 100% rename from Dockerfile.cpanfile rename to docker/images/Dockerfile.cpanfile diff --git a/Dockerfile.mysql8 b/docker/images/Dockerfile.mysql8 similarity index 100% rename from Dockerfile.mysql8 rename to docker/images/Dockerfile.mysql8 diff --git a/docker/run-tests-in-docker.sh b/docker/run-tests-in-docker.sh index fd76880e6..e25499889 100644 --- a/docker/run-tests-in-docker.sh +++ b/docker/run-tests-in-docker.sh @@ -54,6 +54,8 @@ export CIRCLE_BUILD_URL="" DOCKER_COMPOSE_FILE=docker-compose.test.yml if [ "$1" == "pg" ]; then DOCKER_COMPOSE_FILE=docker-compose.test-pg.yml +elif [ "$1" == "sqlite" ]; then + DOCKER_COMPOSE_FILE=docker-compose.test-sqlite.yml fi $DOCKER compose -f $DOCKER_COMPOSE_FILE build if [ $? == 0 ]; then