summaryrefslogtreecommitdiffstats
path: root/Services/apache
diff options
context:
space:
mode:
authorstartxfr <clarue@startx.fr>2016-02-06 05:05:57 +0100
committerstartxfr <clarue@startx.fr>2016-02-06 05:05:57 +0100
commit5cff390c081bdfb756a8977ad0bd56d778202d6b (patch)
treece018b9be9ad054e4f7aa6891d7b4668c1ad74af /Services/apache
parent0f3bcf30ae748a75c22a03d4655dba4d8dc71185 (diff)
downloadphpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.gz
phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.bz2
phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.xz
phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.zip
reorg avec gestion des sig
Diffstat (limited to 'Services/apache')
-rw-r--r--Services/apache/Dockerfile23
-rw-r--r--Services/apache/README.md16
-rw-r--r--Services/apache/docker-compose.yml4
-rw-r--r--Services/apache/index.html22
-rw-r--r--Services/apache/run.sh8
-rw-r--r--Services/apache/sx-httpd.sh66
6 files changed, 54 insertions, 85 deletions
diff --git a/Services/apache/Dockerfile b/Services/apache/Dockerfile
index 9682a0a..78e7cdc 100644
--- a/Services/apache/Dockerfile
+++ b/Services/apache/Dockerfile
@@ -5,24 +5,21 @@ USER root
RUN dnf -y install httpd && \
dnf clean all
ENV HTTPDCONF=/etc/httpd/conf.d/app.conf \
- STARTUPLOG=/data/logs/apache/startup.log \
- LOG_PATH=/data/logs/apache \
- APP_PATH=/data/apache \
- TMP_APP_PATH=/tmp/apache
+ STARTUPLOG=/logs/startup.log \
+ LOG_PATH=/logs \
+ APP_PATH=/app \
+ DATA_PATH=/data
COPY httpd.conf $HTTPDCONF
COPY *.sh /bin/
RUN chmod 775 /bin/run.sh /bin/sx-httpd.sh && \
chmod ug+r $HTTPDCONF && \
- rm -f /etc/httpd/conf.d/autoindex.conf && \
- rm -f /etc/httpd/conf.d/welcome.conf && \
- mkdir -p $TMP_APP_PATH && \
- mkdir -p $APP_PATH && \
- mkdir -p $LOG_PATH && \
+ rm -f /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/welcome.conf && \
+ mkdir -p $DATA_PATH $APP_PATH $LOG_PATH && \
touch $STARTUPLOG
-COPY ./ $TMP_APP_PATH
-RUN rm -f $TMP_APP_PATH/Dockerfile $TMP_APP_PATH/httpd.conf $TMP_APP_PATH/run.sh $TMP_APP_PATH/sx-httpd.sh && \
- chown -R apache:apache $TMP_APP_PATH $APP_PATH $LOG_PATH
+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_PATH $LOG_PATH
EXPOSE 80 443
-VOLUME [$APP_PATH,$LOG_PATH]
+VOLUME [$DATA_PATH,$LOG_PATH]
CMD ["/bin/run.sh"] \ No newline at end of file
diff --git a/Services/apache/README.md b/Services/apache/README.md
index ed737e1..c1ae1a2 100644
--- a/Services/apache/README.md
+++ b/Services/apache/README.md
@@ -30,8 +30,8 @@ service:
CONTAINER_INSTANCE: "service-apache"
SERVER_NAME: "localhost"
volumes:
- - "/tmp/container/logs/apache:/data/logs/apache"
- - "/tmp/container/apache:/data/apache"
+ - "/tmp/container/logs/apache:/logs"
+ - "/tmp/container/apache:/data"
```
## Docker-compose in various situations
@@ -90,8 +90,8 @@ CMD ["/bin/run.sh"]
| CONTAINER_SERVICE | `string` | `no` | Define the type of service or application provided
| SERVER_NAME | `string` | `no` | Server name for this container. If no name localhost will be assigned
| HOSTNAME | `auto` | `auto` | Container unique id automatically assigned by docker daemon at startup
-| LOG_PATH | `auto` | `auto` | default set to /data/logs/apache and used as a volume mountpoint
-| APP_PATH | `auto` | `auto` | default set to /data/apache and used as a volume mountpoint
+| LOG_PATH | `auto` | `auto` | default set to /logs and used as a volume mountpoint
+| APP_PATH | `auto` | `auto` | default set to /data and used as a volume mountpoint
## Exposed port
@@ -104,8 +104,8 @@ CMD ["/bin/run.sh"]
| Container directory | Description |
|----------------------|--------------------------------------------------------------------------|
-| /data/logs/apache | log directory used to record container and apache logs
-| /data/apache | data directory served by apache. If empty will be filled with app on startup. In other case use content from mountpoint or data volumes
+| /logs | log directory used to record container and apache logs
+| /data | data directory served by apache. If empty will be filled with app on startup. In other case use content from mountpoint or data volumes
## Testing the service
@@ -126,8 +126,8 @@ You must have a working environment with the source code of this repository. Rea
1. Jump into the container directory with `cd Services/apache`
2. Build the container using `docker build -t sv-apache .`
3. Run this container
- 1. Interactively with `docker run -p 80:80 -v /data/logs/apache -it sv-apache`. If you add a second parameter (like `/bin/bash`) to will run this command instead of the default entrypoint. Usefull to interact with this container (ex: `/bin/bash`, `/bin/ps -a`, `/bin/df -h`,...)
- 2. As a daemon with `docker run -p 80:80 -v /data/logs/apache -d sv-apache`
+ 1. Interactively with `docker run -p 80:80 -v /logs -it sv-apache`. If you add a second parameter (like `/bin/bash`) to will run this command instead of the default entrypoint. Usefull to interact with this container (ex: `/bin/bash`, `/bin/ps -a`, `/bin/df -h`,...)
+ 2. As a daemon with `docker run -p 80:80 -v /logs -d sv-apache`
### Build & run a container using `docker-compose`
diff --git a/Services/apache/docker-compose.yml b/Services/apache/docker-compose.yml
index 60e4b4f..3c23a4b 100644
--- a/Services/apache/docker-compose.yml
+++ b/Services/apache/docker-compose.yml
@@ -14,5 +14,5 @@ server:
CONTAINER_INSTANCE: "service-apache"
SERVER_NAME: "localhost"
volumes:
- - "/tmp/container/logs/apache:/data/logs/apache"
- - "/tmp/container/apache:/data/apache" \ No newline at end of file
+ - "/tmp/container/logs/apache:/logs"
+ - "/tmp/container/apache:/data" \ No newline at end of file
diff --git a/Services/apache/index.html b/Services/apache/index.html
index 039c3dc..f3a9e21 100644
--- a/Services/apache/index.html
+++ b/Services/apache/index.html
@@ -13,14 +13,8 @@
h3 { text-shadow: 1px 1px 0px rgba(255,255,255,1); font-size: 1.5em;margin: .2em; }
h4 { font-size: 1.2em; margin: .2em; }
p { font-size: 1em; margin: .5em .2em; }
- ul {
- padding-bottom: 1em;
- padding-left: 2em;
- }
- a {
- color: white;
- text-decoration: none;
- }
+ ul { font-size: 1em; margin: .5em .2em; padding-bottom: 1em; padding-left: 2em; }
+ a { color: white; text-decoration: none; }
body > header h1 { color: #000e44; text-shadow: 0 0 3px rgb(255,255,255), 0 0 10px rgba(255,255,255,1), 0 0 20px rgba(255,255,255,0.6); float: left }
body > header h1 span { color: #0c6f5e }
body > header h2 { color: white; font-size: .7em; font-weight: normal; margin: 2.2em 0 0 1em; float: left }
@@ -28,8 +22,6 @@
article header { margin: 0;padding: .3em; box-shadow: 0 0 5px rgba(0,0,0,0.9); border-radius: 5px 5px 0 0; width: 892px; }
article h3 { display: inline; }
article > details { margin: 1em; }
-
-
body#error { background-color : #533;}
#error article { color : darkred; background-color : rgba(255,255,255,0.9); clear: both }
#error article h2 { color : white; text-shadow: 0 0 2px white, 0 0 15px #600, 3px 3px 8px rgba(50,0,0,0.9); }
@@ -37,7 +29,6 @@
#error h3, #error article a { color : #744; }
#error article a:hover { color : #533; }
#error pre.xdebug-var-dump {font-size:0.8em}
-
body#answer { background-color : #353 }
#answer article { color : #575;background-color : rgba(255,255,255,0.9); clear: both }
#answer article h2 { color : white; text-shadow: 0 0 2px rgba(11,45,11,0.9), 0 0 10px rgba(11,45,11,0.8); }
@@ -57,12 +48,13 @@
</header>
<p>
You are actually running an apache webserver running under the latest fedora release. For more information about this container and how to add your content instead of this message, please read the following links.
+ </p>
<ul>
<li><a href="https://github.com/startxfr/docker-images/tree/master/Services/apache" target="_blank">See this container Dockerfile</a></li>
<li><a href="https://github.com/startxfr/docker-images" target="_blank">STARTX github docker images repository</a></li>
<li><a href="https://registry.hub.docker.com/u/startx/" target="_blank">STARTX Dockerhub profile</a></li>
</ul>
- </p>
- </article>
- <footer><p>&copy; 2015 - <a href="https://github.com/startxfr" target="_blank">STARTX</a> - <a href="https://www.startx.fr" target="_blank">STARTX Dev Team</a></p></footer>
-</body></html> \ No newline at end of file
+ </article>
+ <footer><p>&copy; 2015 - <a href="https://github.com/startxfr" target="_blank">STARTX</a> - <a href="https://www.startx.fr" target="_blank">STARTX Dev Team</a></p></footer>
+ </body>
+</html> \ No newline at end of file
diff --git a/Services/apache/run.sh b/Services/apache/run.sh
index ee10346..7a06314 100644
--- a/Services/apache/run.sh
+++ b/Services/apache/run.sh
@@ -2,12 +2,6 @@
source /bin/sx-lib.sh
source /bin/sx-httpd.sh
-if [[ "$0" == *"run.sh" && ! $1 = "" ]];then
- eval "$@";
-fi
-
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
+start_service_httpd
diff --git a/Services/apache/sx-httpd.sh b/Services/apache/sx-httpd.sh
index b850ee3..707b16d 100644
--- a/Services/apache/sx-httpd.sh
+++ b/Services/apache/sx-httpd.sh
@@ -9,11 +9,15 @@ function check_httpd_environment {
echo "! WARNING : auto-assigned value : $SERVER_NAME"
fi
if [ ! -v APP_PATH ]; then
- APP_PATH="/data/apache"
+ APP_PATH="/app"
export APP_PATH
fi
+ if [ ! -v DATA_PATH ]; then
+ DATA_PATH="/data"
+ export DATA_PATH
+ fi
if [ ! -v LOG_PATH ]; then
- LOG_PATH="/data/logs/apache"
+ LOG_PATH="/logs"
export LOG_PATH
fi
}
@@ -38,54 +42,36 @@ function display_container_httpd_header {
if [ -v APP_PATH ]; then
echo "| App path : $APP_PATH"
fi
+ if [ -v DATA_PATH ]; then
+ echo "| Data path : $DATA_PATH"
+ fi
if [ -v LOG_PATH ]; then
echo "| Log path : $LOG_PATH"
fi
echo "+====================================================="
}
-# Begin configuration before starting daemonized process
-# and start generating host keys
-function begin_config {
- echo "=> BEGIN APACHE CONFIGURATION"
- if [[ -d $TMP_APP_PATH ]]; then
- if [ "$(ls -A $TMP_APP_PATH)" ]; then
- echo "COPY application from $TMP_APP_PATH into $APP_PATH"
- FILE_LIST=$(find $TMP_APP_PATH -maxdepth 1 -mindepth 1 -printf "%f\n")
- for FILE in $FILE_LIST; do
- echo -n "adding $APP_PATH/$FILE"
- cp -r $TMP_APP_PATH/$FILE $APP_PATH/
- echo " DONE"
- done
- fi
- fi
-}
-
-# End configuration process just before starting daemon
-function end_config {
- 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 ..."
+function stop_httpd_handler {
killall httpd
rm -rf /run/httpd/*
- sleep 2
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ echo "| Container $HOSTNAME is now STOPPED" | tee -a $STARTUPLOG
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ exit 143; # 128 + 15 -- SIGTERM
}
+
# Start the httpd server as a deamon and execute it inside
# the running shell
-function start_daemon {
- echo "=> Starting httpd daemon ..." | tee -a $STARTUPLOG
- display_container_started | tee -a $STARTUPLOG
- exec /usr/sbin/apachectl && tail -f $LOG_PATH/error.log
+function start_service_httpd {
+ trap 'kill ${!}; stop_httpd_handler' SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL SIGSTOP SIGCONT
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ echo "| Container $HOSTNAME is now RUNNING" | tee -a $STARTUPLOG
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ rm -rf /run/httpd/* /tmp/httpd*
+ exec /usr/sbin/httpd -D FOREGROUND &
+ while true
+ do
+ tail -f /dev/null & wait ${!}
+ done
}