-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
37 lines (29 loc) · 1.29 KB
/
Dockerfile
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
37
FROM mysql:8.0-debian
# Configure golang environment to run migration against database
ARG TARGETARCH
RUN apt-get update && apt-get install -y curl && apt-get clean
RUN apt-get install -y git
RUN curl -L https://golang.org/dl/go1.18.linux-$TARGETARCH.tar.gz | tar xzf -
ENV GOROOT=/go
ENV PATH=$PATH:/go/bin
RUN mkdir /home/mysql && chown mysql:mysql /home/mysql
USER mysql
COPY --chown=mysql:mysql . /home/mysql/contest
WORKDIR /home/mysql
# Pre-build the migration script, make sure it builds.
RUN cd /home/mysql/contest && \
go build github.com/linuxboot/contest/tools/migration/rdbms
# All scripts in docker-entrypoint-initdb.d/ are automatically
# executed during container startup
COPY docker/mysql/initdb.sql /docker-entrypoint-initdb.d/
COPY db/rdbms/schema/v0/create_contest_db.sql /
# Run all known migrations at the time of the creation of the container.
# From container documentation:
# """
# When a container is started for the first time, a new database with the
# specified name will be created and initialized with the provided configuration
# variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz
# that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical
# order.
# """
COPY docker/mysql/migration.sh /docker-entrypoint-initdb.d/