feat: local test with nginx docker

This commit is contained in:
Aliberk Sandıkçı 2023-12-21 00:37:07 +03:00
parent a8bb2d0dc9
commit 56531810b7
Signed by: asandikci
GPG Key ID: 25C67A03B5666BC1
1 changed files with 34 additions and 0 deletions

34
nginx_docker_localtest.sh Executable file
View File

@ -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