2019-07-27 11:12:46 -04:00
|
|
|
# Copyright (c) 2019 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
|
|
# implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2023-03-27 08:13:33 -07:00
|
|
|
# Mon Mar 27 15:13:11 UTC 2023 - trigger rebuild
|
2021-02-12 08:58:18 +11:00
|
|
|
|
2021-09-15 13:45:31 -07:00
|
|
|
FROM docker.io/opendevorg/python-builder:3.9-bullseye as builder
|
2019-09-17 12:18:02 +02:00
|
|
|
|
|
|
|
COPY . /tmp/src
|
|
|
|
RUN assemble
|
|
|
|
|
2023-01-17 15:24:40 -08:00
|
|
|
FROM docker.io/opendevorg/python-base:3.9-bullseye as gerrit-base
|
2019-07-27 11:12:46 -04:00
|
|
|
|
2020-02-26 16:10:58 -06:00
|
|
|
RUN echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/95disable-recommends
|
|
|
|
|
2019-07-27 11:12:46 -04:00
|
|
|
RUN apt-get update \
|
2023-02-27 12:56:03 -08:00
|
|
|
&& apt-get install -y dumb-init git openssh-client openjdk-11-jdk-headless unzip \
|
2023-01-17 15:24:40 -08:00
|
|
|
# This next set of installs helps align us with the old openjdk image \
|
|
|
|
# but they may not all be necessary \
|
|
|
|
&& apt-get install -y xz-utils bzip2 wget curl gnupg \
|
2019-07-27 11:12:46 -04:00
|
|
|
&& apt-get clean \
|
2023-01-17 15:24:40 -08:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2019-09-17 12:18:02 +02:00
|
|
|
|
|
|
|
COPY --from=builder /output/ /output
|
|
|
|
RUN /output/install-from-bindep
|
2019-07-27 11:12:46 -04:00
|
|
|
|
2019-09-16 20:23:22 +02:00
|
|
|
# 3000 is what the existing opendev gerrit2 uid is
|
2019-07-27 11:12:46 -04:00
|
|
|
RUN addgroup gerrit --gid 3000 --system \
|
|
|
|
&& adduser \
|
|
|
|
--system \
|
|
|
|
--uid 3000 \
|
|
|
|
--home /var/gerrit \
|
|
|
|
--shell /bin/bash \
|
|
|
|
--ingroup gerrit \
|
|
|
|
gerrit
|
|
|
|
|
gerrit: add mariadb_container option
This adds a local mariadb container to the gerrit host to hold the
accountPatchReviewDb database. This is inspired by a few things
- since migration to NoteDB, there is only one table left where
Gerrit records what files have been reviewed for a change. This
logically scales with the number of reviews users are doing.
Pulling the stats on this, we can see since the NoteDB upgrade this
went from a very busy database (~300 queries/70 commits per second)
to barely registering one hit per second :
https://imgur.com/a/QGJV7Fw
Thus separating the db to an external host for performance reasons
is not a large concern any more.
- emperically we've done a bad job in keeping the existing hosted db
up-to-date; it's still running mysql 5.1 and we have been hit by
bugs such as the one referenced in-line which silently drops
backups.
- The other gerrit option is to use an on-disk H2 database. This is
certainly an option, however you need special tools to interact
with it for migration, etc. and it's not safe to backup from files
on disk (as opposed to mysqldump). Upstream advice is unclear, and
varies between H2 being a performance bottleneck to this being
ephemeral data that users don't care about. We know how to admin
mariadb/mysql and this allows us to migrate and backup data, so
seems like the best choice.
- we have a pressing need to update the server to a new operating
system. Running the db alongside the gerrit instance minimises
fiddling we have to do manging connections to and migrating the
hosted db systems.
- related to that, we are tending towards more provider independence
for control-plane servers. A hosted database product is not always
provided, so this gives us more flexibility in moving things
around.
- the main concern here is memory usage. "docker stats" reports a
quiescent container, freshly started on a 8GB host:
gerrit-compose_mariadb_1 67.32MiB
After loading a copy of the production table, and then dumping it
back to a file the same container reports:
gerrit-compose_mariadb_1 462.6MiB
The existing remote mysql configuration path remains mostly the same.
We move the gerrit startup into a script rather than a CMD so we can
call it after a "wait for db" script in the mariadb_container case
(this is the reccommeded way to enforce ordering [1]).
Backups of the local container need different dump commands; backups
are relocated to a new file and updated.
Testing is converted to use this rather than a local H2 database.
[1] https://docs.docker.com/compose/startup-order/
Change-Id: Iec981ef3c2e38889f91e9759e66295dbfb499c2e
2021-02-17 15:23:19 +11:00
|
|
|
# Startup scripts
|
|
|
|
COPY wait-for-it.sh /wait-for-it.sh
|
|
|
|
RUN chmod +x /wait-for-it.sh
|
|
|
|
COPY run-gerrit.sh /run-gerrit.sh
|
|
|
|
RUN chmod +x /run-gerrit.sh
|
|
|
|
|
2019-07-27 11:12:46 -04:00
|
|
|
USER gerrit
|
2019-08-27 13:19:18 +02:00
|
|
|
RUN mkdir /var/gerrit/bin \
|
|
|
|
&& mkdir /var/gerrit/hooks \
|
|
|
|
&& mkdir /var/gerrit/static
|
2019-07-27 11:12:46 -04:00
|
|
|
|
2021-08-03 09:09:41 -07:00
|
|
|
# Download mariadb java client.
|
|
|
|
# Modern gerrit stopped downloading missing libs during init which means we
|
|
|
|
# need to do the downland and install ourselves.
|
2022-03-16 10:49:49 -07:00
|
|
|
# Note the perms on this are 0600 hence the need for the chown otherwise
|
|
|
|
# they are root owned and Gerrit can't use the jdbc driver.
|
|
|
|
ADD --chown=gerrit:gerrit https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.2/mariadb-java-client-2.7.2.jar /var/gerrit/lib/mariadb-java-client.jar
|
2020-03-20 09:41:23 -05:00
|
|
|
|
2019-07-27 11:12:46 -04:00
|
|
|
# Allow incoming traffic
|
2020-08-10 15:01:08 -07:00
|
|
|
# OpenDev Gerrit listens on 8081 not default of 8080
|
|
|
|
EXPOSE 29418 8081
|
2019-07-27 11:12:46 -04:00
|
|
|
|
2023-02-27 13:14:34 -08:00
|
|
|
VOLUME /var/gerrit/git /var/gerrit/index /var/gerrit/cache /var/gerrit/db /var/gerrit/etc /var/log/gerrit /var/gerrit/tmp /var/gerrit/data
|
2019-07-27 11:12:46 -04:00
|
|
|
|
|
|
|
RUN ln -s /var/log/gerrit /var/gerrit/logs
|
|
|
|
|
|
|
|
# container.javaOptions
|
|
|
|
# Also include container.heapLimit - but with -Xmx prefixing it
|
|
|
|
ENV JAVA_OPTIONS ""
|
|
|
|
|
|
|
|
# Ulimits should be set on command line or in docker-compose.yaml
|
|
|
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
gerrit: add mariadb_container option
This adds a local mariadb container to the gerrit host to hold the
accountPatchReviewDb database. This is inspired by a few things
- since migration to NoteDB, there is only one table left where
Gerrit records what files have been reviewed for a change. This
logically scales with the number of reviews users are doing.
Pulling the stats on this, we can see since the NoteDB upgrade this
went from a very busy database (~300 queries/70 commits per second)
to barely registering one hit per second :
https://imgur.com/a/QGJV7Fw
Thus separating the db to an external host for performance reasons
is not a large concern any more.
- emperically we've done a bad job in keeping the existing hosted db
up-to-date; it's still running mysql 5.1 and we have been hit by
bugs such as the one referenced in-line which silently drops
backups.
- The other gerrit option is to use an on-disk H2 database. This is
certainly an option, however you need special tools to interact
with it for migration, etc. and it's not safe to backup from files
on disk (as opposed to mysqldump). Upstream advice is unclear, and
varies between H2 being a performance bottleneck to this being
ephemeral data that users don't care about. We know how to admin
mariadb/mysql and this allows us to migrate and backup data, so
seems like the best choice.
- we have a pressing need to update the server to a new operating
system. Running the db alongside the gerrit instance minimises
fiddling we have to do manging connections to and migrating the
hosted db systems.
- related to that, we are tending towards more provider independence
for control-plane servers. A hosted database product is not always
provided, so this gives us more flexibility in moving things
around.
- the main concern here is memory usage. "docker stats" reports a
quiescent container, freshly started on a 8GB host:
gerrit-compose_mariadb_1 67.32MiB
After loading a copy of the production table, and then dumping it
back to a file the same container reports:
gerrit-compose_mariadb_1 462.6MiB
The existing remote mysql configuration path remains mostly the same.
We move the gerrit startup into a script rather than a CMD so we can
call it after a "wait for db" script in the mariadb_container case
(this is the reccommeded way to enforce ordering [1]).
Backups of the local container need different dump commands; backups
are relocated to a new file and updated.
Testing is converted to use this rather than a local H2 database.
[1] https://docs.docker.com/compose/startup-order/
Change-Id: Iec981ef3c2e38889f91e9759e66295dbfb499c2e
2021-02-17 15:23:19 +11:00
|
|
|
CMD "/run-gerrit.sh"
|