-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from devilbox/release-0.10
REL-0.10 Rebuild with official apache, watcherd and vhost-gen
- Loading branch information
Showing
19 changed files
with
1,467 additions
and
987 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
|
||
### | ||
### Variables | ||
### | ||
CWD="$( dirname "${0}" )" | ||
|
||
|
||
### | ||
### Run | ||
### | ||
run() { | ||
_cmd="${1}" | ||
|
||
_red="\033[0;31m" | ||
_green="\033[0;32m" | ||
_yellow="\033[0;33m" | ||
_reset="\033[0m" | ||
_user="$(whoami)" | ||
|
||
printf "${_yellow}[%s] ${_red}%s \$ ${_green}${_cmd}${_reset}\n" "$(hostname)" "${_user}" | ||
sh -c "LANG=C LC_ALL=C ${_cmd}" | ||
} | ||
|
||
|
||
|
||
### | ||
### Get 15 character random word | ||
### | ||
function get_random_name() { | ||
local chr=(a b c d e f g h i j k l m o p q r s t u v w x y z) | ||
local len="${#chr[@]}" | ||
local name= | ||
|
||
for i in {1..15}; do | ||
rand="$( shuf -i 0-${len} -n 1 )" | ||
rand=$(( rand - 1 )) | ||
name="${name}${chr[$rand]}" | ||
i="${i}" # simply to get rid of shellcheck complaints | ||
done | ||
echo "${name}" | ||
} | ||
|
||
|
||
DOCKER_IMAGE="$( grep 'image=".*"' "${CWD}/../Dockerfile" | sed 's/^[[:space:]]*//g' | awk -F'"' '{print $2}' )" | ||
DOCKER_VENDOR="$( grep 'vendor=".*"' "${CWD}/../Dockerfile" | sed 's/^[[:space:]]*//g' | awk -F'"' '{print $2}' )" | ||
# shellcheck disable=SC2034 | ||
DOCKER_NAME="${DOCKER_VENDOR}/${DOCKER_IMAGE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" | ||
|
||
|
||
### | ||
### Load Library | ||
### | ||
# shellcheck disable=SC1090 | ||
. ${CWD}/.lib.sh | ||
|
||
|
||
|
||
### | ||
### Preparation | ||
### | ||
RAND_DIR="$( mktemp -d )" | ||
RAND_NAME="$( get_random_name )" | ||
run "echo \"hello world\" > ${RAND_DIR}/index.html" | ||
|
||
|
||
### | ||
### Build container | ||
### | ||
run "docker build -t ${DOCKER_NAME} ${CWD}/.." | ||
|
||
|
||
### | ||
### Startup container | ||
### | ||
run "docker run -d --rm \ | ||
-v ${RAND_DIR}:/var/www/default/htdocs \ | ||
-p 127.0.0.1:80:80 \ | ||
-e DEBUG_ENTRYPOINT=2 \ | ||
-e DEBUG_RUNTIME=1 \ | ||
-e NEW_UID=$( id -u ) \ | ||
-e NEW_GID=$( id -g ) \ | ||
--name ${RAND_NAME} ${DOCKER_NAME}" | ||
|
||
|
||
### | ||
### Tests | ||
### | ||
run "sleep 5" | ||
run "docker ps" | ||
run "docker logs ${RAND_NAME}" | ||
run "curl localhost" | ||
run "curl localhost | grep 'hello world'" | ||
|
||
|
||
### | ||
### Cleanup | ||
### | ||
run "docker stop ${RAND_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" | ||
|
||
|
||
### | ||
### Load Library | ||
### | ||
# shellcheck disable=SC1090 | ||
. ${CWD}/.lib.sh | ||
|
||
|
||
|
||
### | ||
### Preparation | ||
### | ||
RAND_DIR="$( mktemp -d )" | ||
RAND_NAME1="$( get_random_name )" | ||
RAND_NAME2="$( get_random_name )" | ||
run "echo \"<?php echo 'hello world php';\" > ${RAND_DIR}/index.php" | ||
|
||
|
||
### | ||
### Build container | ||
### | ||
run "docker build -t ${DOCKER_NAME} ${CWD}/.." | ||
|
||
|
||
### | ||
### Startup container | ||
### | ||
run "docker run -d --rm \ | ||
-v ${RAND_DIR}:/var/www/default/htdocs \ | ||
-e DEBUG_ENTRYPOINT=1 \ | ||
-e NEW_UID=$( id -u ) \ | ||
-e NEW_GID=$( id -g ) \ | ||
--name ${RAND_NAME1} cytopia/php-fpm-5.6" | ||
|
||
run "docker run -d --rm \ | ||
-v ${RAND_DIR}:/var/www/default/htdocs \ | ||
-p 127.0.0.1:80:80 \ | ||
-e DEBUG_ENTRYPOINT=2 \ | ||
-e DEBUG_RUNTIME=1 \ | ||
-e NEW_UID=$( id -u ) \ | ||
-e NEW_GID=$( id -g ) \ | ||
-e PHP_FPM_ENABLE=1 \ | ||
-e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \ | ||
-e PHP_FPM_SERVER_PORT=9000 \ | ||
--link ${RAND_NAME1} \ | ||
--name ${RAND_NAME2} ${DOCKER_NAME}" | ||
|
||
|
||
### | ||
### Tests | ||
### | ||
run "sleep 5" | ||
run "docker ps" | ||
run "docker logs ${RAND_NAME1}" | ||
run "docker logs ${RAND_NAME2}" | ||
run "curl localhost" | ||
run "curl localhost | grep 'hello world php'" | ||
|
||
|
||
### | ||
### Cleanup | ||
### | ||
run "docker stop ${RAND_NAME1}" | ||
run "docker stop ${RAND_NAME2}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
set -o pipefail | ||
|
||
### | ||
### Variables | ||
### | ||
|
||
IFS=$'\n' | ||
|
||
# Current directory | ||
CWD="$( dirname "${0}" )" | ||
|
||
declare -a TESTS=() | ||
|
||
|
||
### | ||
### Sanity checks | ||
### | ||
|
||
# Check Dockerfile | ||
if [ ! -f "${CWD}/../Dockerfile" ]; then | ||
echo "Dockerfile not found in: ${CWD}/../Dockerfile." | ||
exit 1 | ||
fi | ||
|
||
# Check docker Name | ||
if ! grep -q 'image=".*"' "${CWD}/../Dockerfile" > /dev/null 2>&1; then | ||
echo "No 'image' LABEL found" | ||
exit | ||
fi | ||
|
||
|
||
### | ||
### Run tests | ||
### | ||
|
||
# Get all [0-9]+.sh test files | ||
FILES="$( find ${CWD} -regex "${CWD}/[0-9].+\.sh" | sort -u )" | ||
for f in ${FILES}; do | ||
TESTS+=("${f}") | ||
done | ||
|
||
# Start a single test | ||
if [ "${#}" -eq "1" ]; then | ||
sh -c "${TESTS[${1}]}" | ||
|
||
# Run all tests | ||
else | ||
for i in "${TESTS[@]}"; do | ||
echo "sh -c ${CWD}/${i}" | ||
sh -c "${i}" | ||
done | ||
fi |
Oops, something went wrong.