mariadb and nginx works both with debian and alpine

+ makefile a little clean up
This commit is contained in:
hugo gogo
2022-09-18 16:39:13 +02:00
parent 5d01ad0fdc
commit 9708715bb5
9 changed files with 134 additions and 67 deletions

View File

@@ -1,26 +1,48 @@
FROM debian:buster
# debian -----------------------------------------------------
ARG DB_NAME
ARG DB_USER
ARG DB_PSWD
# FROM debian:buster
#
# ARG DB_NAME
# ARG DB_USER
# ARG DB_PSWD
#
# RUN apt update && apt install -y \
# mariadb-client \
# mariadb-server \
# && \
# rm -rf /var/lib/apt/lists/*
#
# # config file .cnf :
# COPY ./conf/50-server.cnf.debian /etc/mysql/mariadb.conf.d/50-server.cnf
RUN apt update && apt install -y \
mariadb-client \
mariadb-server
RUN rm -rf /var/lib/apt/lists/*
# alpine -----------------------------------------------------
FROM alpine:3.15
ARG DB_NAME
ARG DB_USER
ARG DB_PSWD
# vim and bash for debug
RUN apk update && apk add \
mariadb \
mariadb-client \
vim bash \
&& \
rm -rf /var/cache/apk*
# config file .cnf :
COPY ./conf/mariadb-server.cnf.alpine /etc/my.cnf.d/mariadb-server.cnf
# common -----------------------------------------------------
# init mysql database
RUN mysql_install_db --user=mysql --ldata=/var/lib/mysql && \
mkdir -p /var/run/mysqld && \
chown -R mysql:root /var/run/mysqld
# configure wp database
RUN service mysql start && \
mariadb --execute="CREATE DATABASE ${DB_NAME};" && \
mariadb --execute="CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PSWD}';" && \
mariadb --execute="GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'localhost' with grant option;"
COPY ./conf/create_db.sql /usr/bin/create_db.sql
# # config file 50-server.cnf :
# # uncomment port = 3306
# RUN sed -i "s/^#port/port /g" /etc/mysql/mariadb.conf.d/50-server.cnf
# # comment bind-address = 127.0.0.1
# RUN sed -i "s/^bind-address /#bind-address/g" /etc/mysql/mariadb.conf.d/50-server.cnf
COPY ./conf/50-server.cnf ./
ENTRYPOINT [ "mysqld" ]
ENTRYPOINT [ "mysqld", "--user=mysql", "--init-file=/usr/bin/create_db.sql" ]

View File

@@ -1,3 +1,12 @@
# inception modifications :
#
# [mysqld] :
# < port = 3306
# > #port = 3306
# ---
# < #bind-address = 127.0.0.1
# > bind-address = 127.0.0.1
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see

View File

@@ -0,0 +1,5 @@
USE mysql;
CREATE DATABASE IF NOT EXISTS ${DB_NAME};
CREATE USER IF NOT EXISTS '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PSWD}';
GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'localhost' with grant option;

View File

@@ -0,0 +1,62 @@
# https://wiki.alpinelinux.org/wiki/MariaDB
# inception modifications :
#
# [mysqld] :
# < skip-networking = false
# > skip-networking
# ---
# < datadir = /var/lib/mysql
# >
# ---
# < port = 3306
# >
# ---
# < socket=/var/lib/mysql/mysql.sock
# >
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
skip-networking = false
datadir = /var/lib/mysql
port = 3306
socket=/var/lib/mysql/mysql.sock
# Galera-related settings
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.5]