trying to commit with my voyager is too complicated at the moment
This commit is contained in:
parent
778e1a9056
commit
4a60057513
10 changed files with 130 additions and 62 deletions
|
|
@ -1,15 +1,17 @@
|
|||
FROM alpine:3.21
|
||||
|
||||
RUN apk update && apk add mariadb mariadb-client bash
|
||||
RUN apk update && apk add sudo mariadb mariadb-client bash;
|
||||
|
||||
RUN mkdir -p /run/mysqld && chown -R mysql:mysql /run/mysqld
|
||||
|
||||
HEALTHCHECK --start-period=5m CMD mariadb -e 'SELECT @@datadir;' || exit 1
|
||||
|
||||
RUN mysql_install_db --user=$DB_USER --basedir=/usr --datadir=/var/lib/mysql
|
||||
|
||||
USER mysql
|
||||
RUN mkdir -p /var/lib/mysqld;
|
||||
RUN mkdir -p /run/mysqld;
|
||||
RUN chown -R mysql:mysql /run/mysqld;
|
||||
RUN chown -R mysql:mysql /var/lib/mysqld;
|
||||
|
||||
EXPOSE 3306
|
||||
|
||||
CMD ["mariadbd"]
|
||||
RUN /usr/bin/mysql_install_db --user=mysql --datadir=/var/lib/mysql;
|
||||
|
||||
COPY tools/start_db.sh /usr/bin/start_db
|
||||
RUN chmod +x /usr/bin/start_db;
|
||||
|
||||
CMD ["start_db"]
|
||||
|
|
|
|||
19
srcs/requirements/mariadb/tools/start_db.sh
Normal file
19
srcs/requirements/mariadb/tools/start_db.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
sudo -u mysql -s /bin/sh -c mysqld &
|
||||
PID=$!
|
||||
|
||||
mariadb-admin status --wait
|
||||
|
||||
mariadb -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME};"
|
||||
mariadb -e "CREATE USER IF NOT EXISTS '${DB_USER}'@'%' IDENTIFIED BY '${DB_PASSWORD}';"
|
||||
mariadb -e "GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'%';"
|
||||
mariadb -e "FLUSH PRIVILEGES;"
|
||||
|
||||
sudo -u mysql -s /bin/sh -c "mysqladmin shutdown"
|
||||
wait "$PID"
|
||||
|
||||
sed -i /etc/my.cnf.d/mariadb-server.cnf -e 's/^port=3307$/\0\nbind-address = 0.0.0.0/'
|
||||
sed -i /etc/my.cnf.d/mariadb-server.cnf -e 's/^skip-networking$/;\0/'
|
||||
|
||||
exec sudo -u mysql -s /bin/sh -c mysqld
|
||||
Loading…
Add table
Add a link
Reference in a new issue