Skip to content

Commit cf86c27

Browse files
authored
Merge pull request #110 from linuxserver/s6v3-master
2 parents 2bffc8b + 97f741d commit cf86c27

File tree

27 files changed

+85
-72
lines changed

27 files changed

+85
-72
lines changed

.github/workflows/external_trigger.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fi
1919
echo "**** External trigger running off of master branch. To disable this trigger, set a Github secret named \"PAUSE_EXTERNAL_TRIGGER_MARIADB_MASTER\". ****"
2020
echo "**** Retrieving external version ****"
21-
EXT_RELEASE=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
21+
EXT_RELEASE=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
2222
&& awk '/^P:'"mariadb"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://')
2323
if [ -z "${EXT_RELEASE}" ] || [ "${EXT_RELEASE}" == "null" ]; then
2424
echo "**** Can't retrieve external version, exiting ****"

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/linuxserver/baseimage-alpine:3.14
1+
FROM ghcr.io/linuxserver/baseimage-alpine:3.16
22

33
# set version label
44
ARG BUILD_DATE
@@ -14,7 +14,7 @@ ENV DATADIR=$MYSQL_DIR/databases
1414
RUN \
1515
echo "**** install runtime packages ****" && \
1616
if [ -z ${MARIADB_VERSION+x} ]; then \
17-
MARIADB_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
17+
MARIADB_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
1818
&& awk '/^P:mariadb$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
1919
fi && \
2020
apk add --no-cache \
@@ -36,4 +36,5 @@ COPY root/ /
3636

3737
# ports and volumes
3838
EXPOSE 3306
39+
3940
VOLUME /config

Dockerfile.aarch64

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.14
1+
FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.16
22

33
# set version label
44
ARG BUILD_DATE
@@ -14,7 +14,7 @@ ENV DATADIR=$MYSQL_DIR/databases
1414
RUN \
1515
echo "**** install runtime packages ****" && \
1616
if [ -z ${MARIADB_VERSION+x} ]; then \
17-
MARIADB_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
17+
MARIADB_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
1818
&& awk '/^P:mariadb$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
1919
fi && \
2020
apk add --no-cache \
@@ -36,4 +36,5 @@ COPY root/ /
3636

3737
# ports and volumes
3838
EXPOSE 3306
39+
3940
VOLUME /config

Dockerfile.armhf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.14
1+
FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.16
22

33
# set version label
44
ARG BUILD_DATE
@@ -14,7 +14,7 @@ ENV DATADIR=$MYSQL_DIR/databases
1414
RUN \
1515
echo "**** install runtime packages ****" && \
1616
if [ -z ${MARIADB_VERSION+x} ]; then \
17-
MARIADB_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
17+
MARIADB_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
1818
&& awk '/^P:mariadb$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
1919
fi && \
2020
apk add --no-cache \
@@ -36,4 +36,5 @@ COPY root/ /
3636

