diff options
author | startxfr <clarue@startx.fr> | 2015-11-28 19:46:13 +0100 |
---|---|---|
committer | startxfr <clarue@startx.fr> | 2015-11-28 19:46:13 +0100 |
commit | 348568c89ae1ad19270e930c02a1492bc43e99b1 (patch) | |
tree | 97514774d5c27789d9383f5085103eb9775b6a52 /Services/apache | |
parent | 05c9aa4a4d3572168878bf0e81eeac724a95454d (diff) | |
download | phpmyadmin-348568c89ae1ad19270e930c02a1492bc43e99b1.tar.gz phpmyadmin-348568c89ae1ad19270e930c02a1492bc43e99b1.tar.bz2 phpmyadmin-348568c89ae1ad19270e930c02a1492bc43e99b1.tar.xz phpmyadmin-348568c89ae1ad19270e930c02a1492bc43e99b1.zip |
Adding display of OS flavour at startup and improving flexibility of services with env param
Diffstat (limited to 'Services/apache')
-rw-r--r-- | Services/apache/Dockerfile | 25 | ||||
-rw-r--r-- | Services/apache/docker-compose.yml | 15 | ||||
-rw-r--r-- | Services/apache/httpd.conf | 10 | ||||
-rw-r--r-- | Services/apache/run.sh | 15 | ||||
-rw-r--r-- | Services/apache/sx-httpd.sh | 34 |
5 files changed, 54 insertions, 45 deletions
diff --git a/Services/apache/Dockerfile b/Services/apache/Dockerfile index 72a8ee8..24dc063 100644 --- a/Services/apache/Dockerfile +++ b/Services/apache/Dockerfile @@ -4,20 +4,25 @@ MAINTAINER Christophe LARUE <dev@startx.fr> USER root RUN dnf -y install httpd && \ dnf clean all -COPY httpd.conf /etc/httpd/conf.d/app.conf +ENV HTTPDCONF=/etc/httpd/conf.d/app.conf \ + STARTUPLOG=/data/logs/httpd/startup.log \ + LOG_PATH=/data/logs/httpd \ + APP_PATH=/data/httpd +COPY httpd.conf $HTTPDCONF COPY *.sh /bin/ RUN chmod 775 /bin/run.sh /bin/sx-httpd.sh && \ - chmod ug+r /etc/httpd/conf.d/app.conf && \ + chmod ug+r $HTTPDCONF && \ rm -f /etc/httpd/conf.d/autoindex.conf && \ rm -f /etc/httpd/conf.d/welcome.conf && \ mkdir /data && \ - mkdir /data/www && \ - mkdir /data/logs -COPY ./ /data/www -RUN rm -f /data/www/Dockerfile /data/www/httpd.conf /data/www/run.sh /data/www/sx-httpd.sh && \ - chown -R apache:apache /data/www /data/logs + mkdir $APP_PATH && \ + mkdir /data/logs && \ + mkdir $LOG_PATH && \ + touch $STARTUPLOG +COPY ./ $APP_PATH +RUN rm -f $APP_PATH/Dockerfile $APP_PATH/httpd.conf $APP_PATH/run.sh $APP_PATH/sx-httpd.sh && \ + chown -R apache:apache $APP_PATH /data/logs -EXPOSE 80 -EXPOSE 443 -VOLUME ["/data/www","/data/logs"] +EXPOSE 80 443 +VOLUME [$APP_PATH,$LOG_PATH] CMD ["/bin/run.sh"]
\ No newline at end of file diff --git a/Services/apache/docker-compose.yml b/Services/apache/docker-compose.yml index e0a016f..205a439 100644 --- a/Services/apache/docker-compose.yml +++ b/Services/apache/docker-compose.yml @@ -1,16 +1,17 @@ -apache: +httpd: build: ./ -# image: sx-apache - container_name: "sx-apache" +# image: sx-httpd + container_name: "sx-httpd" mem_limit: 1g memswap_limit: 2g cpu_shares: 2 restart: "on-failure:2" environment: CONTAINER_TYPE: "service" - CONTAINER_SERVICE: "apache" - CONTAINER_INSTANCE: "sx-apache" + CONTAINER_SERVICE: "httpd" + CONTAINER_INSTANCE: "sx-httpd" SERVER_NAME: "localhost" + DOC_ROOT: "/data/httpd" volumes: - - "/tmp/container/logs:/data/logs" - - "/tmp/container/www:/data/www"
\ No newline at end of file + - "/tmp/container/logs/httpd:/data/logs/httpd" + - "/tmp/container/httpd:/data/httpd"
\ No newline at end of file diff --git a/Services/apache/httpd.conf b/Services/apache/httpd.conf index 8b04449..2f9d2fc 100644 --- a/Services/apache/httpd.conf +++ b/Services/apache/httpd.conf @@ -1,15 +1,17 @@ # # This file will be copied into /etc/httpd/conf.d/app.conf and loaded when httpd start # +DocumentRoot ${DOC_ROOT} +ServerName ${SERVER_NAME} ServerAdmin cl@startx.fr -ErrorLog "/data/logs/httpd_error.log" +ErrorLog ${LOG_PATH}/error.log <IfModule log_config_module> - CustomLog "/data/logs/httpd_access.log" combined + CustomLog ${LOG_PATH}/access.log combined </IfModule> -Alias / /data/www -<Directory "/data/www"> +Alias / ${APP_PATH} +<Directory ${APP_PATH}> AddDefaultCharset UTF-8 AllowOverride All Order Allow,Deny diff --git a/Services/apache/run.sh b/Services/apache/run.sh index a02537e..026c618 100644 --- a/Services/apache/run.sh +++ b/Services/apache/run.sh @@ -1,6 +1,4 @@ #!/bin/bash -export HTTPDCONF=/etc/httpd/conf.d/app.conf - source /bin/sx-lib.sh source /bin/sx-httpd.sh @@ -8,10 +6,9 @@ if [[ "$0" == *"run.sh" && ! $1 = "" ]];then eval "$@"; fi -check_environment -check_httpd_environment -display_container_httpd_header -begin_config -end_config -display_container_started -start_daemon +check_environment | tee -a $STARTUPLOG +check_httpd_environment | tee -a $STARTUPLOG +display_container_httpd_header | tee -a $STARTUPLOG +begin_config | tee -a $STARTUPLOG +end_config | tee -a $STARTUPLOG +start_daemon | tee -a $STARTUPLOG diff --git a/Services/apache/sx-httpd.sh b/Services/apache/sx-httpd.sh index 6b2a417..363e74f 100644 --- a/Services/apache/sx-httpd.sh +++ b/Services/apache/sx-httpd.sh @@ -7,17 +7,24 @@ function check_httpd_environment { echo "! WARNING : environment var SERVER_NAME is missing..." echo "! WARNING : auto-assigned value : $SERVER_NAME" fi - if [ ! -v DOCROOT ]; then - DOCROOT="/data/www" - export DOCROOT - echo "! WARNING : environment var DOCROOT is missing..." - echo "! WARNING : auto-assigned value : $DOCROOT" + if [ ! -v DOC_ROOT ]; then + DOC_ROOT="/data/httpd" + export DOC_ROOT + fi + if [ ! -v APP_PATH ]; then + APP_PATH="/data/httpd" + export APP_PATH + fi + if [ ! -v LOG_PATH ]; then + LOG_PATH="/data/logs/httpd" + export LOG_PATH fi } function display_container_httpd_header { echo "+=====================================================" echo "| Container : $HOSTNAME" + echo "| OS : $(</etc/redhat-release)" if [ -v CONTAINER_TYPE ]; then echo "| Type : $CONTAINER_TYPE" fi @@ -30,6 +37,12 @@ function display_container_httpd_header { if [ -v CONTAINER_SERVICE ]; then echo "| ServerName : $SERVER_NAME" fi + if [ -v APP_PATH ]; then + echo "| App path : $APP_PATH" + fi + if [ -v LOG_PATH ]; then + echo "| Log path : $LOG_PATH" + fi echo "+=====================================================" } @@ -37,20 +50,10 @@ function display_container_httpd_header { # and start generating host keys function begin_config { echo "=> BEGIN APACHE CONFIGURATION" - mkdir -p /var/run/httpd - if [ -v DOCROOT ]; then - echo "=> Set DocumentRoot to $DOCROOT in $HTTPDCONF" - echo "DocumentRoot \"$DOCROOT\"" >> $HTTPDCONF - fi - if [ -v SERVER_NAME ]; then - echo "=> Set ServerName to $SERVER_NAME in $HTTPDCONF" - echo "ServerName \"$SERVER_NAME\"" >> $HTTPDCONF - fi } # End configuration process just before starting daemon function end_config { - stop_server echo "=> END APACHE CONFIGURATION" } @@ -74,5 +77,6 @@ function stop_server { # the running shell function start_daemon { echo "=> Starting httpd daemon ..." + display_container_started exec /usr/sbin/apachectl -D FOREGROUND } |