From c2ae0e92c39e7c849419d5b565b457238dc1efa7 Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Thu, 12 Jan 2023 15:58:11 +0100 Subject: [PATCH 1/2] Add MySQL config (#2) --- mysql/build-context/Dockerfile | 14 +++++++++ mysql/build-context/docker-data/.gitkeep | 0 mysql/build-context/extras/.gitkeep | 0 mysql/common-settings.yml | 11 +++++++ mysql/docker-compose.override.yml | 9 ++++++ mysql/docker-compose.yml | 27 +++++++++++++++++ ...ully.qualified.domain.name_ctx.env.example | 29 +++++++++++++++++++ 7 files changed, 90 insertions(+) create mode 100644 mysql/build-context/Dockerfile create mode 100644 mysql/build-context/docker-data/.gitkeep create mode 100644 mysql/build-context/extras/.gitkeep create mode 100644 mysql/common-settings.yml create mode 100644 mysql/docker-compose.override.yml create mode 100644 mysql/docker-compose.yml create mode 100644 mysql/env/fully.qualified.domain.name_ctx.env.example diff --git a/mysql/build-context/Dockerfile b/mysql/build-context/Dockerfile new file mode 100644 index 0000000..3b73c34 --- /dev/null +++ b/mysql/build-context/Dockerfile @@ -0,0 +1,14 @@ +# For the remainder of this Dockerfile EXAMPLE_ARG_FOR_DOCKERFILE will be +# available with a value of 'must_be_available_in_dockerfile', check out the env +# file at 'env/fully.qualified.domain.name.example' for reference. +# ARG EXAMPLE_ARG_FOR_DOCKERFILE + +# Another env var, this one's needed in the example build step below: +# ARG MYSQL_VERSION + +# Example +# FROM "mysql:${MYSQL_VERSION}" +# RUN apt-get update && \ +# apt-get -y install \ +# somepackage-6.q16-6-extra && \ +# rm -rf /var/lib/apt/lists/* diff --git a/mysql/build-context/docker-data/.gitkeep b/mysql/build-context/docker-data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mysql/build-context/extras/.gitkeep b/mysql/build-context/extras/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mysql/common-settings.yml b/mysql/common-settings.yml new file mode 100644 index 0000000..9fd26d7 --- /dev/null +++ b/mysql/common-settings.yml @@ -0,0 +1,11 @@ +services: + common-settings: + environment: + TZ: "${TIMEZONE:-Etc/UTC}" + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "10" + compress: "true" + restart: "${RESTARTPOLICY:-unless-stopped}" diff --git a/mysql/docker-compose.override.yml b/mysql/docker-compose.override.yml new file mode 100644 index 0000000..4add0f9 --- /dev/null +++ b/mysql/docker-compose.override.yml @@ -0,0 +1,9 @@ +services: + mysql-build: + image: "mysql/mysql-server:${MYSQL_VERSION}" + profiles: ["build"] + build: + context: "build-context/mysql" + dockerfile: Dockerfile + args: + MYSQL_VERSION: "${MYSQL_VERSION}" diff --git a/mysql/docker-compose.yml b/mysql/docker-compose.yml new file mode 100644 index 0000000..e2a5524 --- /dev/null +++ b/mysql/docker-compose.yml @@ -0,0 +1,27 @@ +services: + mysql: + image: "mysql/mysql-server:${MYSQL_VERSION}" + container_name: "mysql-${CONTEXT}" + networks: + mysql-default: + extends: + file: common-settings.yml + service: common-settings + ports: + - 3306:3306 + volumes: + - /opt/docker-data/mysql-${CONTEXT}/data:/var/lib/mysql + - /opt/docker-data/mysql-${CONTEXT}/config/my.cnf:/etc/my.cnf + environment: + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} +networks: + mysql-default: + name: mysql-${CONTEXT} + driver: bridge + driver_opts: + com.docker.network.enable_ipv6: "false" + ipam: + driver: default + config: + - subnet: 172.16.7.0/24 diff --git a/mysql/env/fully.qualified.domain.name_ctx.env.example b/mysql/env/fully.qualified.domain.name_ctx.env.example new file mode 100644 index 0000000..a114e54 --- /dev/null +++ b/mysql/env/fully.qualified.domain.name_ctx.env.example @@ -0,0 +1,29 @@ +CONTEXT=loft_ent + + + +# Set something sensible here and uncomment +# --- +# MYSQL_VERSION=x.y.z + + + +# A ${LOCATION} var is usually not needed. It may be helpful when a ${CONTEXT} +# extends over more than one location e.g. to bind-mount location-specific +# config files or certificates into a container. +# --- +# LOCATION= + + + +# Feel free to leave defaults. They apply while these vars are commented out +# --- +# RESTARTPOLICY=unless-stopped +# TIMEZONE=Etc/UTC + + + +# See 'docker-compose.override.yml' for how to make a variable available in +# a Dockerfile +# --- +# EXAMPLE_ARG_FROM_ENV_FILE=must_be_available_in_dockerfile -- 2.47.2 From 324b97ebb8be0e89e366824dad0694d6b766532f Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Thu, 12 Jan 2023 16:02:29 +0100 Subject: [PATCH 2/2] Add .gitignore files for production docker compose env files (#2) --- mysql/env/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 mysql/env/.gitignore diff --git a/mysql/env/.gitignore b/mysql/env/.gitignore new file mode 100644 index 0000000..03bd412 --- /dev/null +++ b/mysql/env/.gitignore @@ -0,0 +1 @@ +*.env -- 2.47.2