From 1bf3a2863c14dd2fd98c0cb72a593a6bb3111e75 Mon Sep 17 00:00:00 2001 From: clfreville2 Date: Sun, 12 Mar 2023 10:31:33 +0100 Subject: [PATCH] Also recreate the nginx container for testing --- test/nginx/Dockerfile | 3 +++ test/test_image.sh | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 test/nginx/Dockerfile diff --git a/test/nginx/Dockerfile b/test/nginx/Dockerfile new file mode 100644 index 0000000..11d23f4 --- /dev/null +++ b/test/nginx/Dockerfile @@ -0,0 +1,3 @@ +FROM linuxserver/openssh-server:9.1_p1-r2-ls105 + +RUN apk add --no-cache rsync diff --git a/test/test_image.sh b/test/test_image.sh index 90877cd..239e0df 100755 --- a/test/test_image.sh +++ b/test/test_image.sh @@ -5,19 +5,22 @@ set -eu root_dir=$(readlink -f $(dirname $(realpath "$0"))/..) if ! [ -f "$root_dir"/id_rsa ]; then echo 'Generating SSH key' - ssh-keygen -t rsa -f "$root_dir"/id_rsa -q -N '' + ssh-keygen -t rsa -f "$root_dir/id_rsa" -q -N '' fi run_image() { + # Run the codefirst-docdeployer image with the given branch and command. + # + # The container will automatically be added to the same network as a container + # named 'nginx'. The codefirst-nginx container acts as a SSH server and will + # be started and stopped automatically. The SSH user, port and authorized + # keys are already configured. local branch=$1 - local pubkey=$(<"$root_dir"/id_rsa.pub) + local pubkey=$(<"$root_dir/id_rsa.pub") shift docker network inspect codefirst &> /dev/null || docker network create codefirst - docker volume create --name=codefirst-docdeployer-drone - docker volume create --name=codefirst-docdeployer-docs - docker volume create --name=codefirst-nginx - nginx_id=$(docker run --rm -d -v codefirst-nginx:/usr/share/nginx --net=codefirst -e PUBLIC_KEY="$pubkey" -e USER_NAME=codefirst --hostname=nginx linuxserver/openssh-server) - sleep 1 # Wait to let the container start + nginx_id=$(docker run --rm -d -v codefirst-nginx:/usr/share/nginx --net=codefirst -e PUBLIC_KEY="$pubkey" -e USER_NAME=codefirst -e PUID=0 --hostname=nginx codefirst-nginx) + sleep 2 # Wait to let the container start docker run -v codefirst-docdeployer-drone:/drone/src \ -v codefirst-docdeployer-docs:/docs \ --net=codefirst \ @@ -30,8 +33,11 @@ run_image() { --rm codefirst-docdeployer \ -c "sed -i 's/ssh/ssh -p 2222/g' /entrypoint.sh && sed -i 's/root@nginx/codefirst@nginx/g' /entrypoint.sh && $*" docker stop "$nginx_id" + docker volume rm codefirst-docdeployer-drone codefirst-docdeployer-docs + docker run --rm -i -v codefirst-nginx:/usr/share/nginx busybox find /usr/share/nginx } docker build -t codefirst-docdeployer "$root_dir" +docker build -t codefirst-nginx "$root_dir/test/nginx" run_image main 'doxygen -g && /entrypoint.sh -b main -l . -t doxygen -d sourcecode_documentation'