Merge pull request #7 from sameersbn/s6-service

Configure Apache as an s6 service
This commit is contained in:
Adnan Abdulhussein 2015-09-30 19:06:04 +01:00
commit c6573f6167
9 changed files with 55 additions and 22 deletions

View File

@ -10,12 +10,8 @@ ENV BITNAMI_APP_VOL_PREFIX=/bitnami/$BITNAMI_APP_NAME \
PATH=$BITNAMI_APP_DIR/bin:$PATH
RUN sh $BITNAMI_PREFIX/install.sh
COPY vhosts/* $BITNAMI_APP_DIR/conf.defaults/vhosts/
COPY rootfs/ /
EXPOSE 80 443
VOLUME ["$BITNAMI_APP_VOL_PREFIX/conf", "$BITNAMI_APP_VOL_PREFIX/logs", "/app"]
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["httpd"]

View File

@ -0,0 +1,15 @@
#!/bin/bash
if [ "${1:0:1}" = '-' ]; then
export EXTRA_OPTIONS="$@"
set --
elif [ "${1}" == "httpd" -o "${1}" == "$(which httpd)" ]; then
export EXTRA_OPTIONS="${@:2}"
set --
fi
if [ -n "${1}" ]; then
touch /etc/services.d/$BITNAMI_APP_NAME/down
fi
exec /init "$@"

View File

@ -1,20 +1,11 @@
#!/bin/bash
#!/usr/bin/with-contenv bash
set -e
source $BITNAMI_PREFIX/bitnami-utils.sh
print_welcome_page
generate_conf_files
if [ ! "$(ls -A /app)" ]; then
cp -r $BITNAMI_APP_DIR/htdocs.defaults/* $BITNAMI_APP_DIR/htdocs
fi
# Remove zombie pidfile
rm -f $BITNAMI_APP_DIR/logs/httpd.pid
if [[ "$@" = 'httpd' ]]; then
exec $@ -DFOREGROUND -f $BITNAMI_APP_DIR/conf/httpd.conf
else
exec "$@"
fi

View File

@ -0,0 +1,21 @@
#!/usr/bin/with-contenv bash
failcount=0
if [ -f $BITNAMI_APP_DIR/tmp/failcount ]; then
failcount=$(cat $BITNAMI_APP_DIR/tmp/failcount)
fi
start=$(cat $BITNAMI_APP_DIR/tmp/start)
stop=`date '+%d%H%M%S'`
interval=`expr $stop - $start`
if test $interval -lt 30 ; then
failcount=`expr $failcount + 1`
else
failcount=0
fi
echo -n $failcount > $BITNAMI_APP_DIR/tmp/failcount
# bring down container on frequent failures. something is definitely wrong
if test $failcount -ge 3 ; then
s6-svscanctl -t /var/run/s6/services
fi

View File

@ -0,0 +1,10 @@
#!/usr/bin/with-contenv bash
set -e
source $BITNAMI_PREFIX/bitnami-utils.sh
# Remove zombie pidfile
rm -f $BITNAMI_APP_DIR/logs/httpd.pid
mkdir -p $BITNAMI_APP_DIR/tmp
date '+%d%H%M%S' > $BITNAMI_APP_DIR/tmp/start
exec httpd -DFOREGROUND -f $BITNAMI_APP_DIR/conf/httpd.conf ${EXTRA_OPTIONS:+"$EXTRA_OPTIONS"}

View File

@ -36,29 +36,29 @@ add_vhost() {
@test "We can connect to the port 80 and 443" {
create_container
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:80
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i --noproxy apache http://apache:80
[[ "$output" =~ "200 OK" ]]
[ $status = 0 ]
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i -k https://apache:443
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i --noproxy apache -k https://apache:443
[[ "$output" =~ "200 OK" ]]
[ $status = 0 ]
}
@test "Returns default page" {
create_container
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:80
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i --noproxy apache http://apache:80
[[ "$output" =~ "It works!" ]]
[ $status = 0 ]
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i -k https://apache:443
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i --noproxy apache -k https://apache:443
[[ "$output" =~ "It works!" ]]
[ $status = 0 ]
}
@test "Logs to stdout" {
create_container
docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:80
docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i --noproxy apache http://apache:80
run docker logs $CONTAINER_NAME
[[ "$output" =~ "GET / HTTP/1.1" ]]
[ $status = 0 ]
@ -77,7 +77,7 @@ add_vhost() {
add_vhost
docker restart $CONTAINER_NAME
sleep $SLEEP_TIME
docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:81 | {
docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i --noproxy apache http://apache:81 | {
run grep "405 Method Not Allowed"
[ $status = 0 ]
}