Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .ci/.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ set -u
set -o pipefail


###
### Variables
###
CWD="$( dirname "${0}" )"


###
### Run
###
Expand Down Expand Up @@ -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}"
11 changes: 3 additions & 8 deletions .ci/00.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -u
set -o pipefail

CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
DOCKER_NAME="${1}"


###
Expand All @@ -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
###
Expand All @@ -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'"


###
Expand Down
13 changes: 4 additions & 9 deletions .ci/01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -u
set -o pipefail

CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
DOCKER_NAME="${1}"


###
Expand All @@ -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 \"<?php echo 'hello world php';\" > ${RAND_DIR}/index.php"


###
### Build container
###
run "docker build -t ${DOCKER_NAME} ${CWD}/.."
run "echo \"<?php echo 'h'.'e'.'llo world php';\" > ${RAND_DIR}/index.php"


###
Expand Down Expand Up @@ -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'"


###
Expand Down
26 changes: 5 additions & 21 deletions .ci/start-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
###
Expand All @@ -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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}


###
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
FROM nginx:mainline
MAINTAINER "cytopia" <cytopia@everythingcli.org>

LABEL \
name="cytopia's nginx mainline image" \
image="devilbox/nginx-mainline" \
vendor="devilbox" \
license="MIT"

###
### 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 \
Expand Down
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
image = devilbox/nginx-mainline

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)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,5 @@ It allows any of the following combinations:
## Version

```
nginx version: nginx/1.13.12
nginx version: nginx/1.15.2
```
65 changes: 0 additions & 65 deletions build/docker-build.sh

This file was deleted.

65 changes: 0 additions & 65 deletions build/docker-rebuild.sh

This file was deleted.

20 changes: 20 additions & 0 deletions build/gen-readme.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions data/vhost-gen/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down