From 56531810b7b69afadc477887a18592329468a250 Mon Sep 17 00:00:00 2001 From: asandikci Date: Thu, 21 Dec 2023 00:37:07 +0300 Subject: [PATCH] feat: local test with nginx docker --- nginx_docker_localtest.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 nginx_docker_localtest.sh diff --git a/nginx_docker_localtest.sh b/nginx_docker_localtest.sh new file mode 100755 index 00000000..8c5007a2 --- /dev/null +++ b/nginx_docker_localtest.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Nginx Docker Localtest + +CONT_NAME="IFLRANDEVU_NGINX_LOCALTEST" # nginx docker name +MOUNT_PATH="/source" # binded mount path in nginx docker +FILE_NAME="nginx_docker_localtest.sh" # name of the *this* file + +_RED='\033[0;31m' +_NC='\033[0m \e[0m' # No Color, No Effect +if [[ $1 != "docker" ]]; then + if [[ $(pwd) != *iflrandevu ]]; then + echo "PLEASE CHANGE DIRECTORY TO \`iflrandevu/\` BEFORE STARTING SCRIPT" + exit + fi + docker stop $CONT_NAME + docker rm $CONT_NAME + echo "removed" + + docker run -it -d --name "$CONT_NAME" --mount type=bind,source=".",target=/source/,readonly --publish 8000:80 nginx bash + echo -e "RUN SCRIPT: \`${_RED}bash $MOUNT_PATH/nginx_docker_localtest.sh docker${_NC}\`" + docker attach $CONT_NAME --detach-keys="ctrl-k" + echo "EXIT" + exit + +elif [[ $1 == "docker" ]]; then + apt update + apt install nano exa tree -y + cd /usr/share/nginx/html + rm -f "50x.html" + rm -f "index.html" + cp -r /source/build/ . + +fi