ci: fix db container
This commit is contained in:
parent
8ea4ad4de2
commit
52b51e4962
|
@ -41,7 +41,7 @@ services:
|
|||
volumes:
|
||||
- mariadb-data:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ietf
|
||||
MYSQL_ROOT_PASSWORD: RkTkDPFnKpko
|
||||
MYSQL_DATABASE: ietf_utf8
|
||||
MYSQL_USER: django
|
||||
MYSQL_PASSWORD: RkTkDPFnKpko
|
||||
|
|
|
@ -1,53 +1,25 @@
|
|||
# ====================
|
||||
# --- Import Stage ---
|
||||
# ====================
|
||||
FROM ubuntu:focal AS importStage
|
||||
# =====================
|
||||
# --- Builder Stage ---
|
||||
# =====================
|
||||
FROM mariadb:10 AS builder
|
||||
|
||||
# Install dependencies for import
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get -y update && \
|
||||
apt-get -y install --no-install-recommends \
|
||||
locales \
|
||||
mariadb-server \
|
||||
pigz \
|
||||
unzip && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
# That file does the DB initialization but also runs mysql daemon, by removing the last line it will only init
|
||||
RUN ["sed", "-i", "s/exec \"$@\"/echo \"not running $@\"/", "/usr/local/bin/docker-entrypoint.sh"]
|
||||
|
||||
# Set locale to en_US.UTF-8
|
||||
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment && \
|
||||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
|
||||
echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
|
||||
dpkg-reconfigure locales && \
|
||||
locale-gen en_US.UTF-8 && \
|
||||
update-locale LC_ALL en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
|
||||
# Turn on mariadb performance_schema
|
||||
RUN sed -i 's/\[mysqld\]/\[mysqld\]\nperformance_schema=ON/' /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
|
||||
# Set mariadb default charset to utf8 instead of utf8mb4 to match production
|
||||
RUN sed -i 's/utf8mb4/utf8/' /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
RUN sed -i 's/unicode_ci/general_ci/' /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
|
||||
# Make the mariadb sys schema available for possible installation
|
||||
# We would normally use the next line, but that has a bug:
|
||||
# ADD https://github.com/FromDual/mariadb-sys/archive/master.zip /
|
||||
# This is the repo that has the PR:
|
||||
ADD https://github.com/grooverdan/mariadb-sys/archive/refs/heads/master.zip /
|
||||
RUN unzip /master.zip
|
||||
RUN rm /master.zip
|
||||
# needed for intialization
|
||||
ENV MARIADB_ROOT_PASSWORD=RkTkDPFnKpko
|
||||
ENV MARIADB_DATABASE=ietf_utf8
|
||||
ENV MARIADB_USER=django
|
||||
ENV MARIADB_PASSWORD=RkTkDPFnKpko
|
||||
|
||||
# Import the latest database dump
|
||||
ADD https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz /
|
||||
RUN pigz -v -d /ietf_utf8.sql.gz && \
|
||||
sed -i -e 's/ENGINE=MyISAM/ENGINE=InnoDB/' /ietf_utf8.sql
|
||||
# see https://dba.stackexchange.com/a/83385
|
||||
RUN sed -i 's/\[mysqld\]/\[mysqld\]\ninnodb_buffer_pool_size = 1G\ninnodb_log_buffer_size = 128M\ninnodb_log_file_size = 256M\ninnodb_write_io_threads = 8\ninnodb_flush_log_at_trx_commit = 0/' /etc/mysql/mariadb.conf.d/50-server.cnf && \
|
||||
systemctl start mariadb.service --innodb-doublewrite=0 && \
|
||||
echo "This sequence will take a long time, please be patient" && \
|
||||
mysqladmin -u root --default-character-set=utf8 create ietf_utf8 && \
|
||||
bash -c "cd /mariadb-sys-master && mysql --user root < sys_10.sql" && \
|
||||
bash -c "mysql --user root ietf_utf8 <<< \"GRANT ALL PRIVILEGES ON *.* TO 'django'@'%' IDENTIFIED BY 'RkTkDPFnKpko'; FLUSH PRIVILEGES;\"" && \
|
||||
bash -c "mysql --user=django --password=RkTkDPFnKpko -f ietf_utf8 < /ietf_utf8.sql"
|
||||
ADD https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz /docker-entrypoint-initdb.d/
|
||||
|
||||
# Need to change the datadir to something else that /var/lib/mysql because the parent docker file defines it as a volume.
|
||||
# https://docs.docker.com/engine/reference/builder/#volume :
|
||||
# Changing the volume from within the Dockerfile: If any build steps change the data within the volume after
|
||||
# it has been declared, those changes will be discarded.
|
||||
RUN ["/usr/local/bin/docker-entrypoint.sh", "mysqld", "--datadir", "/initialized-db", "--aria-log-dir-path", "/initialized-db"]
|
||||
|
||||
# ===================
|
||||
# --- Final Image ---
|
||||
|
@ -55,5 +27,5 @@ RUN sed -i 's/\[mysqld\]/\[mysqld\]\ninnodb_buffer_pool_size = 1G\ninnodb_log_bu
|
|||
FROM mariadb:10
|
||||
LABEL maintainer="IETF Tools Team <tools-discuss@ietf.org>"
|
||||
|
||||
# Copy the mysql data folder from the import stage
|
||||
COPY --from=importStage /var/lib/mysql /var/lib/mysql
|
||||
# Copy the mysql data folder from the builder stage
|
||||
COPY --from=builder /initialized-db /var/lib/mysql
|
||||
|
|
Loading…
Reference in a new issue