2024-11-10 23:29:56 +01:00
|
|
|
# Rx3-Docker/Server Docker Image
|
2024-08-25 18:17:03 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2024-11-11 22:56:40 +01:00
|
|
|
ARG IMG_FROM_URL="rx3-docker/base:latest"
|
|
|
|
|
|
|
|
FROM ${IMG_FROM_URL}
|
|
|
|
|
2024-08-25 18:17:03 +02:00
|
|
|
ARG IMG_NAME
|
2024-11-10 23:29:56 +01:00
|
|
|
ARG IMG_NAME_FULL
|
2024-08-25 18:17:03 +02:00
|
|
|
ARG IMG_VERSION
|
|
|
|
ARG IMG_MAINTAINER
|
2024-11-10 23:29:56 +01:00
|
|
|
|
|
|
|
LABEL org.rx3.${IMG_NAME}.name=${IMG_NAME_FULL}
|
2024-08-27 00:33:11 +02:00
|
|
|
LABEL org.rx3.${IMG_NAME}.version=${IMG_VERSION}
|
|
|
|
LABEL org.rx3.${IMG_NAME}.maintainer=${IMG_MAINTAINER}
|
2024-08-25 18:17:03 +02:00
|
|
|
LABEL maintainer=${IMG_MAINTAINER}
|
|
|
|
|
2024-11-11 22:56:40 +01:00
|
|
|
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
|
|
|
|
|
2024-08-25 18:17:03 +02:00
|
|
|
|
2024-08-26 21:21:07 +02:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
ARG INIT_SHELL='#!/bin/bash \n\
|
|
|
|
\n\
|
2024-11-11 22:56:40 +01:00
|
|
|
function log() { echo "$(date --rfc-3339=ns) Init: $*" | tee -a '${SERVER_LOG_INIT_FILE}'; } \n\
|
2024-08-26 21:21:07 +02:00
|
|
|
\n\
|
|
|
|
log "Starting" \n\
|
|
|
|
\n\
|
|
|
|
for pgm in /etc/rcD.d/* \n\
|
|
|
|
do \n\
|
|
|
|
if [[ -r ${pgm} ]] \n\
|
|
|
|
then \n\
|
|
|
|
if [[ ${pgm##*/} == S99* ]] \n\
|
|
|
|
then \n\
|
|
|
|
log "Executing: [${pgm##*/}]" \n\
|
|
|
|
log "Completed" \n\
|
|
|
|
exec ${pgm} \n\
|
|
|
|
else \n\
|
|
|
|
log "Calling: [${pgm##*/}]" \n\
|
|
|
|
${pgm} \n\
|
|
|
|
fi \n\
|
|
|
|
fi \n\
|
|
|
|
done'
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-11-10 23:29:56 +01:00
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
ARG SUPERVISORD='#!/bin/bash \n\
|
|
|
|
\n\
|
|
|
|
exec supervisord -c /etc/supervisord.conf'
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
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'
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-08-26 21:21:07 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
ARG SUPERVISORD_INI='[inet_http_server] \n\
|
2024-11-11 22:56:40 +01:00
|
|
|
port=*:'${SERVER_PORT_SV_INT}' \n\
|
2024-08-26 21:21:07 +02:00
|
|
|
\n\
|
|
|
|
[supervisord] \n\
|
|
|
|
nodaemon=true \n\
|
2024-11-11 22:56:40 +01:00
|
|
|
childlogdir='${SERVER_LOG_SV_DIR}' \n\
|
2024-08-26 21:21:07 +02:00
|
|
|
user=root'
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
ARG CROND_INI='[program:crond] \n\
|
|
|
|
command=crond -n'
|
|
|
|
#---------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-28 16:14:02 +02:00
|
|
|
RUN urpmi --force supervisor \
|
2024-11-11 22:56:40 +01:00
|
|
|
&& echo -e "${INIT_SHELL}" | sed -e "s/\`/'/g" -e 's/ *$//' > /usr/local/sbin/init.sh \
|
2024-08-28 16:14:02 +02:00
|
|
|
&& chmod a+x /usr/local/sbin/init.sh \
|
|
|
|
&& mkdir /etc/rc.d/rcD.d \
|
|
|
|
&& ln -s /etc/rc.d/rcD.d /etc \
|
2024-11-11 22:56:40 +01:00
|
|
|
&& mkdir "${SERVER_LOG_INIT_DIR}" \
|
2024-11-10 23:29:56 +01:00
|
|
|
&& 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 \
|
2024-08-28 16:14:02 +02:00
|
|
|
&& chmod a+x /etc/init.d/supervisord \
|
2024-11-10 23:29:56 +01:00
|
|
|
&& ln -s /etc/init.d/crond /etc/rcD.d/S60crond \
|
|
|
|
&& 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
|
2024-11-11 22:56:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
VOLUME ${SERVER_LOG_INIT_DIR}
|
|
|
|
VOLUME ${SERVER_LOG_SV_DIR}
|
2024-08-26 21:21:07 +02:00
|
|
|
|
2024-11-10 23:29:56 +01:00
|
|
|
EXPOSE ${SERVER_PORT_SV_INT}
|
2024-08-26 21:21:07 +02:00
|
|
|
|
2024-08-25 18:17:03 +02:00
|
|
|
CMD []
|
2024-08-26 21:21:07 +02:00
|
|
|
ENTRYPOINT ["init.sh"]
|
|
|
|
|