diff --git a/Dockerfile b/Dockerfile index b7fba5d..6737cbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,32 @@ # Rx3-Docker/Server Docker Image #------------------------------------------------------------------------------- +ARG IMG_FROM_URL="rx3-docker/base:latest" + +FROM ${IMG_FROM_URL} + ARG IMG_NAME ARG IMG_NAME_FULL ARG IMG_VERSION ARG IMG_MAINTAINER -ARG IMG_FROM_URL - -ARG SERVER_PORT_SV_INT - -FROM ${IMG_FROM_URL} 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 SERVER_LOG_INIT_DIR +ARG SERVER_LOG_SV_DIR +ARG SERVER_PORT_SV_INT + +ARG SERVER_LOG_INIT_FILE=${SERVER_LOG_INIT_DIR}/init.log + #--------------------------------------------------------------------------------------------------- ARG INIT_SHELL='#!/bin/bash \n\ \n\ -function log() { echo "$(date --rfc-3339=ns) Init: $*" | tee -a /var/log/init.log; } \n\ +function log() { echo "$(date --rfc-3339=ns) Init: $*" | tee -a '${SERVER_LOG_INIT_FILE}'; } \n\ \n\ log "Starting" \n\ \n\ @@ -59,10 +64,11 @@ fi' #--------------------------------------------------------------------------------------------------- ARG SUPERVISORD_INI='[inet_http_server] \n\ -port=*:9001 \n\ +port=*:'${SERVER_PORT_SV_INT}' \n\ \n\ [supervisord] \n\ nodaemon=true \n\ +childlogdir='${SERVER_LOG_SV_DIR}' \n\ user=root' #--------------------------------------------------------------------------------------------------- @@ -74,10 +80,11 @@ command=crond -n' RUN urpmi --force supervisor \ - && echo -e "${INIT_SHELL}" | sed -e 's/ *$//' >/usr/local/sbin/init.sh \ + && echo -e "${INIT_SHELL}" | sed -e "s/\`/'/g" -e 's/ *$//' > /usr/local/sbin/init.sh \ && chmod a+x /usr/local/sbin/init.sh \ && mkdir /etc/rc.d/rcD.d \ && ln -s /etc/rc.d/rcD.d /etc \ + && mkdir "${SERVER_LOG_INIT_DIR}" \ && echo -e "${CROND}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/crond \ && echo -e "${SUPERVISORD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/supervisord \ && chmod a+x /etc/init.d/crond \ @@ -86,7 +93,10 @@ RUN urpmi --force supervisor && ln -s /etc/init.d/supervisord /etc/rcD.d/S99supervisord \ && echo -e "${CROND_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/crond.ini \ && echo -e "${SUPERVISORD_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/supervisord.ini - + + +VOLUME ${SERVER_LOG_INIT_DIR} +VOLUME ${SERVER_LOG_SV_DIR} EXPOSE ${SERVER_PORT_SV_INT} diff --git a/ReadMe.txt b/ReadMe.txt index 16df47e..8f250d5 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -8,8 +8,8 @@ Features: - Curtently based on rx3-docker/base:1.3.0-mga9 image, - Init script calling in order sub scripts in /etc/init.d & /etc/rcD.d, - supervisord managing services, - - crond & logrotate configured, - - crond disabled by default. + - crond & logrotate configured & crond disabled by default, + - Export init & supivisor log directories as volume. Enjoy it! diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index b4ec403..782b6fd 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -6,7 +6,8 @@ Rx3-Docker/Server V 1.2.0 - A. GIBERT - 2024/11/10 - New version naming standard, - Now use docker_tools for .env building, - Use now rx3-docker/base:1.3.0-mga9 image, -- Add crond enabling via SERVER_CROND_ENABLE environement variable. +- Add crond enabling via SERVER_CROND_ENABLE environement variable, +- Add /var/log/init & var/log/supervisor volumes. diff --git a/compose.yaml b/compose.yaml index 3c1072e..86a7a66 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,31 +1,37 @@ # Rx3-Docker/Server Docker Image #------------------------------------------------------------------------------- -name: ${IMG_NAME} +name: ${IMG_NAME} services: server: - container_name: ${IMG_NAME} - hostname: ${IMG_NAME} + container_name: ${IMG_NAME} + hostname: ${IMG_NAME} - image: ${IMG_URL} + image: ${IMG_URL} build: - context: . + context: . args: - - IMG_NAME=${IMG_NAME} - - IMG_NAME_FULL=${IMG_NAME_FULL} - - IMG_VERSION=${IMG_VERSION} - - IMG_MAINTAINER=${IMG_MAINTAINER} - - IMG_FROM_URL=${IMG_FROM_URL} + IMG_NAME: ${IMG_NAME} + IMG_NAME_FULL: ${IMG_NAME_FULL} + IMG_VERSION: ${IMG_VERSION} + IMG_MAINTAINER: ${IMG_MAINTAINER} + IMG_FROM_URL: ${IMG_FROM_URL} - - SERVER_PORT_SV_INT=${SERVER_PORT_SV_INT} + SERVER_LOG_INIT_DIR: ${SERVER_LOG_INIT_DIR} + SERVER_LOG_SV_DIR: ${SERVER_LOG_SV_DIR} + SERVER_PORT_SV_INT: ${SERVER_PORT_SV_INT} - restart: unless-stopped + restart: unless-stopped environment: - SERVER_CROND_ENABLED: ${SERVER_CROND_ENABLED} + SERVER_CROND_ENABLED: ${SERVER_CROND_ENABLED} + volumes: + - ./var/log/init:${SERVER_LOG_INIT_DIR} + - ./var/log/supervisor:${SERVER_LOG_SV_DIR} + ports: - "127.0.0.1:${SERVER_PORT_SV_EXT}:${SERVER_PORT_SV_INT}" diff --git a/env.dist b/env.dist index abf93db..fed59a2 100644 --- a/env.dist +++ b/env.dist @@ -40,4 +40,7 @@ SERVER_PORT_MAIN_EXT=$(( 8080 + ${ENV_PORT_OFFSET})) SERVER_PORT_SV_EXT=$(( ${SERVER_PORT_MAIN_EXT} + ${SV_PORT_OFFSET})) SERVER_PORT_SV_INT=9001 +SERVER_LOG_INIT_DIR="/var/log/init" +SERVER_LOG_SV_DIR="/var/log/supervisor" + SERVER_CROND_ENABLED="FALSE" diff --git a/var/log/init/.gitignore b/var/log/init/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/init/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/var/log/supervisor/.gitignore b/var/log/supervisor/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/var/log/supervisor/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore