IMAGE mariadb_10.4.15-210106
FROM alpine3.12_3.12.3-210106

RUN EOF
    # Create OS user (which will be picked up later by apk add)
    addgroup -S -g 3306 mysql
    adduser -S -u 3306 -h /var/lib/mysql -s /bin/false -g mysql -G mysql mysql

    # Install MariaDB
    apk --no-cache add mariadb mariadb-client

    # Create socket directory
    mkdir /run/mysqld
    chown mysql:mysql /run/mysqld
EOF

# Due to MySQL's socket authentication design the container init needs to be run as root
COPY image.d

CMD /bin/s6-svscan /etc/services.d
READY /usr/bin/test -e /run/mysqld/mysqld.sock
HALT SIGTERM