-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile.db
25 lines (18 loc) · 1.15 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
FROM mariadb:10.3 as builder
# Reference: https://serverfault.com/questions/796762/creating-a-docker-mysql-container-with-a-prepared-database-scheme
# 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 MARIADB_DATABASE=fp
ENV MARIADB_ROOT_PASSWORD=root
ENV MARIADB_CHARACTER_SET=utf8mb4
ENV MARIADB_COLLATE=utf8mb4_unicode_ci
COPY database.sql/setup.sql /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" ]
FROM mariadb:10.3
COPY --from=builder /initialized-db /var/lib/mysql
COPY database.sql /database.sql