- Use now rx3-docker/base:1.3.3-mga9 image,

- Add dnsmasq to perform optional DNS forwarding,
- Add "urpmi.update -a" to force mirror sync.
This commit is contained in:
Arnaud G. GIBERT 2025-05-28 18:41:36 +02:00
parent c924a727e4
commit 373a9488f1
5 changed files with 140 additions and 65 deletions

View File

@ -23,76 +23,130 @@ ARG SERVER_LOG_INIT_FILE=${SERVER_LOG_INIT_DIR}/init.log
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
ARG INIT_SHELL='#!/bin/bash \n\ ARG INIT_SHELL='#!/bin/bash \n\
\n\ \n\
function log() { echo "$(date --rfc-3339=ns) Init: $*" | tee -a '${SERVER_LOG_INIT_FILE}'; } \n\ function log() { echo "$(date --rfc-3339=ns) Init: $*" | tee -a '${SERVER_LOG_INIT_FILE}'; } \n\
\n\ \n\
log "Starting" \n\ log "Starting" \n\
\n\ \n\
for pgm in /etc/rcD.d/* \n\ for pgm in /etc/rcD.d/* \n\
do \n\ do \n\
if [[ -r ${pgm} ]] \n\ if [[ -r ${pgm} ]] \n\
then \n\ then \n\
if [[ ${pgm##*/} == S99* ]] \n\ if [[ ${pgm##*/} == S99* ]] \n\
then \n\ then \n\
log "Executing: [${pgm##*/}]" \n\ log "Executing: [${pgm##*/}]" \n\
log "Completed" \n\ log "Completed" \n\
exec ${pgm} \n\ exec ${pgm} \n\
else \n\ else \n\
log "Calling: [${pgm##*/}]" \n\ log "Calling: [${pgm##*/}]" \n\
${pgm} \n\ ${pgm} \n\
fi \n\ fi \n\
fi \n\ fi \n\
done' done'
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
ARG SUPERVISORD='#!/bin/bash \n\ ARG DNSMASQ='#!/bin/bash \n\
\n\ \n\
exec supervisord -c /etc/supervisord.conf' if [[ "${SERVER_DNS_ENABLED}" != "TRUE" ]] \n\
#--------------------------------------------------------------------------------------------------- then \n\
mv /etc/supervisord.d/dnsmasq.ini /etc/supervisord.d/dnsmasq.ini.disabled \n\
#--------------------------------------------------------------------------------------------------- else \n\
ARG CROND='#!/bin/bash \n\ echo "" >> /etc/dnsmasq.conf \n\
\n\ echo "# Listen local address" >> /etc/dnsmasq.conf \n\
if [[ "${SERVER_CROND_ENABLED}" != "TRUE" ]] \n\ echo "interface=lo" >> /etc/dnsmasq.conf \n\
then \n\ echo "bind-interfaces" >> /etc/dnsmasq.conf \n\
mv /etc/supervisord.d/crond.ini /etc/supervisord.d/crond.ini.disabled \n\ echo "" >> /etc/dnsmasq.conf \n\
echo "port=53 # DNS only" >> /etc/dnsmasq.conf \n\
echo "no-dhcp-interface= # disables DHCPv4" >> /etc/dnsmasq.conf \n\
echo "" >> /etc/dnsmasq.conf \n\
echo "# Forward local domains" >> /etc/dnsmasq.conf \n\
\n\
for map in ${SERVER_DNS_MAP} \n\
do \n\
OIFS=$IFS \n\
IFS=":" \n\
set ${map} \n\
IFS=$OIFS \n\
\n\
domain="$1" \n\
server="$2" \n\
\n\
echo "server=/${domain}/${server}" >> /etc/dnsmasq.conf \n\
done \n\
\n\
echo "" >> /etc/dnsmasq.conf \n\
echo "# Forward all other queries to default server" >> /etc/dnsmasq.conf \n\
echo "server=${SERVER_DNS_DEFAULT}" >> /etc/dnsmasq.conf \n\
\n\
cp /etc/resolv.conf /etc/resolv.conf.old \n\
\n\
echo "# Generated by DNSMasq init script" > /etc/resolv.conf \n\
echo "" >> /etc/resolv.conf \n\
echo "nameserver 127.0.0.1" >> /etc/resolv.conf \n\
echo "search ${SERVER_DNS_SEARCH}" >> /etc/resolv.conf \n\
\n\
fi' fi'
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
ARG SUPERVISORD_INI='[inet_http_server] \n\ ARG SUPERVISORD='#!/bin/bash \n\
port=*:'${SERVER_PORT_SV_INT}' \n\ \n\
\n\ exec supervisord -c /etc/supervisord.conf'
[supervisord] \n\ #-----------------------------------------------------------------------------------------------------------------------
nodaemon=true \n\
childlogdir='${SERVER_LOG_SV_DIR}' \n\ #-----------------------------------------------------------------------------------------------------------------------
ARG CROND='#!/bin/bash \n\
\n\
if [[ "${SERVER_CROND_ENABLED}" != "TRUE" ]] \n\
then \n\
mv /etc/supervisord.d/crond.ini /etc/supervisord.d/crond.ini.disabled \n\
fi'
#-----------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------
ARG SUPERVISORD_INI='[inet_http_server] \n\
port=*:'${SERVER_PORT_SV_INT}' \n\
\n\
[supervisord] \n\
nodaemon=true \n\
childlogdir='${SERVER_LOG_SV_DIR}' \n\
user=root' user=root'
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
ARG CROND_INI='[program:crond] \n\ ARG CROND_INI='[program:crond] \n\
command=crond -n' command=crond -n'
#--------------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------
ARG DNSMASQ_INI='[program:dnsmasq] \n\
command=dnsmasq -k'
#-----------------------------------------------------------------------------------------------------------------------
RUN urpmi --force supervisor \ RUN urpmi.update -a \
&& echo -e "${INIT_SHELL}" | sed -e "s/\`/'/g" -e 's/ *$//' > /usr/local/sbin/init.sh \ && urpmi --force dnsmasq myip supervisor \
&& chmod a+x /usr/local/sbin/init.sh \ && echo -e "${INIT_SHELL}" | sed -e "s/\`/'/g" -e 's/ *$//' > /usr/local/sbin/init.sh \
&& mkdir /etc/rc.d/rcD.d \ && chmod a+x /usr/local/sbin/init.sh \
&& ln -s /etc/rc.d/rcD.d /etc \ && mkdir /etc/rc.d/rcD.d \
&& mkdir "${SERVER_LOG_INIT_DIR}" \ && ln -s /etc/rc.d/rcD.d /etc \
&& echo -e "${CROND}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/crond \ && mkdir "${SERVER_LOG_INIT_DIR}" \
&& echo -e "${SUPERVISORD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/supervisord \ && echo -e "${CROND}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/crond \
&& chmod a+x /etc/init.d/crond \ && echo -e "${DNSMASQ}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/dnsmasq \
&& chmod a+x /etc/init.d/supervisord \ && echo -e "${SUPERVISORD}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/init.d/supervisord \
&& ln -s /etc/init.d/crond /etc/rcD.d/S60crond \ && chmod a+x /etc/init.d/crond \
&& ln -s /etc/init.d/supervisord /etc/rcD.d/S99supervisord \ && chmod a+x /etc/init.d/dnsmasq \
&& echo -e "${CROND_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/crond.ini \ && chmod a+x /etc/init.d/supervisord \
&& echo -e "${SUPERVISORD_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/supervisord.ini && ln -s /etc/init.d/crond /etc/rcD.d/S60crond \
&& ln -s /etc/init.d/dnsmasq /etc/rcD.d/S65dnsmasq \
&& 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 "${DNSMASQ_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/dnsmasq.ini \
&& echo -e "${SUPERVISORD_INI}" | sed -e "s/\`/'/g" -e 's/ *$//' > /etc/supervisord.d/supervisord.ini
VOLUME ${SERVER_LOG_INIT_DIR} VOLUME ${SERVER_LOG_INIT_DIR}

View File

@ -5,10 +5,11 @@ Welcome to Rx3-Docker/Server docker image!
This project aims to build a Mageia server docker image to be used by other Rx3 packaging projects. This project aims to build a Mageia server docker image to be used by other Rx3 packaging projects.
Features: Features:
- Curtently based on rx3-docker/base:1.3.2-mga9 image, - Curtently based on rx3-docker/base:1.3.3-mga9 image,
- Init script calling in order sub scripts in /etc/init.d & /etc/rcD.d, - Init script calling in order sub scripts in /etc/init.d & /etc/rcD.d,
- supervisord managing services, - supervisord managing services,
- crond & logrotate configured & crond disabled by default, - crond & logrotate configured & crond disabled by default,
- DNS forwarding support with dnsmasq, disabled by default,
- Export init & supivisor log directories as volume. - Export init & supivisor log directories as volume.

View File

@ -1,8 +1,19 @@
------------------------------------------------------------------------------------------------------------------------------------
Rx3-Docker/Server V 1.2.3 - A. GIBERT - 2025/05/28
------------------------------------------------------------------------------------------------------------------------------------
- Use now rx3-docker/base:1.3.3-mga9 image,
- Add dnsmasq to perform optional DNS forwarding,
- Add "urpmi.update -a" to force mirror sync.
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------
Rx3-Docker/Server V 1.2.2 - A. GIBERT - 2025/04/13 Rx3-Docker/Server V 1.2.2 - A. GIBERT - 2025/04/13
------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------
- Use now rx3-docker/base:1.3.2-mga9 image. - Use now rx3-docker/base:1.3.2-mga9 image,
- Add "urpmi.update -a" to force mirror sync.

View File

@ -23,11 +23,15 @@ services:
SERVER_LOG_INIT_DIR: ${SERVER_LOG_INIT_DIR} SERVER_LOG_INIT_DIR: ${SERVER_LOG_INIT_DIR}
SERVER_LOG_SV_DIR: ${SERVER_LOG_SV_DIR} SERVER_LOG_SV_DIR: ${SERVER_LOG_SV_DIR}
SERVER_PORT_SV_INT: ${SERVER_PORT_SV_INT} SERVER_PORT_SV_INT: ${SERVER_PORT_SV_INT}
restart: unless-stopped restart: unless-stopped
environment: environment:
SERVER_CROND_ENABLED: ${SERVER_CROND_ENABLED} SERVER_CROND_ENABLED: ${SERVER_CROND_ENABLED}
SERVER_DNS_ENABLED: ${SERVER_DNS_ENABLED}
SERVER_DNS_DEFAULT: ${SERVER_DNS_DEFAULT}
SERVER_DNS_MAP: ${SERVER_DNS_MAP}
SERVER_DNS_SEARCH: ${SERVER_DNS_SEARCH}
volumes: volumes:
- ./var/log/init:${SERVER_LOG_INIT_DIR} - ./var/log/init:${SERVER_LOG_INIT_DIR}

View File

@ -18,13 +18,13 @@ ORG_URL_PREFIX="${ORG_REGISTRY}/${ORG_NAME}"
IMG_NAME="server" IMG_NAME="server"
IMG_NAME_FULL="Rx3-Docker/Server Docker Image" IMG_NAME_FULL="Rx3-Docker/Server Docker Image"
IMG_VERSION="1.2.2-mga9" IMG_VERSION="1.2.3-mga9"
IMG_MAINTAINER='"Arnaud G. GIBERT" <arnaud@rx3.net>' IMG_MAINTAINER='"Arnaud G. GIBERT" <arnaud@rx3.net>'
IMG_URL_PREFIX="${ORG_URL_PREFIX}" IMG_URL_PREFIX="${ORG_URL_PREFIX}"
IMG_URL="${IMG_URL_PREFIX}/${IMG_NAME}:${IMG_VERSION}" IMG_URL="${IMG_URL_PREFIX}/${IMG_NAME}:${IMG_VERSION}"
IMG_FROM_URL="${ORG_URL_PREFIX}/base:1.3.2-mga9" IMG_FROM_URL="${ORG_URL_PREFIX}/base:1.3.3-mga9"
@ -44,3 +44,8 @@ SERVER_LOG_INIT_DIR="/var/log/init"
SERVER_LOG_SV_DIR="/var/log/supervisor" SERVER_LOG_SV_DIR="/var/log/supervisor"
SERVER_CROND_ENABLED="FALSE" SERVER_CROND_ENABLED="FALSE"
SERVER_DNS_ENABLED="FALSE"
SERVER_DNS_DEFAULT="1.1.1.1"
SERVER_DNS_MAP="rx3:10.0.0.1 10.in-addr.arpa:10.0.0.1 168.192.in-addr.arpa:10.0.0.1"
SERVER_DNS_SEARCH="xor.rx3 and.rx3 not.rx3 mob.rx3 fix.rx3 rx3 rx3.net"