9 Commits

Author SHA1 Message Date
asif 2a5f5eb556 chore(ide): update docker build config 2022-02-19 07:54:04 -07:00
asif af07af2015 fix(Dockerfile): fix apk update command 2022-02-19 07:42:30 -07:00
asif 3e4ea22d92 feature(Dockerfile): update base image 2022-02-19 07:40:56 -07:00
asif 036cac764c feature(Dockerfile): add dockerignore 2022-02-19 07:34:40 -07:00
asif 442b3921b7 chore(ide): docker build configuration for Rider 2022-02-19 07:33:35 -07:00
asif f3627e136a fix(Dockerfile): fix image title 2022-02-19 07:32:17 -07:00
asif 8b3fc0886f refactor(Dockerfile): set minimum versions 2022-02-19 07:30:34 -07:00
asif b9d8fa20c2 refactor(Dockerfile): parameterize versions 2022-02-19 07:27:01 -07:00
asif 6bf6c283d7 refactor(Dockerfile): update labels
- modernize labels
- split into stable and frequently updated
- place frequently updated at end of file
- update versioning structure
2022-02-19 07:26:28 -07:00
15 changed files with 72 additions and 244 deletions
+6 -24
View File
@@ -20,7 +20,7 @@
*.PDF diff=astextplain *.PDF diff=astextplain
*.rtf diff=astextplain *.rtf diff=astextplain
*.RTF diff=astextplain *.RTF diff=astextplain
*.md text diff=markdown *.md text
*.tex text diff=tex *.tex text diff=tex
*.adoc text *.adoc text
*.textile text *.textile text
@@ -30,7 +30,6 @@
*.tsv text *.tsv text
*.txt text *.txt text
*.sql text *.sql text
*.ps1 text eol=crlf
# Graphics # Graphics
*.png binary *.png binary
@@ -54,23 +53,7 @@
# These are explicitly windows files and should use crlf # These are explicitly windows files and should use crlf
*.bat text eol=crlf *.bat text eol=crlf
*.cmd text eol=crlf *.cmd text eol=crlf
*.ps1 text eol=crlf
# web frontend stack -- force LF so SRI hashes are always correct
*.html text eol=lf
*.htm text eol=lf
*.css text eol=lf
*.min.css text eol=lf
*.js text eol=lf
*.min.js text eol=lf
*.php text eol=lf
# Visual Studio projects (Rider also)
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Serialisation # Serialisation
*.json text *.json text
@@ -93,8 +76,7 @@
# Exclude files from exporting # Exclude files from exporting
# #
.gitattributes export-ignore .gitattributes export-ignore
.gitignore export-ignore .gitignore export-ignore
.gitkeep export-ignore .gitkeep export-ignore
.idea export-ignore .vscode export-ignore
.vscode export-ignore
+10 -72
View File
@@ -1,73 +1,11 @@
### JetBrains template # VSCode files
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider .vscode/*
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 !.vscode/settings.json
!.vscode/tasks.json
# User-specific stuff !.vscode/launch.json
.idea/**/workspace.xml !.vscode/extensions.json
.idea/**/tasks.xml !.vscode/numbered-bookmarks.json
.idea/**/usage.statistics.xml *.code-workspace
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# Local History for Visual Studio Code
.history/
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitCommitMessageStorage">
<option name="messageStorage">
<MessageStorage />
</option>
</component>
</project>
@@ -11,10 +11,5 @@
<option name="enabled" value="true" /> <option name="enabled" value="true" />
</CommitMessageValidationOverride> </CommitMessageValidationOverride>
</option> </option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component> </component>
</project> </project>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="RIDER_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/../.." />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitCommitMessageStorage">
<option name="messageStorage">
<MessageStorage />
</option>
</component>
</project>
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxBlameSettings">
<option name="version" value="2" />
</component>
</project>
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
-8
View File
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="singleClickDiffPreview" value="1" />
<option name="unhandledExceptionsIgnoreList" value="1" />
<option name="vcsConfiguration" value="3" />
</component>
</project>
Generated
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CommitMessageInspectionProfile">
<profile version="1.0">
<inspection_tool class="BodyLimit" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SubjectBodySeparation" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SubjectLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="RIGHT_MARGIN" value="50" />
</inspection_tool>
</profile>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
+5 -14
View File
@@ -1,29 +1,21 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker"> <configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker LOCAL">
<deployment type="dockerfile"> <deployment type="dockerfile">
<settings> <settings>
<option name="imageTag" value="docker.asifbacchus.dev/mariadb/ab-mariadb-alpine:11.8.8-r0" /> <option name="imageTag" value="docker.asifbacchus.dev/mariadb/ab-mariadb-alpine:10.5.13" />
<option name="buildArgs"> <option name="buildArgs">
<list> <list>
<DockerEnvVarImpl>
<option name="name" value="ALPINE_VERSION" />
<option name="value" value="3.24" />
</DockerEnvVarImpl>
<DockerEnvVarImpl>
<option name="name" value="MARIADB_VERSION" />
<option name="value" value="11.8.8-r0" />
</DockerEnvVarImpl>
<DockerEnvVarImpl> <DockerEnvVarImpl>
<option name="name" value="INTERNAL_VERSION" /> <option name="name" value="INTERNAL_VERSION" />
<option name="value" value="2.3.1" /> <option name="value" value="1.2" />
</DockerEnvVarImpl> </DockerEnvVarImpl>
<DockerEnvVarImpl> <DockerEnvVarImpl>
<option name="name" value="GIT_COMMIT" /> <option name="name" value="GIT_COMMIT" />
<option name="value" value="64da9eea64" /> <option name="value" value="af07af2015" />
</DockerEnvVarImpl> </DockerEnvVarImpl>
<DockerEnvVarImpl> <DockerEnvVarImpl>
<option name="name" value="BUILD_DATE" /> <option name="name" value="BUILD_DATE" />
<option name="value" value="2026-09-12" /> <option name="value" value="2022-02-19" />
</DockerEnvVarImpl> </DockerEnvVarImpl>
</list> </list>
</option> </option>
@@ -31,7 +23,6 @@
<option name="sourceFilePath" value="Dockerfile" /> <option name="sourceFilePath" value="Dockerfile" />
</settings> </settings>
</deployment> </deployment>
<EXTENSION ID="com.jetbrains.rider.docker.debug" isFastModeEnabled="true" isSslEnabled="false" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
</component> </component>
+11 -21
View File
@@ -2,9 +2,9 @@
# mariadb running on Alpine Linux # mariadb running on Alpine Linux
# #
# build arguments # version arguments
ARG ALPINE_VERSION="3.24" ARG ALPINE_VERSION="3.14"
ARG MARIADB_VERSION="11.8.8-r0" ARG MARIADB_VERSION="10.5.13-r0"
FROM alpine:${ALPINE_VERSION} FROM alpine:${ALPINE_VERSION}
ARG ALPINE_VERSION ARG ALPINE_VERSION
@@ -22,11 +22,11 @@ LABEL org.opencontainer.image.url="https://git.asifbacchus.dev/ab-docker/ab-mari
LABEL org.opencontainer.image.vendor="Asif Bacchus <asif@asifbacchus.dev>" LABEL org.opencontainer.image.vendor="Asif Bacchus <asif@asifbacchus.dev>"
# install mariadb and turn on TCP connection in default config # install mariadb and turn on TCP connection in default config
RUN apk --update --no-cache add \ RUN apk --no-cache --update add \
tzdata \ tzdata \
mariadb>${MARIADB_VERSION} \ mariadb>${MARIADB_VERSION} \
mariadb-client>${MARIADB_VERSION} \ mariadb-client>${MARIADB_VERSION} \
mariadb-server-utils>${MARIADB_VERSION} \ mariadb-server-utils>${MARIADB_VERSION} \
&& apk --no-cache --update upgrade \ && apk --no-cache --update upgrade \
&& sed -i 's/skip-networking/skip-networking=0/' /etc/my.cnf.d/mariadb-server.cnf && sed -i 's/skip-networking/skip-networking=0/' /etc/my.cnf.d/mariadb-server.cnf
@@ -36,14 +36,6 @@ EXPOSE 3306
# create volume if user forgets # create volume if user forgets
VOLUME ["/var/lib/mysql"] VOLUME ["/var/lib/mysql"]
# basic healthcheck (service only)
HEALTHCHECK \
--interval=30s \
--timeout=5s \
--start-period=5s \
--retries=3 \
CMD mysqladmin ping --silent
# set environment variables # set environment variables
ENV TZ=Etc/UTC ENV TZ=Etc/UTC
ENV MYSQL_UID=8100 ENV MYSQL_UID=8100
@@ -60,14 +52,12 @@ ENV MYSQL_PASSWORD=''
COPY entrypoint.sh /usr/local/bin/entrypoint.sh COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN mkdir -p /docker-entrypoint-preinit.d \ RUN mkdir -p /docker-entrypoint-preinit.d \
&& mkdir -p /docker-entrypoint-initdb.d \ && mkdir -p /docker-entrypoint-initdb.d \
&& mkdir -p /docker-entrypoint-postinit.d \ && mkdir -p /docker-entrypoint-postinit.d
&& chmod +x /usr/local/bin/entrypoint.sh
# set entrypoint and default command # set entrypoint and default command
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
CMD [ "/usr/bin/mariadbd", "--user=mysql", "--console" ] CMD [ "/usr/bin/mysqld", "--user=mysql", "--console" ]
# add parameters, version and build date labels
# set build timestamp and version labels # set build timestamp and version labels
ARG INTERNAL_VERSION ARG INTERNAL_VERSION
ARG GIT_COMMIT ARG GIT_COMMIT
@@ -77,4 +67,4 @@ LABEL org.opencontainers.image.version="${INTERNAL_VERSION}-${MARIADB_VERSION}"
LABEL org.opencontainers.image.revision=${GIT_COMMIT} LABEL org.opencontainers.image.revision=${GIT_COMMIT}
LABEL org.opencontainers.image.created=${BUILD_DATE} LABEL org.opencontainers.image.created=${BUILD_DATE}
#EOF #EOF
+27 -34
View File
@@ -5,59 +5,58 @@ half the size of the official MariaDB container which runs on Ubuntu but still a
adding a few extra ;-) Note that this container is built against the Alpine EDGE repository for newer versions of adding a few extra ;-) Note that this container is built against the Alpine EDGE repository for newer versions of
mariaDB. mariaDB.
<!-- toc -->
- [Quick Start](#quick-start) - [Quick Start](#quick-start)
* [Pull the image](#pull-the-image) - [Pull the image](#pull-the-image)
* [Run the image](#run-the-image) - [Run the image](#run-the-image)
* [Create a database](#create-a-database) - [Create a database](#create-a-database)
+ [Root password](#root-password) - [Root password](#root-password)
+ [User password](#user-password) - [User password](#user-password)
- [Connecting as a client](#connecting-as-a-client) - [Connecting as a client](#connecting-as-a-client)
* [Direct-to-Container](#direct-to-container) - [Direct-to-Container](#direct-to-container)
* [Separate Container](#separate-container) - [Separate Container](#separate-container)
- [Shell Access](#shell-access) - [Shell Access](#shell-access)
- [Checking Logs](#checking-logs) - [Checking Logs](#checking-logs)
- [Environment Variables](#environment-variables) - [Environment Variables](#environment-variables)
* [System-related](#system-related) - [System-related](#system-related)
* [MariaDB configuration](#mariadb-configuration) - [MariaDB configuration](#mariadb-configuration)
* [Database configuration](#database-configuration) - [Database configuration](#database-configuration)
- [Root Account](#root-account) - [Root Account](#root-account)
* [Integrated-account](#integrated-account) - [Integrated-account](#integrated-account)
* [Root-at-any-host](#root-at-any-host) - [Root-at-any-host](#root-at-any-host)
- [Data Persistence](#data-persistence) - [Data Persistence](#data-persistence)
- [Data instantiation/import](#data-instantiationimport) - [Data instantiation/import](#data-instantiationimport)
* [Existing DB (mysql directory)](#existing-db-mysql-directory) - [Existing DB (mysql directory)](#existing-db-mysql-directory)
* [Instantiation](#instantiation) - [Instantiation](#instantiation)
- [Custom Scripts](#custom-scripts) - [Custom Scripts](#custom-scripts)
* [Entrypoint Task Order](#entrypoint-task-order) - [Entrypoint Task Order](#entrypoint-task-order)
- [Custom Configuration](#custom-configuration) - [Custom Configuration](#custom-configuration)
* [Command-line parameters](#command-line-parameters) - [Command-line parameters](#command-line-parameters)
* [Configuration file(s)](#configuration-files) - [Configuration file(s)](#configuration-files)
- [Database dumps](#database-dumps) - [Database dumps](#database-dumps)
- [Healthcheck](#healthcheck)
- [Source](#source) - [Source](#source)
- [Final Thoughts](#final-thoughts) - [Final Thoughts](#final-thoughts)
<!-- tocstop -->
## Quick Start ## Quick Start
### Pull the image ### Pull the image
The latest images are on my private docker registry. I also try to keep the ones on Dockerhub updated within a few The latest images are on my private docker registry but, I also try to keep the ones on Dockerhub updated within a few
days. days. If you need signed containers, you will have to use my private registry. As such, you have two choices:
```bash ```bash
# pull from my private repo # my private repo
docker pull docker.asifbacchus.dev/mariadb/ab-mariadb-alpine:latest docker pull asifbacchus/ab-mariadb-alpine:latest
```
# pull from dockerhub or
```bash
# dockerhub
docker pull asifbacchus/ab-mariadb-alpine:latest docker pull asifbacchus/ab-mariadb-alpine:latest
``` ```
The examples in this document will refer to dockerhub, but know that anywhere you The examples in this document will refer to dockerhub, but know that anywhere you
see `asifbacchus/ab-mariadb-alpine:tag` you can use `docker.asifbacchus.app/mariadb/ab-mariadb-alpine:tag` to use my see `asifbacchus/ab-mariadb-alpine:tag` you can use `docker.asifbacchus.app/mariadb/ab-mariadb-alpine` to use my
registry instead. registry instead.
### Run the image ### Run the image
@@ -341,12 +340,6 @@ docker exec -it container_name /bin/sh -c 'exec mysql' < /local/path/mySQLdumps/
docker exec -it container_name /bin/sh -c 'exec mysql -uroot -p"SuPeR$ecurEP@$$w0rd"' < /local/path/mySQLdumps/filename.sql docker exec -it container_name /bin/sh -c 'exec mysql -uroot -p"SuPeR$ecurEP@$$w0rd"' < /local/path/mySQLdumps/filename.sql
``` ```
## Healthcheck
Starting with internal version 2.0-10.6.4-r0, I've added a very basic healthcheck to the container. It simply checks that the mysqld daemon is running in the container and accepting connections. It **does NOT** check anything to do with the actual database. As such, you may want to override this with a more specific healthcheck for your particular use-case. If you just need to know MariaDB is actually running though, this healthcheck will work just fine.
If anyone has suggestions for a better healthcheck, PLEASE let me know!
## Source ## Source
The source for this container build (Dockerfile, entrypoint.sh) are available on my [private git repo](https://git.asifbacchus.app/ab-docker/mariadb-alpine) or on [GitHub](https://github.com/asifbacchus/ab-mariadb-alpine.git). Note that the newest versions will be on my repo and GitHub will be updated at most a few days later. Also, I'd prefer issues be filed on my repo, but I understand if GitHub is easier/more familiar for you. The source for this container build (Dockerfile, entrypoint.sh) are available on my [private git repo](https://git.asifbacchus.app/ab-docker/mariadb-alpine) or on [GitHub](https://github.com/asifbacchus/ab-mariadb-alpine.git). Note that the newest versions will be on my repo and GitHub will be updated at most a few days later. Also, I'd prefer issues be filed on my repo, but I understand if GitHub is easier/more familiar for you.
+6 -6
View File
@@ -86,7 +86,7 @@ if [ -z "$(ls -A /var/lib/mysql/ 2> /dev/null)" ]; then
# create system tables # create system tables
printf "DB-CREATE: Setting up mySQL system tables\n" printf "DB-CREATE: Setting up mySQL system tables\n"
if (! mariadb-install-db --user=mysql --ldata=/var/lib/mysql > /dev/null); then if (! mysql_install_db --user=mysql --ldata=/var/lib/mysql > /dev/null); then
exit 1 exit 1
fi fi
@@ -113,7 +113,7 @@ if [ -z "$(ls -A /var/lib/mysql/ 2> /dev/null)" ]; then
# execute statements against mariadb and cleanup # execute statements against mariadb and cleanup
printf "DB-CREATE: Bootstrapping mySQL database\n" printf "DB-CREATE: Bootstrapping mySQL database\n"
if (! mariadbd --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$sqlCmd"); then if (! mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$sqlCmd"); then
exit 1 exit 1
fi fi
shred -u "$sqlCmd" shred -u "$sqlCmd"
@@ -129,7 +129,7 @@ for f in /docker-entrypoint-initdb.d/*; do
*.sql) *.sql)
if [ -s "$f" ]; then if [ -s "$f" ]; then
printf "IMPORT-SQL: Importing %s\n" "$f" printf "IMPORT-SQL: Importing %s\n" "$f"
if (! mariadbd --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"); then if (! mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0 < "$f"); then
exit 3 exit 3
fi fi
printf "\n" printf "\n"
@@ -138,7 +138,7 @@ for f in /docker-entrypoint-initdb.d/*; do
*.sql.gz) *.sql.gz)
if [ -s "$f" ]; then if [ -s "$f" ]; then
printf "IMPORT-SQL: Importing %s\n" "$f" printf "IMPORT-SQL: Importing %s\n" "$f"
if (! gunzip -c "$f" | mariadbd --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0); then if (! gunzip -c "$f" | mysqld --user=mysql --bootstrap --verbose=0 --skip-name-resolve --skip-networking=0); then
exit 3 exit 3
fi fi
printf "\n" printf "\n"
@@ -168,8 +168,8 @@ fi
# process CMD sent to this container # process CMD sent to this container
case "$1" in case "$1" in
-*) -*)
# param starts with '-' --> assume mariadbd parameter(s) and append to CMD # param starts with '-' --> assume mysqld parameter(s) and append to CMD
set -- /usr/bin/mariadbd --user=mysql --console "$@" set -- /usr/bin/mysqld --user=mysql --console "$@"
printf "\nExecuting: %s\n" "$*" printf "\nExecuting: %s\n" "$*"
exec "$@" exec "$@"
;; ;;