diff options
-rw-r--r-- | OS/docker-compose.yml | 4 | ||||
-rw-r--r-- | OS/run.sh | 3 | ||||
-rw-r--r-- | OS/sx-lib.sh | 6 | ||||
-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 | ||||
-rw-r--r-- | docker-compose.yml | 6 | ||||
-rwxr-xr-x | run-tests.sh | 1 |
10 files changed, 109 insertions, 77 deletions
diff --git a/OS/docker-compose.yml b/OS/docker-compose.yml index c79d5d9..7d2f3f5 100644 --- a/OS/docker-compose.yml +++ b/OS/docker-compose.yml @@ -7,6 +7,6 @@ server: cpu_shares: 2 restart: "on-failure:2" environment: - CONTAINER_SERVICE: "os" - CONTAINER_TYPE: "fedora" + CONTAINER_TYPE: "OS" + CONTAINER_SERVICE: "fedora" CONTAINER_INSTANCE: "sx-fedora"
\ No newline at end of file @@ -1,4 +1,5 @@ #!/bin/bash source /bin/sx-lib.sh -display_container_header
\ No newline at end of file +display_container_header +display_container_started
\ No newline at end of file diff --git a/OS/sx-lib.sh b/OS/sx-lib.sh index 2fcb5aa..22aa84a 100644 --- a/OS/sx-lib.sh +++ b/OS/sx-lib.sh @@ -16,3 +16,9 @@ function display_container_header { fi echo "+=====================================================" } + +function display_container_started { + echo "+=====================================================" + echo "| Container $HOSTNAME is now running..." + echo "+=====================================================" +}
\ No newline at end of file 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 diff --git a/docker-compose.yml b/docker-compose.yml index 0156a71..e8cf6ff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,9 @@ fedora: container_name: "startx-fedora" command: cat /etc/redhat-release -#apache: -# build: Services/apache/ -# container_name: "startx-sv-apache" +apache: + build: Services/apache/ + container_name: "startx-sv-apache" #mariadb: # build: Services/mariadb/ diff --git a/run-tests.sh b/run-tests.sh index b81f952..44caeda 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -5,5 +5,4 @@ cd /tmp/startx-docker-images; git clone https://github.com/startxfr/docker-images.git /tmp/startx-docker-images sudo docker-compose build sudo docker-compose up -d -sudo docker-compose logs exit 0;
\ No newline at end of file |