Skip to content

Commit 19023a5

Browse files
authored
Merge pull request #7 from devilbox/release-0.10
REL-0.10 Rebuild with official nginx, watcherd and vhost-gen
2 parents e22c611 + 03fe707 commit 19023a5

19 files changed

+1442
-1081
lines changed

.ci/.lib.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
8+
###
9+
### Variables
10+
###
11+
CWD="$( dirname "${0}" )"
12+
13+
14+
###
15+
### Run
16+
###
17+
run() {
18+
_cmd="${1}"
19+
20+
_red="\033[0;31m"
21+
_green="\033[0;32m"
22+
_yellow="\033[0;33m"
23+
_reset="\033[0m"
24+
_user="$(whoami)"
25+
26+
printf "${_yellow}[%s] ${_red}%s \$ ${_green}${_cmd}${_reset}\n" "$(hostname)" "${_user}"
27+
sh -c "LANG=C LC_ALL=C ${_cmd}"
28+
}
29+
30+
31+
32+
###
33+
### Get 15 character random word
34+
###
35+
function get_random_name() {
36+
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)
37+
local len="${#chr[@]}"
38+
local name=
39+
40+
for i in {1..15}; do
41+
rand="$( shuf -i 0-${len} -n 1 )"
42+
rand=$(( rand - 1 ))
43+
name="${name}${chr[$rand]}"
44+
i="${i}" # simply to get rid of shellcheck complaints
45+
done
46+
echo "${name}"
47+
}
48+
49+
50+
DOCKER_IMAGE="$( grep 'image=".*"' "${CWD}/../Dockerfile" | sed 's/^[[:space:]]*//g' | awk -F'"' '{print $2}' )"
51+
DOCKER_VENDOR="$( grep 'vendor=".*"' "${CWD}/../Dockerfile" | sed 's/^[[:space:]]*//g' | awk -F'"' '{print $2}' )"
52+
# shellcheck disable=SC2034
53+
DOCKER_NAME="${DOCKER_VENDOR}/${DOCKER_IMAGE}"

.ci/00.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
8+
9+
10+
###
11+
### Load Library
12+
###
13+
# shellcheck disable=SC1090
14+
. ${CWD}/.lib.sh
15+
16+
17+
18+
###
19+
### Preparation
20+
###
21+
RAND_DIR="$( mktemp -d )"
22+
RAND_NAME="$( get_random_name )"
23+
run "echo \"hello world\" > ${RAND_DIR}/index.html"
24+
25+
26+
###
27+
### Build container
28+
###
29+
run "docker build -t ${DOCKER_NAME} ${CWD}/.."
30+
31+
32+
###
33+
### Startup container
34+
###
35+
run "docker run -d --rm \
36+
-v ${RAND_DIR}:/var/www/default/htdocs \
37+
-p 127.0.0.1:80:80 \
38+
-e DEBUG_ENTRYPOINT=2 \
39+
-e DEBUG_RUNTIME=1 \
40+
-e NEW_UID=$( id -u ) \
41+
-e NEW_GID=$( id -g ) \
42+
--name ${RAND_NAME} ${DOCKER_NAME}"
43+
44+
45+
###
46+
### Tests
47+
###
48+
run "sleep 5"
49+
run "docker ps"
50+
run "docker logs ${RAND_NAME}"
51+
run "curl localhost"
52+
run "curl localhost | grep 'hello world'"
53+
54+
55+
###
56+
### Cleanup
57+
###
58+
run "docker stop ${RAND_NAME}"

.ci/01.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
8+
9+
10+
###
11+
### Load Library
12+
###
13+
# shellcheck disable=SC1090
14+
. ${CWD}/.lib.sh
15+
16+
17+
18+
###
19+
### Preparation
20+
###
21+
RAND_DIR="$( mktemp -d )"
22+
RAND_NAME1="$( get_random_name )"
23+
RAND_NAME2="$( get_random_name )"
24+
run "echo \"<?php echo 'hello world php';\" > ${RAND_DIR}/index.php"
25+
26+
27+
###
28+
### Build container
29+
###
30+
run "docker build -t ${DOCKER_NAME} ${CWD}/.."
31+
32+
33+
###
34+
### Startup container
35+
###
36+
run "docker run -d --rm \
37+
-v ${RAND_DIR}:/var/www/default/htdocs \
38+
-e DEBUG_ENTRYPOINT=1 \
39+
-e NEW_UID=$( id -u ) \
40+
-e NEW_GID=$( id -g ) \
41+
--name ${RAND_NAME1} cytopia/php-fpm-5.6"
42+
43+
run "docker run -d --rm \
44+
-v ${RAND_DIR}:/var/www/default/htdocs \
45+
-p 127.0.0.1:80:80 \
46+
-e DEBUG_ENTRYPOINT=2 \
47+
-e DEBUG_RUNTIME=1 \
48+
-e NEW_UID=$( id -u ) \
49+
-e NEW_GID=$( id -g ) \
50+
-e PHP_FPM_ENABLE=1 \
51+
-e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \
52+
-e PHP_FPM_SERVER_PORT=9000 \
53+
--link ${RAND_NAME1} \
54+
--name ${RAND_NAME2} ${DOCKER_NAME}"
55+
56+
57+
###
58+
### Tests
59+
###
60+
run "sleep 5"
61+
run "docker ps"
62+
run "docker logs ${RAND_NAME1}"
63+
run "docker logs ${RAND_NAME2}"
64+
run "curl localhost"
65+
run "curl localhost | grep 'hello world php'"
66+
67+
68+
###
69+
### Cleanup
70+
###
71+
run "docker stop ${RAND_NAME1}"
72+
run "docker stop ${RAND_NAME2}"

.ci/start-ci.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
###
8+
### Variables
9+
###
10+
11+
IFS=$'\n'
12+
13+
# Current directory
14+
CWD="$( dirname "${0}" )"
15+
16+
declare -a TESTS=()
17+
18+
19+
###
20+
### Sanity checks
21+
###
22+
23+
# Check Dockerfile
24+
if [ ! -f "${CWD}/../Dockerfile" ]; then
25+
echo "Dockerfile not found in: ${CWD}/../Dockerfile."
26+
exit 1
27+
fi
28+
29+
# Check docker Name
30+
if ! grep -q 'image=".*"' "${CWD}/../Dockerfile" > /dev/null 2>&1; then
31+
echo "No 'image' LABEL found"
32+
exit
33+
fi
34+
35+
36+
###
37+
### Run tests
38+
###
39+
40+
# Get all [0-9]+.sh test files
41+
FILES="$( find ${CWD} -regex "${CWD}/[0-9].+\.sh" | sort -u )"
42+
for f in ${FILES}; do
43+
TESTS+=("${f}")
44+
done
45+
46+
# Start a single test
47+
if [ "${#}" -eq "1" ]; then
48+
sh -c "${TESTS[${1}]}"
49+
50+
# Run all tests
51+
else
52+
for i in "${TESTS[@]}"; do
53+
echo "sh -c ${CWD}/${i}"
54+
sh -c "${i}"
55+
done
56+
fi

0 commit comments

Comments
 (0)