diff options
Diffstat (limited to 'Services')
-rw-r--r-- | Services/apache/Dockerfile | 30 | ||||
-rw-r--r-- | Services/apache/docker-compose.yml | 15 | ||||
-rw-r--r-- | Services/apache/httpd.conf | 15 | ||||
-rw-r--r-- | Services/apache/httpd.sh | 50 | ||||
-rw-r--r-- | Services/apache/run.sh | 56 |
5 files changed, 96 insertions, 70 deletions
diff --git a/Services/apache/Dockerfile b/Services/apache/Dockerfile index d382ea7..8db1b4f 100644 --- a/Services/apache/Dockerfile +++ b/Services/apache/Dockerfile @@ -2,21 +2,21 @@ FROM startx/fedora MAINTAINER Christophe LARUE <dev@startx.fr> USER root -# Install packages and set up httpd -RUN dnf -y install httpd \ - && dnf clean all \ - && mkdir -p /var/www/html \ - && mkdir -p /var/log/httpd -# Copy startx toolkit -COPY sx/* /sx/ -COPY httpd.conf /etc/httpd/conf.d/sx.conf -# Copy html content -COPY html/* /var/www/html/ -RUN chmod ug+rx /sx/httpd* \ - && chmod ug+r /var/www/html/* \ - && chown -R apache:apache /var/www/html /var/log/httpd +RUN dnf -y install httpd && \ + dnf clean all +COPY httpd.conf /etc/httpd/conf.d/app.conf +COPY run.sh /bin/ +RUN chmod 775 /bin/run.sh && \ + chmod ug+r /etc/httpd/conf.d/app.conf && \ + 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 EXPOSE 80 EXPOSE 443 -VOLUME ["/var/www/html", "/var/log/httpd"] -CMD ["/sx/httpd_run.sh"]
\ No newline at end of file +VOLUME ["/data/www","/data/logs"] +CMD ["/bin/run.sh"]
\ No newline at end of file diff --git a/Services/apache/docker-compose.yml b/Services/apache/docker-compose.yml new file mode 100644 index 0000000..b8130ef --- /dev/null +++ b/Services/apache/docker-compose.yml @@ -0,0 +1,15 @@ +apache: + build: ./ +# image: sx-apache + container_name: "sx-apache" + mem_limit: 1g + memswap_limit: 2g + cpu_shares: 2 + restart: "on-failure:2" + environment: + CONTAINER_TYPE: "service" + CONTAINER_SERVICE: "apache" + CONTAINER_INSTANCE: "sx-apache" + volumes: + - "/tmp/container/logs:/data/logs" + - "/tmp/container/www:/data/www"
\ No newline at end of file diff --git a/Services/apache/httpd.conf b/Services/apache/httpd.conf index 8eab200..ef55e71 100644 --- a/Services/apache/httpd.conf +++ b/Services/apache/httpd.conf @@ -2,7 +2,18 @@ # This file will be copied into /etc/httpd/conf.d/sx.conf and loaded when httpd start # ServerAdmin cl@startx.fr -<Directory "/var/www/html"> +ErrorLog "/data/logs/httpd_error.log" + +<IfModule log_config_module> + CustomLog "/data/logs/httpd_access.log" combined +</IfModule> + +Alias / /data/www +<Directory "/data/www"> + AddDefaultCharset UTF-8 AllowOverride All + Order Allow,Deny + Allow from All + Require all granted DirectoryIndex index.html home.html -</Directory> +</Directory>
\ No newline at end of file diff --git a/Services/apache/httpd.sh b/Services/apache/httpd.sh deleted file mode 100644 index 0220984..0000000 --- a/Services/apache/httpd.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -export TERM=dumb -export HTTPDCONF=/etc/httpd/conf.d/sx.conf - -# Begin configuration before starting daemonized process -# and start generating host keys -function begin_config { - echo "=> Begin httpd configuration for host $HOSTNAME" - mkdir -p /var/run/httpd - if [ -z "$DOCROOT" ]; then - echo "===> Changing document root to $DOCROOT" - ${DOCROOT=/var/www/html} - echo "DocumentRoot \"$DOCROOT\"" >> $HTTPDCONF - fi -} - -# End configuration process just before starting daemon -function end_config { - stop_server - echo "=> End httpd configuration ..." -} - -# Start the httpd server in background. Used to perform config -# against the database structure such as user creation -function start_server { - echo "===> Starting httpd server ..." - /usr/sbin/apachectl & - sleep 8 -} - -# Stop the httpd server running in background. -function stop_server { - echo "===> Stopping httpd server ..." - killall httpd - rm -rf /run/httpd/* - sleep 8 -} - -# Start the httpd server as a deamon and execute it inside -# the running shell -function start_daemon { - echo "=> Starting httpd daemon ..." - exec /usr/sbin/apachectl -D FOREGROUND -} - - -if [[ "$0" == *"httpd.sh" && ! $1 = "" ]];then - eval "$@"; -fi
\ No newline at end of file diff --git a/Services/apache/run.sh b/Services/apache/run.sh index ef073a3..7e2fb8e 100644 --- a/Services/apache/run.sh +++ b/Services/apache/run.sh @@ -1,7 +1,57 @@ #!/bin/bash -source /sx/httpd.sh +source /bin/sx-lib.sh +export HTTPDCONF=/etc/httpd/conf.d/app.conf +# Begin configuration before starting daemonized process +# and start generating host keys +function begin_config { + echo "=> BEGIN APACHE CONFIGURATION" + mkdir -p /var/run/httpd + if [ -v DOCROOT ]; then + echo "=> Changing document root to $DOCROOT" + ${DOCROOT=/data/www} + echo "DocumentRoot \"$DOCROOT\"" >> $HTTPDCONF + fi +} + +# End configuration process just before starting daemon +function end_config { + stop_server + echo "=> END APACHE CONFIGURATION" +} + +# Start the httpd server in background. Used to perform config +# against the database structure such as user creation +function start_server { + echo "=> Starting httpd server" + /usr/sbin/apachectl & + sleep 2 +} + +# Stop the httpd server running in background. +function stop_server { + echo "=> Stopping httpd server ..." + killall httpd + rm -rf /run/httpd/* + sleep 2 +} + +# Start the httpd server as a deamon and execute it inside +# the running shell +function start_daemon { + echo "=> Starting httpd daemon ..." + exec /usr/sbin/apachectl -D FOREGROUND +} + + + +if [[ "$0" == *"httpd.sh" && ! $1 = "" ]];then + eval "$@"; +fi + + +display_container_header begin_config end_config - -start_daemon
\ No newline at end of file +start_daemon +display_container_started |