From aa2c81cca915a8749871e5f7ee44d05737c1f835 Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Mon, 2 Dec 2024 16:51:20 +0100 Subject: [PATCH] - Move & Rename repo from Rx3/Ampache-MGA9 to Rx3-Docker/Ampache, - New version naming standard, - Now use docker_tools for .env building, - Now use rx3-docker/php-apache:1.4.0-mga9 & rx3-docker/mariadb-1.1.0-mga9 images, - Add /var/log/init*, /var/log/supervisor* volumes, - Fix crontab: user ampache user instead of root and add it to git, - Fix database restart in compose file, - Add database healthcheck & webapp service depencies. --- Dockerfile | 20 ++- ReadMe.txt | 7 +- ReleaseNotes.txt | 7 +- compose.yaml | 120 ++++++++++-------- env.dist | 86 +++++++------ .../.gitignore | 0 .../.gitignore | 0 var/lib/{ => mysql-database}/.gitignore | 0 .../.gitignore | 0 .../.gitignore | 0 var/log/httpd-webapp-external/.gitignore | 4 + var/log/httpd-webapp-internal/.gitignore | 4 + var/log/init-database/.gitignore | 4 + var/log/init-webapp-external/.gitignore | 4 + var/log/init-webapp-internal/.gitignore | 4 + var/log/mysql-database/.gitignore | 4 + var/log/supervisor-database/.gitignore | 4 + var/log/supervisor-webapp-external/.gitignore | 4 + var/log/supervisor-webapp-internal/.gitignore | 4 + 19 files changed, 170 insertions(+), 106 deletions(-) rename etc/{ampache-external => ampache-webapp-external}/.gitignore (100%) rename etc/{ampache-internal => ampache-webapp-internal}/.gitignore (100%) rename var/lib/{ => mysql-database}/.gitignore (100%) rename var/log/{ampache-external => ampache-webapp-external}/.gitignore (100%) rename var/log/{ampache-internal => ampache-webapp-internal}/.gitignore (100%) create mode 100644 var/log/httpd-webapp-external/.gitignore create mode 100644 var/log/httpd-webapp-internal/.gitignore create mode 100644 var/log/init-database/.gitignore create mode 100644 var/log/init-webapp-external/.gitignore create mode 100644 var/log/init-webapp-internal/.gitignore create mode 100644 var/log/mysql-database/.gitignore create mode 100644 var/log/supervisor-database/.gitignore create mode 100644 var/log/supervisor-webapp-external/.gitignore create mode 100644 var/log/supervisor-webapp-internal/.gitignore diff --git a/Dockerfile b/Dockerfile index e67f806..dbaf3ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,24 @@ -# +# Rx3-Docker/Ampache Dockerfile #------------------------------------------------------------------------------- -ARG IMG_URL_PREFIX="rx3" +ARG IMG_FROM_URL="rx3-docker/php-apache:latest" -FROM ${IMG_URL_PREFIX}/php-apache-mga9:1.3.3 +FROM ${IMG_FROM_URL} ARG IMG_NAME -ARG IMG_FULL_NAME +ARG IMG_NAME_FULL ARG IMG_VERSION ARG IMG_MAINTAINER +LABEL org.rx3.${IMG_NAME}.name=${IMG_NAME_FULL} +LABEL org.rx3.${IMG_NAME}.version=${IMG_VERSION} +LABEL org.rx3.${IMG_NAME}.maintainer=${IMG_MAINTAINER} +LABEL maintainer=${IMG_MAINTAINER} + ARG AMPACHE_VERSION=6.6.0 ENV DISABLE_INOTIFYWAIT_CLEAN=0 -LABEL org.rx3.${IMG_NAME}.name=${IMG_FULL_NAME} -LABEL org.rx3.${IMG_NAME}.version=${IMG_VERSION} -LABEL org.rx3.${IMG_NAME}.maintainer=${IMG_MAINTAINER} -LABEL maintainer=${IMG_MAINTAINER} - #--------------------------------------------------------------------------------------------------- @@ -61,5 +61,3 @@ VOLUME ["/var/www/html/config"] VOLUME ["/var/log/ampache"] VOLUME ["/media"] - -EXPOSE 80 diff --git a/ReadMe.txt b/ReadMe.txt index 5934ffd..df304f0 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,11 +1,12 @@ -Welcome to Rx3/Ampache-Mga9 docker image! +Welcome to Rx3-Docker/Ampache docker image! -This is project aims to build a Ampache + Mageia 9 docker image. +This is project aims to build an Ampache docker image. Features: - - Based on rx3/php-apache-mga9:1.3.3 & rx3/mariadb-mga9:1.0.2 images, + - Using Ampache V 6.6.0, + - Based on rx3-docker/php-apache:1.4.0-mga9 & rx3-docker/mariadb:1.1.0 images, - Support mysql & external pwauth authentication. diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 0f8d1c1..6b8600b 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,7 +1,12 @@ ------------------------------------------------------------------------------------------------------------------------------------ -Rx3/Ampache-Mga9 V 1.2.3 - A. GIBERT - 2024/10/xx +Rx3-Docker/Ampache V 1.3.0 - A. GIBERT - 2024/12/02 ------------------------------------------------------------------------------------------------------------------------------------ +- Move & Rename repo from Rx3/Ampache-MGA9 to Rx3-Docker/Ampache, +- New version naming standard, +- Now use docker_tools for .env building, +- Now use rx3-docker/php-apache:1.4.0-mga9 & rx3-docker/mariadb-1.1.0-mga9 images, +- Add /var/log/init*, /var/log/supervisor* volumes, - Fix crontab: user ampache user instead of root and add it to git, - Fix database restart in compose file, - Add database healthcheck & webapp service depencies. diff --git a/compose.yaml b/compose.yaml index 34283d2..9bcf2c9 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,73 +1,82 @@ -# Rx3 Ampache Mageia-9 Docker Image +# Rx3-Docker/Ampache Docker Image #------------------------------------------------------------------------------- -name: ${APPL_NAME} +name: ${HOST_NAME_PREFIX} services: database: - container_name: ${DATABASE_CONT_NAME} + container_name: ${DB_HOST_NAME} + hostname: ${DB_HOST_NAME} - image: ${DATABASE_IMG} - - restart: unless-stopped + image: ${DB_IMG_URL} + + restart: unless-stopped environment: - MARIADB_UID: ${MARIADB_UID} - MARIADB_GID: ${MARIADB_GID} - MARIADB_ROOT_HOST: ${MARIADB_ROOT_HOST} - MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD} - MARIADB_DATABASE: ${MARIADB_DATABASE} - MARIADB_USER: ${MARIADB_USER} - MARIADB_PASSWORD: ${MARIADB_PASSWORD} + MARIADB_UID: ${DB_USER_ID} + MARIADB_GID: ${DB_GROUP_ID} + MARIADB_ROOT_HOST: ${DB_ROOT_HOST} + MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} + MARIADB_DATABASE: ${DB_DB_NAME} + MARIADB_USER: ${DB_DB_USER} + MARIADB_PASSWORD: ${DB_DB_PASSWORD} healthcheck: - test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p${MARIADB_ROOT_PASSWORD}' ] - interval: 10s - timeout: 3s - retries: 3 + test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p${DB_ROOT_PASSWORD}' ] + interval: 10s + timeout: 3s + retries: 3 volumes: - - ./var/lib/mysql:/var/lib/mysql + - ./${DB_LIB_EXT}:${DB_LIB_INT} + - ./${DB_LOG_INIT_EXT}:${DB_LOG_INIT_INT} + - ./${DB_LOG_SV_EXT}:${DB_LOG_SV_INT} + - ./${DB_LOG_MAIN_EXT}:${DB_LOG_MAIN_INT} networks: - appl ports: - - "127.0.0.1:${DATABASE_SV_PORT}:9001" - - "127.0.0.1:${DATABASE_PORT}:3306" + - "127.0.0.1:${DB_PORT_SV_EXT}:${DB_PORT_SV_INT}" + - "127.0.0.1:${DB_PORT_MAIN_EXT}:${DB_PORT_MAIN_INT}" webapp-internal: - container_name: ${WEBAPP_INT_CONT_NAME} + container_name: ${WAI_HOST_NAME} + hostname: ${WAI_HOST_NAME} - image: ${WEBAPP_IMG} + image: ${WAI_IMG_URL} build: - context: . + context: . args: - - IMG_NAME=${APPL_NAME} - - IMG_FULL_NAME=${APPL_FULL_NAME} - - IMG_VERSION=${APPL_VERSION} - - IMG_MAINTAINER=${APPL_MAINTAINER} - - IMG_URL_PREFIX=${APPL_URL_PREFIX} + IMG_NAME: ${WAI_IMG_URL} + IMG_NAME_FULL: ${WAI_IMG_NAME_FULL} + IMG_VERSION: ${WAI_IMG_VERSION} + IMG_MAINTAINER: ${APPL_MAINTAINER} + IMG_FROM_URL: ${WAI_IMG_FROM_URL} - restart: unless-stopped + restart: unless-stopped depends_on: database: - condition: service_healthy + condition: service_healthy environment: - APACHE_UID: ${APACHE_UID} - APACHE_GID: ${APACHE_GID} - APACHE_DOC_ROOT: ${APACHE_DOC_ROOT} + APACHE_UID: ${WAI_USER_ID} + APACHE_GID: ${WAI_GROUP_ID} + APACHE_DOC_ROOT: ${APACHE_DOC_ROOT} volumes: - - ./etc/ampache-internal:/var/www/config - - ./var/log/ampache-internal:/var/log/ampache + - ./${WAI_LOG_INIT_EXT}:${WAI_LOG_INIT_INT} + - ./${WAI_LOG_SV_EXT}:${WAI_LOG_SV_INT} + - ./${WAI_LOG_MAIN_EXT}:${WAI_LOG_MAIN_INT} + + - ./etc/ampache-webapp-internal:/var/www/config - ./etc/cron.d/ampache:/etc/cron.d/ampache:ro - /etc/passwd:/etc/passwd:ro - /etc/group:/etc/group:ro - /etc/shadow:/etc/shadow:ro + - ${MUSIC_REPO}:/media/music - ${VIDEO_REPO}:/media/video @@ -75,30 +84,35 @@ services: - appl ports: - - "127.0.0.1:${WEBAPP_INT_SV_PORT}:9001" - - "127.0.0.1:${WEBAPP_INT_PORT}:80" + - "127.0.0.1:${WAI_PORT_SV_EXT}:${WAI_PORT_SV_INT}" + - "127.0.0.1:${WAI_PORT_MAIN_EXT}:${WAI_PORT_MAIN_INT}" webapp-external: - container_name: ${WEBAPP_EXT_CONT_NAME} - - image: ${WEBAPP_IMG} + container_name: ${WAE_HOST_NAME} + hostname: ${WAE_HOST_NAME} - restart: unless-stopped + image: ${WAE_IMG_URL} + + restart: unless-stopped depends_on: database: - condition: service_healthy + condition: service_healthy environment: - APACHE_UID: ${APACHE_UID} - APACHE_GID: ${APACHE_GID} - APACHE_DOC_ROOT: ${APACHE_DOC_ROOT} + APACHE_UID: ${WAE_USER_ID} + APACHE_GID: ${WAE_GROUP_ID} + APACHE_DOC_ROOT: ${APACHE_DOC_ROOT} volumes: - - ./etc/ampache-external:/var/www/config - - ./var/log/ampache-external:/var/log/ampache + - ./${WAE_LOG_INIT_EXT}:${WAE_LOG_INIT_INT} + - ./${WAE_LOG_SV_EXT}:${WAE_LOG_SV_INT} + - ./${WAE_LOG_MAIN_EXT}:${WAE_LOG_MAIN_INT} + + - ./etc/ampache-webapp-external:/var/www/config - /etc/passwd:/etc/passwd:ro - /etc/group:/etc/group:ro + - ${MUSIC_REPO}:/media/music - ${VIDEO_REPO}:/media/video @@ -106,16 +120,16 @@ services: - appl ports: - - "127.0.0.1:${WEBAPP_EXT_SV_PORT}:9001" - - "127.0.0.1:${WEBAPP_EXT_PORT}:80" + - "127.0.0.1:${WAE_PORT_SV_EXT}:${WAE_PORT_SV_INT}" + - "127.0.0.1:${WAE_PORT_MAIN_EXT}:${WAE_PORT_MAIN_INT}" networks: appl: - name: ${NETWORK_NAME} - driver: bridge + name: ${NETWORK_NAME} + driver: bridge driver_opts: com.docker.network.bridge.name: ${NETWORK_IF_NAME} ipam: config: - - subnet: 10.2.33.0/24 - gateway: 10.2.33.254 + - subnet: 10.2.33.0/24 + gateway: 10.2.33.254 diff --git a/env.dist b/env.dist index 0881db6..d3fb6c8 100644 --- a/env.dist +++ b/env.dist @@ -5,9 +5,10 @@ # Global Settings #------------------------------------------------------------------------------- -APPL_ORG="rx3" -APPL_REGISTRY="docker.xor.rx3:5000" -APPL_URL_PREFIX="${APPL_REGISTRY}/${APPL_ORG}" +ORG_NAME="rx3-docker" +ORG_REGISTRY="docker.xor.rx3:5000" + +ORG_URL_PREFIX="${ORG_REGISTRY}/${ORG_NAME}" @@ -15,11 +16,11 @@ APPL_URL_PREFIX="${APPL_REGISTRY}/${APPL_ORG}" # Image Settings #------------------------------------------------------------------------------- -APPL_NAME="ampache-mga9" -APPL_FULL_NAME="Rx3 Ampache Mageia-9 Docker Image" -APPL_SHORT_NAME="ampache" -APPL_VERSION="1.2.2" -APPL_URL="${APPL_URL_PREFIX}/${APPL_NAME}:${APPL_VERSION}" +APPL_NAME="ampache" +APPL_NAME_FULL="Ampache" +APPL_NAME_SHORT="ampache" +APPL_ORG="rx3-docker" +APPL_VERSION="1.3.0" APPL_MAINTAINER='"Arnaud G. GIBERT" ' @@ -45,17 +46,40 @@ VIDEO_REPO="./opt/video" if [[ "${APPL_ENV}" != "prd" ]] then APPL_SUFFIX="-${APPL_ENV}" - ENV_PORT_OFFSET=100 + PORT_ENV_OFFSET=100 else APPL_SUFFIX="" - ENV_PORT_OFFSET=0 + PORT_ENV_OFFSET=0 fi -CONT_NAME_PREFIX=${APPL_NAME/-mga9}${APPL_SUFFIX} +ORG_URL_PREFIX="${ORG_REGISTRY}/${ORG_NAME}" +APPL_URL_PREFIX="${ORG_REGISTRY}/${APPL_ORG}/${APPL_NAME_SHORT}" -SV_PORT_OFFSET=1000 -NETWORK_NAME=${CONT_NAME_PREFIX} -NETWORK_IF_NAME=br-${APPL_SHORT_NAME}-${APPL_ENV} +HOST_NAME_PREFIX=${APPL_NAME_SHORT}${APPL_SUFFIX} + +PORT_ENV_OFFSET=0 + +PORT_SV_INT=9001 +PORT_SV_OFFSET=1000 + +NETWORK_NAME=${HOST_NAME_PREFIX} +NETWORK_IF_NAME=br-${APPL_NAME_SHORT}-${APPL_ENV} + +DOCKER_TOOLS_DEBUG=FALSE +DOCKER_TOOLS_VOLUME=MERGED +#DOCKER_TOOLS_EXECPTION_LIBS="postgres:pgsql" + + + +#------------------+----------+--------------------------+--------------------+------------------+-------------------------------+-----------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+ +# | Variable | Service | Target Image | From Image | Module | Main Port | Admin Port | User | Group | +# | Prefix | Name | URL Prefix | Name | Name Full | Version | URL Prefix | Name | Version | Name | Version | Ext | Int | Ext | Int | Name / Id | Name / Id | +#------------------+----------+--------------------------+--------------------+------------------+-------------------------------+-----------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+ + +docker_service_add DB database ${ORG_URL_PREFIX} mariadb - 1.1.0-mga9 - - - mysql - 8006 3306 - - postgres postgres + +docker_service_add WAI webapp-internal ${ORG_URL_PREFIX} ampache "Rx3-Docker/Ampache" 1.3.0-mga9 ${ORG_URL_PREFIX} php-apache 1.4.0-mga9 - - 8085 80 - - apache apache +docker_service_add WAE webapp-external ${ORG_URL_PREFIX} ampache - 1.3.0-mga9 - - - - - 8086 80 - - apache apache @@ -63,18 +87,11 @@ NETWORK_IF_NAME=br-${APPL_SHORT_NAME}-${APPL_ENV} # Database #------------------------------------------------------------------------------- -DATABASE_IMG=${APPL_URL_PREFIX}/mariadb-mga9:1.0.2 -DATABASE_CONT_NAME="${CONT_NAME_PREFIX}-database" -DATABASE_PORT=$(( 8006 + ${ENV_PORT_OFFSET})) -DATABASE_SV_PORT=$(( ${DATABASE_PORT} + ${SV_PORT_OFFSET})) - -MARIADB_UID=983 -MARIADB_GID=981 -MARIADB_ROOT_HOST='%' # needs to be enclosed with quotes -MARIADB_ROOT_PASSWORD="mysqladmin" -MARIADB_DATABASE="ampache" -MARIADB_USER="ampache" -MARIADB_PASSWORD="ampacheadmin" +DB_ROOT_HOST='%' # needs to be enclosed with quotes +DB_ROOT_PASSWORD="mysqladmin" +DB_DB_NAME="ampache" +DB_DB_USER="ampache" +DB_DB_PASSWORD="ampacheadmin" @@ -82,16 +99,9 @@ MARIADB_PASSWORD="ampacheadmin" # WebApp #------------------------------------------------------------------------------- -WEBAPP_IMG=${APPL_URL} - -WEBAPP_INT_CONT_NAME="${CONT_NAME_PREFIX}-webapp-internal" -WEBAPP_INT_PORT=$(( 8085 + ${ENV_PORT_OFFSET})) -WEBAPP_INT_SV_PORT=$(( ${WEBAPP_INT_PORT} + ${SV_PORT_OFFSET})) - -WEBAPP_EXT_CONT_NAME="${CONT_NAME_PREFIX}-webapp-external" -WEBAPP_EXT_PORT=$(( ${WEBAPP_INT_PORT} + 1)) -WEBAPP_EXT_SV_PORT=$(( ${WEBAPP_EXT_PORT} + ${SV_PORT_OFFSET})) - -APACHE_UID=980 -APACHE_GID=977 APACHE_DOC_ROOT=/var/www/public + +WAI_LOG_MAIN_INT="/var/log/httpd" +WAI_LOG_MAIN_EXT="./var/log/httpd-webapp-internal" +WAE_LOG_MAIN_INT="/var/log/httpd" +WAE_LOG_MAIN_EXT="./var/log/httpd-webapp-external" diff --git a/etc/ampache-external/.gitignore b/etc/ampache-webapp-external/.gitignore similarity index 100% rename from etc/ampache-external/.gitignore rename to etc/ampache-webapp-external/.gitignore diff --git a/etc/ampache-internal/.gitignore b/etc/ampache-webapp-internal/.gitignore similarity index 100% rename from etc/ampache-internal/.gitignore rename to etc/ampache-webapp-internal/.gitignore diff --git a/var/lib/.gitignore b/var/lib/mysql-database/.gitignore similarity index 100% rename from var/lib/.gitignore rename to var/lib/mysql-database/.gitignore diff --git a/var/log/ampache-external/.gitignore b/var/log/ampache-webapp-external/.gitignore similarity index 100% rename from var/log/ampache-external/.gitignore rename to var/log/ampache-webapp-external/.gitignore diff --git a/var/log/ampache-internal/.gitignore b/var/log/ampache-webapp-internal/.gitignore similarity index 100% rename from var/log/ampache-internal/.gitignore rename to var/log/ampache-webapp-internal/.gitignore diff --git a/var/log/httpd-webapp-external/.gitignore b/var/log/httpd-webapp-external/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/httpd-webapp-external/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/httpd-webapp-internal/.gitignore b/var/log/httpd-webapp-internal/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/httpd-webapp-internal/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/init-database/.gitignore b/var/log/init-database/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/init-database/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/init-webapp-external/.gitignore b/var/log/init-webapp-external/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/init-webapp-external/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/init-webapp-internal/.gitignore b/var/log/init-webapp-internal/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/init-webapp-internal/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/mysql-database/.gitignore b/var/log/mysql-database/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/mysql-database/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/supervisor-database/.gitignore b/var/log/supervisor-database/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/supervisor-database/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/supervisor-webapp-external/.gitignore b/var/log/supervisor-webapp-external/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/supervisor-webapp-external/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/supervisor-webapp-internal/.gitignore b/var/log/supervisor-webapp-internal/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/supervisor-webapp-internal/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore