forked from QuickSwing/v6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.db
36 lines (26 loc) · 1.58 KB
/
Dockerfile.db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
FROM mysql:8 as builder
# 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"]
# needed for intialization
ENV MYSQL_RANDOM_ROOT_PASSWORD=yes
ENV MYSQL_DATABASE=vanilla
ENV MYSQL_USER=tchooz
ENV MYSQL_PASSWORD=tchooz_password
# Copy Tchooz database (fresh install) to docker-initdb-entrypoint
COPY ["./media/com_emundus_vanilla/vanilla_emjmd.sql","/docker-entrypoint-initdb.d/init-vanilla.sql"]
# Copy MySQL configuration
COPY ["./.ci/mysql/conf/my.cnf","/etc/mysql/conf.d/my.cnf"]
RUN chmod 664 /etc/mysql/conf.d/my.cnf
# 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"]
FROM mysql:8
LABEL maintainer="Wilfried Maillet <wilfried.maillet@emundus.fr>"
# Preloading of the database
COPY --from=builder /initialized-db /var/lib/mysql
# Copy MySQL custom configuration
COPY --from=builder /etc/mysql/conf.d/my.cnf /etc/mysql/conf.d/my.cnf
# Provide the Tchooz database initialization SQL script in a scenario where the container uses an empty volume
COPY --from=builder /docker-entrypoint-initdb.d/init-vanilla.sql /docker-entrypoint-initdb.d/init-vanilla.sql