From 61014d1d6530804821b16ceccfec793f087e5007 Mon Sep 17 00:00:00 2001 From: cytopia Date: Thu, 2 Aug 2018 22:26:51 +0200 Subject: [PATCH 1/3] Use latest vhost-gen version --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index db738be..27ec3e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ MAINTAINER "cytopia" ### ### Build arguments ### -ARG VHOST_GEN_GIT_REF=0.7 +ARG VHOST_GEN_GIT_REF=0.10 ARG CERT_GEN_GIT_REF=0.2 ENV BUILD_DEPS \ @@ -67,6 +67,9 @@ RUN set -x \ && sed -i'' 's|^\s*include.*conf\.d/.*| include /etc/httpd-custom.d/*.conf;\n include /etc/httpd/conf.d/*.conf;\n include /etc/httpd/vhost.d/*.conf;\n|g' /etc/nginx/nginx.conf \ && echo "daemon off;" >> /etc/nginx/nginx.conf +RUN set -x \ + && sed -i'' 's|http {|http {\nfastcgi_intercept_errors = on;|g' /etc/nginx/nginx.conf + # create directories RUN set -x \ && mkdir -p /etc/httpd-custom.d \ From 43d204a21002eee32d2a2f4fd10a35a66a405f79 Mon Sep 17 00:00:00 2001 From: cytopia Date: Thu, 2 Aug 2018 22:48:37 +0200 Subject: [PATCH 2/3] Fix Travis CI tests --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 27ec3e3..42197a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,11 @@ FROM nginx:stable MAINTAINER "cytopia" +LABEL \ + name="cytopia's nginx stable image" \ + image="devilbox/nginx-stable" \ + vendor="devilbox" \ + license="MIT" ### ### Build arguments From 28950f1146250d38cadc427ab7fbfd595bfbfd67 Mon Sep 17 00:00:00 2001 From: cytopia Date: Fri, 3 Aug 2018 00:00:21 +0200 Subject: [PATCH 3/3] Fix travis errors --- .ci/.lib.sh | 12 -------- .ci/00.sh | 11 ++----- .ci/01.sh | 13 +++------ .ci/start-ci.sh | 26 ++++------------- .travis.yml | 3 +- Dockerfile | 3 -- Makefile | 21 +++++++++++++ README.md | 2 +- build/docker-build.sh | 65 ----------------------------------------- build/docker-rebuild.sh | 65 ----------------------------------------- build/gen-readme.sh | 20 +++++++++++++ data/vhost-gen/main.yml | 2 ++ 12 files changed, 58 insertions(+), 185 deletions(-) create mode 100644 Makefile delete mode 100755 build/docker-build.sh delete mode 100755 build/docker-rebuild.sh create mode 100755 build/gen-readme.sh diff --git a/.ci/.lib.sh b/.ci/.lib.sh index a47cfa2..0371aaa 100755 --- a/.ci/.lib.sh +++ b/.ci/.lib.sh @@ -5,12 +5,6 @@ set -u set -o pipefail -### -### Variables -### -CWD="$( dirname "${0}" )" - - ### ### Run ### @@ -45,9 +39,3 @@ function get_random_name() { 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}" diff --git a/.ci/00.sh b/.ci/00.sh index c94cba8..83d1db1 100755 --- a/.ci/00.sh +++ b/.ci/00.sh @@ -5,6 +5,7 @@ set -u set -o pipefail CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" +DOCKER_NAME="${1}" ### @@ -23,12 +24,6 @@ RAND_NAME="$( get_random_name )" run "echo \"hello world\" > ${RAND_DIR}/index.html" -### -### Build container -### -run "docker build -t ${DOCKER_NAME} ${CWD}/.." - - ### ### Startup container ### @@ -48,8 +43,8 @@ run "docker run -d --rm \ run "sleep 5" run "docker ps" run "docker logs ${RAND_NAME}" -run "curl localhost" -run "curl localhost | grep 'hello world'" +run "curl -sS localhost/index.html" +run "curl -sS localhost/index.html | grep 'hello world'" ### diff --git a/.ci/01.sh b/.ci/01.sh index dd25739..8528d8e 100755 --- a/.ci/01.sh +++ b/.ci/01.sh @@ -5,6 +5,7 @@ set -u set -o pipefail CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" +DOCKER_NAME="${1}" ### @@ -21,13 +22,7 @@ CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" RAND_DIR="$( mktemp -d )" RAND_NAME1="$( get_random_name )" RAND_NAME2="$( get_random_name )" -run "echo \" ${RAND_DIR}/index.php" - - -### -### Build container -### -run "docker build -t ${DOCKER_NAME} ${CWD}/.." +run "echo \" ${RAND_DIR}/index.php" ### @@ -61,8 +56,8 @@ 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'" +run "curl -sS localhost" +run "curl -sS localhost | grep 'hello world php'" ### diff --git a/.ci/start-ci.sh b/.ci/start-ci.sh index 5ce0b04..647b208 100755 --- a/.ci/start-ci.sh +++ b/.ci/start-ci.sh @@ -12,27 +12,11 @@ IFS=$'\n' # Current directory CWD="$( dirname "${0}" )" +IMAGE="${1}" 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 ### @@ -44,13 +28,13 @@ for f in ${FILES}; do done # Start a single test -if [ "${#}" -eq "1" ]; then - sh -c "${TESTS[${1}]}" +if [ "${#}" -eq "2" ]; then + sh -c "${TESTS[${2}]} ${IMAGE}" # Run all tests else for i in "${TESTS[@]}"; do - echo "sh -c ${CWD}/${i}" - sh -c "${i}" + echo "sh -c ${CWD}/${i} ${IMAGE}" + sh -c "${i} ${IMAGE}" done fi diff --git a/.travis.yml b/.travis.yml index 5ff656d..00fd266 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,8 @@ install: - max=100; i=0; while [ $i -lt $max ]; do if sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; then break; else i=$((i+1)); fi done - docker version script: - - .ci/start-ci.sh "${TEST}" "${IMAGE}" + - make build + - make test ARG=${TEST} ### diff --git a/Dockerfile b/Dockerfile index 42197a5..f0d8143 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,9 +72,6 @@ RUN set -x \ && sed -i'' 's|^\s*include.*conf\.d/.*| include /etc/httpd-custom.d/*.conf;\n include /etc/httpd/conf.d/*.conf;\n include /etc/httpd/vhost.d/*.conf;\n|g' /etc/nginx/nginx.conf \ && echo "daemon off;" >> /etc/nginx/nginx.conf -RUN set -x \ - && sed -i'' 's|http {|http {\nfastcgi_intercept_errors = on;|g' /etc/nginx/nginx.conf - # create directories RUN set -x \ && mkdir -p /etc/httpd-custom.d \ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..642508d --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +image = devilbox/nginx-stable + +help: + @printf "%s\n" "make build: Build" + @printf "%s\n" "make rebuild: Rebuild" + @printf "%s\n" "make test: Test" + + +build: pull + docker build -t $(image) . + cd build; ./gen-readme.sh $(image) + +rebuild: pull + docker build --no-cache -t $(image) . + cd build; ./gen-readme.sh $(image) + +test: + .ci/start-ci.sh $(image) $(ARG) + +pull: + docker pull $(shell grep FROM Dockerfile | sed 's/^FROM//g'; done) diff --git a/README.md b/README.md index fc387a0..c608a83 100644 --- a/README.md +++ b/README.md @@ -255,5 +255,5 @@ It allows any of the following combinations: ## Version ``` -nginx version: nginx/1.14.0 +nginx version: nginx/1.14.0 ``` diff --git a/build/docker-build.sh b/build/docker-build.sh deleted file mode 100755 index 566dd80..0000000 --- a/build/docker-build.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -eu - - -### -### Globals -### -CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)/.." -VEND=devilbox -NAME=nginx-stable - -### -### Funcs -### -run() { - _cmd="${1}" - _red="\033[0;31m" - _green="\033[0;32m" - _reset="\033[0m" - _user="$(whoami)" - - printf "${_red}%s \$ ${_green}${_cmd}${_reset}\n" "${_user}" - sh -c "LANG=C LC_ALL=C ${_cmd}" -} - - -### -### Checks -### - -# Check Dockerfile -if [ ! -f "${CWD}/Dockerfile" ]; then - echo "Dockerfile not found in: ${CWD}/Dockerfile." - exit 1 -fi - - -### -### Update Base -### -MY_BASE="$( grep 'FROM[[:space:]].*:.*' "${CWD}/Dockerfile" | sed 's/FROM\s*//g' )" -run "docker pull ${MY_BASE}" - - -### -### Build -### - -# Build Docker -run "docker build -t ${VEND}/${NAME} ${CWD}" - - -### -### Retrieve information afterwards and Update README.md -### -DID="$( docker run -d --rm -t ${VEND}/${NAME} )" -INFO="$( docker exec "${DID}" nginx -v 2>&1 )" -docker stop "${DID}" - -echo "${INFO}" - -sed -i'' '/##[[:space:]]Version/q' "${CWD}/README.md" -echo "" >> "${CWD}/README.md" -echo '```' >> "${CWD}/README.md" -echo "${INFO}" >> "${CWD}/README.md" -echo '```' >> "${CWD}/README.md" diff --git a/build/docker-rebuild.sh b/build/docker-rebuild.sh deleted file mode 100755 index b9a8f40..0000000 --- a/build/docker-rebuild.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -eu - - -### -### Globals -### -CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)/.." -VEND=devilbox -NAME=nginx-stable - -### -### Funcs -### -run() { - _cmd="${1}" - _red="\033[0;31m" - _green="\033[0;32m" - _reset="\033[0m" - _user="$(whoami)" - - printf "${_red}%s \$ ${_green}${_cmd}${_reset}\n" "${_user}" - sh -c "LANG=C LC_ALL=C ${_cmd}" -} - - -### -### Checks -### - -# Check Dockerfile -if [ ! -f "${CWD}/Dockerfile" ]; then - echo "Dockerfile not found in: ${CWD}/Dockerfile." - exit 1 -fi - - -### -### Update Base -### -MY_BASE="$( grep 'FROM[[:space:]].*:.*' "${CWD}/Dockerfile" | sed 's/FROM\s*//g' )" -run "docker pull ${MY_BASE}" - - -### -### Build -### - -# Build Docker -run "docker build --no-cache -t ${VEND}/${NAME} ${CWD}" - - -### -### Retrieve information afterwards and Update README.md -### -DID="$( docker run -d --rm -t ${VEND}/${NAME} )" -INFO="$( docker exec "${DID}" nginx -v 2>&1 )" -docker stop "${DID}" - -echo "${INFO}" - -sed -i'' '/##[[:space:]]Version/q' "${CWD}/README.md" -echo "" >> "${CWD}/README.md" -echo '```' >> "${CWD}/README.md" -echo "${INFO}" >> "${CWD}/README.md" -echo '```' >> "${CWD}/README.md" diff --git a/build/gen-readme.sh b/build/gen-readme.sh new file mode 100755 index 0000000..32d0154 --- /dev/null +++ b/build/gen-readme.sh @@ -0,0 +1,20 @@ +#!/bin/sh -eu + + +### +### Globals +### +CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)/.." +IMAGE="${1}" + +### +### Retrieve information afterwards and Update README.md +### +INFO="$( docker run -it --rm --entrypoint=nginx ${IMAGE} -v 2>&1 )" + +echo "${INFO}" +sed -i'' '/##[[:space:]]Version/q' "${CWD}/README.md" +echo "" >> "${CWD}/README.md" +echo '```' >> "${CWD}/README.md" +echo "${INFO}" >> "${CWD}/README.md" +echo '```' >> "${CWD}/README.md" diff --git a/data/vhost-gen/main.yml b/data/vhost-gen/main.yml index f73384d..286f208 100644 --- a/data/vhost-gen/main.yml +++ b/data/vhost-gen/main.yml @@ -90,6 +90,8 @@ vhost: # Array of indecies to serve as default files (e.g.: index.php, index.html, etc) index: - index.php + - index.html + - index.htm # SSL Definition ssl: dir_crt: /etc/httpd/cert/main