#!/bin/bash # Nginx Docker Localtest CONT_NAME="IFLRANDEVU_NGINX_LOCALTEST" # nginx docker name MOUNT_PATH="/source" # binded mount path in nginx docker SCRIPT_NAME="nginx_docker_localtest.sh" # name of the *this* file ### REMOTE RELEASE ### LATEST_RELEASE="1.4.3-ifl.2" FILE_NAME="iflrandevu-$LATEST_RELEASE.zip" DOWNLOAD_LINK=https://git.aliberksandikci.com.tr/ifl/iflrandevu/releases/download/$LATEST_RELEASE/$FILE_NAME CONFIG_FILE_CONTENT=""" * @copyright Copyleft 2023 - 2024 * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 * @link https://iflpanel.com/about/iflrandevu * @since v1.4.3 * ---------------------------------------------------------------------------- */ /** * IFLRandevu Configuration File */ class Config { // ------------------------------------------------------------------------ // GENERAL SETTINGS // ------------------------------------------------------------------------ const BASE_URL = 'http://localhost:8000'; const LANGUAGE = 'turkish'; const DEBUG_MODE = TRUE; // ------------------------------------------------------------------------ // DATABASE SETTINGS // ------------------------------------------------------------------------ const DB_HOST = 'localhost'; const DB_NAME = 'iflrandevu'; const DB_USERNAME = 'root'; const DB_PASSWORD = 'root'; // ------------------------------------------------------------------------ // GOOGLE CALENDAR SYNC // ------------------------------------------------------------------------ const GOOGLE_SYNC_FEATURE = FALSE; // Enter TRUE or FALSE const GOOGLE_PRODUCT_NAME = ''; const GOOGLE_CLIENT_ID = ''; const GOOGLE_CLIENT_SECRET = ''; const GOOGLE_API_KEY = ''; } /* End of file config.php */ /* Location: ./config.php */ """ NGINX_CONFIG_FILE=""" server { listen 80; server_name localhost; location / { # alias /usr/share/nginx/html/; root /usr/share/nginx/html/; index index.php; # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file # client_max_body_size 50M; # try_files \$uri \$uri/ index.php; # location ~ [^/]\.php(/|\$) { # fastcgi_split_path_info ^(.+?\.php)(/.*)\$; # fastcgi_pass unix:/var/run/php/php8.2-fpm-iflrandevu.sock; # fastcgi_index index.php; # include fastcgi_params; # fastcgi_param REMOTE_USER \$remote_user; # fastcgi_param PATH_INFO \$fastcgi_path_info; # fastcgi_param SCRIPT_FILENAME \$request_filename; # } } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } """ ############################ ############################ _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/$SCRIPT_NAME docker${_NC}\`" docker attach $CONT_NAME --detach-keys="ctrl-k" echo "EXIT" exit elif [[ $1 == "attach" ]]; then docker start $CONT_NAME docker attach $CONT_NAME --detach-keys="ctrl-k" elif [[ $1 == "docker" ]]; then apt update apt install nano exa tree wget unzip less -y cd /usr/share/nginx/html # rm -f "50x.html" rm -f "index.html" if [[ $2 == "local" ]]; then cp -r /source/build/* /usr/share/nginx/html/ elif [[ $2 == "remote" ]]; then wget $DOWNLOAD_LINK unzip $FILE_NAME mv $FILE_NAME ../ else echo -e "${_RED}use docker local or docker remote${_NC}" fi ### CONFIGURATIONS ### apt install php php-fpm -y apt install mariadb-server -y service mariadb start mysql -u root -e "create database iflrandevu" echo -e "$CONFIG_FILE_CONTENT" >"config.php" echo -e "$NGINX_CONFIG_FILE" >"/etc/nginx/conf.d/default.conf" chmod 770 storage service nginx start service nginx status service nginx restart echo -e "${_RED}DONE! - OPEN localhost:8000 TO TEST${_NC}" fi # TODO Docker compose to run with /docker/build/docker.sh container together