3737
# ports and volumes
3838
EXPOSE 3306
39+
3940
VOLUME /config

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pipeline {
2525
DEV_DOCKERHUB_IMAGE = 'lsiodev/mariadb'
2626
PR_DOCKERHUB_IMAGE = 'lspipepr/mariadb'
2727
DIST_IMAGE = 'alpine'
28-
DIST_TAG = '3.14'
29-
DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.14/main/'
28+
DIST_TAG = '3.16'
29+
DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.16/main/'
3030
DIST_REPO_PACKAGES = 'mariadb'
3131
MULTIARCH='true'
3232
CI='true'

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ Container images are configured using parameters passed at runtime (such as thos
159159
| `-p 3306` | Mariadb listens on this port. |
160160
| `-e PUID=1000` | for UserID - see below for explanation |
161161
| `-e PGID=1000` | for GroupID - see below for explanation |
162-
| `-e MYSQL_ROOT_PASSWORD=ROOT_ACCESS_PASSWORD` | Set this to root password for installation (minimum 4 characters). |
162+
| `-e MYSQL_ROOT_PASSWORD=ROOT_ACCESS_PASSWORD` | Set this to root password for installation (minimum 4 characters & non-alphanumeric passwords must be properly escaped). |
163163
| `-e TZ=Europe/London` | Specify a timezone to use EG Europe/London. |
164164
| `-e MYSQL_DATABASE=USER_DB_NAME` | Specify the name of a database to be created on image startup. |
165165
| `-e MYSQL_USER=MYSQL_USER` | This user will have superuser access to the database specified by MYSQL_DATABASE (do not use root here). |
166-
| `-e MYSQL_PASSWORD=DATABASE_PASSWORD` | Set this to the password you want to use for you MYSQL_USER (minimum 4 characters). |
166+
| `-e MYSQL_PASSWORD=DATABASE_PASSWORD` | Set this to the password you want to use for you MYSQL_USER (minimum 4 characters & non-alphanumeric passwords must be properly escaped). |
167167
| `-e REMOTE_SQL=http://URL1/your.sql,https://URL2/your.sql` | Set this to ingest sql files from an http/https endpoint (comma seperated array). |
168168
| `-v /config` | Contains the db itself and all assorted settings. |
169169

@@ -276,6 +276,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
276276

277277
## Versions
278278

279+
* **11.10.22:** - Rebase master to Alpine 3.16, migrate to s6v3, remove password escape logic which caused problems for a small subset of users.
279280
* **06.07.21:** - Rebase master to alpine.
280281
* **03.07.21:** - Rebase to 3.14.
281282
* **08.02.21:** - Fix new installs.

jenkins-vars.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ repo_vars:
1515
- DEV_DOCKERHUB_IMAGE = 'lsiodev/mariadb'
1616
- PR_DOCKERHUB_IMAGE = 'lspipepr/mariadb'
1717
- DIST_IMAGE = 'alpine'
18-
- DIST_TAG = '3.14'
19-
- DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.14/main/'
18+
- DIST_TAG = '3.16'
19+
- DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.16/main/'
2020
- DIST_REPO_PACKAGES = 'mariadb'
2121
- MULTIARCH='true'
2222
- CI='true'

readme-vars.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ param_container_name: "{{ project_name }}"
2525
param_usage_include_net: false
2626
param_usage_include_env: true
2727
param_env_vars:
28-
- { env_var: "MYSQL_ROOT_PASSWORD", env_value: "ROOT_ACCESS_PASSWORD", desc: "Set this to root password for installation (minimum 4 characters)." }
28+
- { env_var: "MYSQL_ROOT_PASSWORD", env_value: "ROOT_ACCESS_PASSWORD", desc: "Set this to root password for installation (minimum 4 characters & non-alphanumeric passwords must be properly escaped)." }
2929
- { env_var: "TZ", env_value: "Europe/London", desc: "Specify a timezone to use EG Europe/London." }
3030
param_usage_include_vols: true
3131
param_volumes:
@@ -41,7 +41,7 @@ opt_param_usage_include_env: true
4141
opt_param_env_vars:
4242
- { env_var: "MYSQL_DATABASE", env_value: "USER_DB_NAME", desc: "Specify the name of a database to be created on image startup." }
4343
- { env_var: "MYSQL_USER", env_value: "MYSQL_USER", desc: "This user will have superuser access to the database specified by MYSQL_DATABASE (do not use root here)." }
44-
- { env_var: "MYSQL_PASSWORD", env_value: "DATABASE_PASSWORD", desc: "Set this to the password you want to use for you MYSQL_USER (minimum 4 characters)." }
44+
- { env_var: "MYSQL_PASSWORD", env_value: "DATABASE_PASSWORD", desc: "Set this to the password you want to use for you MYSQL_USER (minimum 4 characters & non-alphanumeric passwords must be properly escaped)." }
4545
- { env_var: "REMOTE_SQL", env_value: "http://URL1/your.sql,https://URL2/your.sql", desc: "Set this to ingest sql files from an http/https endpoint (comma seperated array)." }
4646
opt_param_usage_include_vols: false
4747
opt_param_usage_include_ports: false
@@ -96,6 +96,7 @@ app_setup_block: |
9696
9797
# changelog
9898
changelogs:
99+
- { date: "11.10.22:", desc: "Rebase master to Alpine 3.16, migrate to s6v3, remove password escape logic which caused problems for a small subset of users." }
99100
- { date: "06.07.21:", desc: "Rebase master to alpine." }
100101
- { date: "03.07.21:", desc: "Rebase to 3.14." }
101102
- { date: "08.02.21:", desc: "Fix new installs." }

root/etc/cont-init.d/30-config

Lines changed: 0 additions & 22 deletions
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-config-end/dependencies.d/init-mariadb-initdb

Whitespace-only changes.

root/etc/s6-overlay/s6-rc.d/init-mariadb-config/dependencies.d/init-config

Whitespace-only changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# make folders if required
4+
mkdir -p \
5+
"${DATADIR}" \
6+
/config/log/mysql \
7+
/var/run/mysqld
8+
9+
# configure mariadb-server.cnf
10+
sed -i "s|.*skip-networking.*|#skip-networking|g" /etc/my.cnf.d/mariadb-server.cnf
11+
12+
# setup custom cnf file
13+
if [[ ! -f /config/custom.cnf ]]; then
14+
cp /defaults/my.cnf /config/custom.cnf
15+
fi
16+
17+
if [[ ! -L /etc/my.cnf.d/custom.cnf && -f /etc/my.cnf.d/custom.cnf ]]; then
18+
rm /etc/my.cnf.d/custom.cnf
19+
fi
20+
21+
if [[ ! -L /etc/my.cnf.d/custom.cnf ]]; then
22+
ln -s /config/custom.cnf /etc/my.cnf.d/custom.cnf
23+
fi
24+
25+
# set permissions
26+
chmod -R 777 \
27+
/var/run/mysqld
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/init-mariadb-config/run

root/etc/s6-overlay/s6-rc.d/init-mariadb-initdb/dependencies.d/init-mariadb-config

Whitespace-only changes.

root/etc/cont-init.d/40-initialise-db renamed to root/etc/s6-overlay/s6-rc.d/init-mariadb-initdb/run

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ start_mysql(){
1414

1515
# test for existence of mysql folder in datadir and start initialise if not present
1616
# BEGIN: No indentation due to heredocs
17-
if [ ! -d "${DATADIR}/mysql" ]; then
17+
if [[ ! -d "${DATADIR}/mysql" ]]; then
1818

1919
# load env file if it exists
20-
if [ -f "/config/env" ]; then
20+
if [[ -f "/config/env" ]]; then
2121
source /config/env
2222
fi
2323

@@ -31,33 +31,32 @@ EOSQL
3131
NOPASS_SET=$(mktemp)
3232
cat > "${NOPASS_SET}" <<-EOFPASS
3333
#################################################################
34-
# No root password or too short a password ,min of 4 characters #
35-
# No root password will be set, this is not a good thing #
36-
# You shoud set one after initialisation with the command #
37-
# mysqladmin -u root password <PASSWORD> #
34+
# No root password or too short a password, min of 4 characters #
35+
# No root password will be set, this is not a good thing #
36+
# You shoud set one after initialisation with the command #
37+
# mysqladmin -u root password <PASSWORD> #
3838
#################################################################
3939
EOFPASS
4040

4141
# test for empty password variable, if it's set to 0 or less than 4 characters
42-
if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
42+
if [[ -z "${MYSQL_ROOT_PASSWORD}" ]]; then
4343
TEST_LEN="0"
4444
else
4545
TEST_LEN=${#MYSQL_ROOT_PASSWORD}
4646
fi
47-
MYSQL_ROOT_PASSWORD=$(sed -E 's/('\'')/\\\1/g' <<< "${MYSQL_ROOT_PASSWORD}")
48-
if [ "${TEST_LEN}" -lt "4" ]; then
47+
48+
if [[ "${TEST_LEN}" -lt "4" ]]; then
4949
MYSQL_PASS="CREATE USER 'root'@'%' IDENTIFIED BY '' ;"
5050
else
5151
MYSQL_PASS="CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;"
5252
fi
5353

5454
# Make sure all user and database settings are set and pass is more than 4 characters
5555
# At the end change to default database created with environment variables to run init and remote scripts there
56-
if [ "${MYSQL_USER+x}" ] && \
57-
[ "${MYSQL_DATABASE+x}" ] && \
58-
[ "${MYSQL_PASSWORD+x}" ] && \
59-
[ "${#MYSQL_PASSWORD}" -gt "3" ]; then
60-
MYSQL_PASSWORD=$(sed -E 's/('\'')/\\\1/g' <<< "${MYSQL_PASSWORD}")
56+
if [[ "${MYSQL_USER+x}" ]] && \
57+
[[ "${MYSQL_DATABASE+x}" ]] && \
58+
[[ "${MYSQL_PASSWORD+x}" ]] && \
59+
[[ "${#MYSQL_PASSWORD}" -gt "3" ]]; then
6160
read -r -d '' MYSQL_DB_SETUP << EOM
6261
CREATE DATABASE \`${MYSQL_DATABASE}\`;
6362
CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';
@@ -77,18 +76,18 @@ EONEWSQL
7776
echo "Setting Up Initial Databases"
7877

7978
# add all sql from a user defined directory on first init
80-
if [ -e "/config/initdb.d" ] && [ -n "$(/bin/ls -A /config/initdb.d/*.sql 2>/dev/null)" ]; then
79+
if [[ -e "/config/initdb.d" ]] && [[ -n "$(/bin/ls -A /config/initdb.d/*.sql 2>/dev/null)" ]]; then
8180
cat /config/initdb.d/*.sql >> "${tempSqlFile}"
8281
fi
8382

8483
chown -R abc:abc "${tempSqlFile}"
8584

8685

8786
# ingest remote sql if REMOTE_SQL is set
88-
if [ -n "${REMOTE_SQL+set}" ]; then
87+
if [[ -n "${REMOTE_SQL+set}" ]]; then
8988
IFS=, read -ra URLS <<< "${REMOTE_SQL}"
9089
for URL in "${URLS[@]}"; do
91-
if [ "$(curl -I -sL -w "%{http_code}" "${URL}" -o /dev/null)" == 200 ]; then
90+
if [[ "$(curl -I -sL -w "%{http_code}" "${URL}" -o /dev/null)" == 200 ]]; then
9291
curl -sL "${URL}" >> "${tempSqlFile}"
9392
fi
9493
done
@@ -109,7 +108,7 @@ wait "${pid}"
109108
echo "Database Setup Completed"
110109

111110
# display a message about password if not set or too short
112-
if [ "${TEST_LEN}" -lt "4" ]; then
111+
if [[ "${TEST_LEN}" -lt "4" ]]; then
113112
printf '\n\n\n%s\n\n\n' "$(<"${NOPASS_SET}")"
114113
sleep 5s
115114
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/init-mariadb-initdb/run

root/etc/s6-overlay/s6-rc.d/svc-mariadb/dependencies.d/init-services

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
echo "Caught SIGTERM signal!"
4+
5+
kill -TERM "$(cat /var/run/mysqld/mysqld.pid)" 2>/dev/null
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 3306" \
4+
s6-setuidgid abc \
5+
/usr/bin/mariadbd-safe \
6+
--datadir="${DATADIR}" \
7+
--pid-file=/var/run/mysqld/mysqld.pid \
8+
--user=abc &
9+
10+
wait
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
longrun

root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mariadb-config

Whitespace-only changes.

root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mariadb-initdb

Whitespace-only changes.

root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-mariadb

Whitespace-only changes.

root/etc/services.d/mariadb/run

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)