private fork from github

This commit is contained in:
soneill 2020-08-30 19:59:19 +12:00
commit ddcacca5c3
37 changed files with 5748 additions and 0 deletions

2
static/crontab.txt Executable file
View file

@ -0,0 +1,2 @@
* * * * * cd /var/www/html/pathfinder;sudo -u nobody php index.php /cron >> /var/log/cron.log 2>&1

9
static/entrypoint.sh Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
envsubst '$DOMAIN' </etc/nginx/sites_enabled/templateSite.conf >/etc/nginx/sites_enabled/site.conf
envsubst '$CONTAINER_NAME' </etc/nginx/templateNginx.conf >/etc/nginx/nginx.conf
envsubst </var/www/html/pathfinder/app/templateEnvironment.ini >/var/www/html/pathfinder/app/environment.ini
envsubst </var/www/html/pathfinder/app/templateConfig.ini >/var/www/html/pathfinder/app/config.ini
envsubst </etc/zzz_custom.ini >/etc/php7/conf.d/zzz_custom.ini
htpasswd -c -b -B /etc/nginx/.setup_pass pf "$APP_PASSWORD"
exec "$@"

451
static/menu.sh Normal file
View file

@ -0,0 +1,451 @@
#!/bin/bash
##
# Pure BASH interactive CLI/TUI menu (single and multi-select/checkboxes)
#
# Author: Markus Geiger <mg@evolution515.net>
# Last revised 2011-09-11
#
# ATTENTION! TO BE REFACTORED! FIRST DRAFT!
#
# Demo
#
# - ASCIINEMA
# https://asciinema.org/a/Y4hLxnN20JtAlrn3hsC6dCRn8
#
# Inspired by
#
# - https://serverfault.com/questions/144939/multi-select-menu-in-bash-script
# - Copyright (C) 2017 Ingo Hollmann - All Rights Reserved
# https://www.bughunter2k.de/blog/cursor-controlled-selectmenu-in-bash
#
# Notes
#
# - This is a hacky first implementation for my shell tools/dotfiles (ZSH)
# - Intention is to use it for CLI wizards (my aim is NOT a full blown curses TUI window interface)
# - I concerted TPUT to ANSII-sequences to spare command executions (e.g. `tput ed | xxd`)
# reference: http://linuxcommand.org/lc3_adv_tput.php
#
# Permission to copy and modify is granted under the Creative Commons Attribution 4.0 license
#
# Strict bash scripting (not yet)
# set -euo pipefail -o errtrace
# Templates for ui_widget_select
declare -xr UI_WIDGET_SELECT_TPL_SELECTED='\e[33m → %s \e[39m'
declare -xr UI_WIDGET_SELECT_TPL_DEFAULT=" \e[37m%s %s\e[39m"
declare -xr UI_WIDGET_MULTISELECT_TPL_SELECTED="\e[33m → %s %s\e[39m"
declare -xr UI_WIDGET_MULTISELECT_TPL_DEFAULT=" \e[37m%s %s\e[39m"
declare -xr UI_WIDGET_TPL_CHECKED="▣"
declare -xr UI_WIDGET_TPL_UNCHECKED="□"
# We use env variable to pass results since no interactive output from subshells and we don't wanna go hacky!
declare -xg UI_WIDGET_RC=-1
##
# Get type of a BASH variable (BASH ≥v4.0)
#
# Notes
# - if references are encountered it will automatically try
# to resolve them unless '-f' is passed!
# - resolving functions can be seen as bonus since they also
# use `declare` (but with -fF). this behavior should be removed!
# - bad indicates bad referencing which normally shouldn't occur!
# - types are shorthand and associative arrays map to "map" for convenience
#
# argument
# -f (optional) force resolvement of first hit
# <variable-name> Variable name
#
# stdout
# (nil|number|array|map|reference)
#
# stderr
# -
#
# return
# 0 - always
typeof() {
# __ref: avoid local to overwrite global var declaration and therefore emmit wrong results!
local type="" resolve_ref=true __ref="" signature=()
if [[ "$1" == "-f" ]]; then
# do not resolve reference
resolve_ref=false; shift;
fi
__ref="$1"
while [[ -z "${type}" ]] || ( ${resolve_ref} && [[ "${type}" == *n* ]] ); do
IFS=$'\x20\x0a\x3d\x22' && signature=($(declare -p "$__ref" 2>/dev/null || echo "na"))
if [[ ! "${signature}" == "na" ]]; then
type="${signature[1]}" # could be -xn!
fi
if [[ -z "${__ref}" ]] || [[ "${type}" == "na" ]] || [[ "${type}" == "" ]]; then
printf "nil"
return 0
elif [[ "${type}" == *n* ]]; then
__ref="${signature[4]}"
fi
done
case "$type" in
*i*) printf "number";;
*a*) printf "array";;
*A*) printf "map";;
*n*) printf "reference";;
*) printf "string";;
esac
}
##
# Removes a value from an array
#
# alternatives
# array=( "${array[@]/$delete}"
#
# arguments
# arg1 value
# arg* list or stdin
#
# stdout
# list with space seperator
array_without_value() {
local args=() value="${1}" s
shift
for s in "${@}"; do
if [ "${value}" != "${s}" ]; then
args+=("${s}")
fi
done
echo "${args[@]}"
}
##
# check if a value is in an array
#
# alternatives
# array=( "${array[@]/$delete}"
#
# arguments
# arg1 value
# arg* list or stdin
#
# stdout
# list with space seperator
array_contains_value() {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
##
# BASH only string to hex
#
# stdout
# hex squence
str2hex_echo() {
# USAGE: hex_repr=$(str2hex_echo "ABC")
# returns "0x410x420x43"
local str=${1:-$(cat -)}
local fmt=""
local chr
local -i i
printf "0x"
for i in `seq 0 $((${#str}-1))`; do
chr=${str:i:1}
printf "%x" "'${chr}"
done
}
##
# Read key and map to human readable output
#
# notes
# output prefix (concated by `-`)
# c ctrl key
# a alt key
# c-a ctrl+alt key
# use F if you mean shift!
# uppercase `f` for `c+a` combination is not possible!
#
# arguments
# -d for debugging keycodes (hex output via xxd)
# -l lowercase all chars
# -l <timeout> timeout
#
# stdout
# mapped key code like in notes
ui_key_input() {
local key
local ord
local debug=0
local lowercase=0
local prefix=''
local args=()
local opt
while (( "$#" )); do
opt="${1}"
shift
case "${opt}" in
"-d") debug=1;;
"-l") lowercase=1;;
"-t") args+=(-t $1); shift;;
esac
done
IFS= read ${args[@]} -rsn1 key 2>/dev/null >&2
read -sN1 -t 0.0001 k1; read -sN1 -t 0.0001 k2; read -sN1 -t 0.0001 k3
key+="${k1}${k2}${k3}"
if [[ "${debug}" -eq 1 ]]; then echo -n "${key}" | str2hex_echo; echo -n " : " ;fi;
case "${key}" in
'') key=enter;;
' ') key=space;;
$'\x1b') key=esc;;
$'\x1b\x5b\x36\x7e') key=pgdown;;
$'\x1b\x5b\x33\x7e') key=erase;;
$'\x7f') key=backspace;;
$'\e[A'|$'\e0A '|$'\e[D'|$'\e0D') key=up;;
$'\e[B'|$'\e0B'|$'\e[C'|$'\e0C') key=down;;
$'\e[1~'|$'\e0H'|$'\e[H') key=home;;
$'\e[4~'|$'\e0F'|$'\e[F') key=end;;
$'\e') key=enter;;
$'\e'?) prefix="a-"; key="${key:1:1}";;
esac
# only lowercase if we have a single letter
# ctrl key is hidden within char code (no o)
if [[ "${#key}" == 1 ]]; then
ord=$(LC_CTYPE=C printf '%d' "'${key}")
if [[ "${ord}" -lt 32 ]]; then
prefix="c-${prefix}"
# ord=$(([##16] ord + 0x60))
# let "ord = [##16] ${ord} + 0x60"
ord="$(printf "%X" $((ord + 0x60)))"
key="$(printf "\x${ord}")"
fi
if [[ "${lowercase}" -eq 1 ]]; then
key="${key,,}"
fi
fi
echo "${prefix}${key}"
}
##
# UI Widget Select
#
# arguments
# -i <[menu-item(s)] …> menu items
# -m activate multi-select mode (checkboxes)
# -k <[key(s)] …> keys for menu items (if none given indexes are used)
# -s <[selected-keys(s)] …> selected keys (index or key)
# if keys are used selection needs to be keys
# -c clear complete menu on exit
# -l clear menu and leave selections
#
# env
# UI_WIDGET_RC will be selected index or -1 of nothing was selected
#
# stdout
# menu display - don't use subshell since we need interactive shell and use tput!
#
# stderr
# sometimes (trying to clean up)
#
# return
# 0 success
# -1 cancelled
ui_widget_select() {
local menu=() keys=() selection=() selection_index=()
local cur=0 oldcur=0 collect="item" select="one"
local sel="" marg="" drawn=false ref v=""
local opt_clearonexit=false opt_leaveonexit=false
export UI_WIDGET_RC=-1
while (( "$#" )); do
opt="${1}"; shift
case "${opt}" in
-k) collect="key";;
-i) collect="item";;
-s) collect="selection";;
-m) select="multi";;
-l) opt_clearonexit=true; opt_leaveonexit=true;;
-c) opt_clearonexit=true;;
*)
if [[ "${collect}" == "selection" ]]; then
selection+=("${opt}")
elif [[ "${collect}" == "key" ]]; then
keys+=("${opt}")
else
menu+=("$opt")
fi;;
esac
done
# sanity check
if [[ "${#menu[@]}" -eq 0 ]]; then
>&2 echo "no menu items given"
return 1
fi
if [[ "${#keys[@]}" -gt 0 ]]; then
# if keys are used
# sanity check
if [[ "${#keys[@]}" -gt 0 ]] && [[ "${#keys[@]}" != "${#menu[@]}" ]]; then
>&2 echo "number of keys do not match menu options!"
return 1
fi
# map keys to indexes
selection_index=()
for sel in "${selection[@]}"; do
for ((i=0;i<${#keys[@]};i++)); do
if [[ "${keys[i]}" == "${sel}" ]]; then
selection_index+=("$i")
fi
done
done
else
# if no keys are used assign by indexes
selection_index=(${selection[@]})
fi
clear_menu() {
local str=""
for i in "${menu[@]}"; do str+="\e[2K\r\e[1A"; done
echo -en "${str}"
}
##
# draws menu in three different states
# - initial: draw every line as intenden
# - update: only draw updated lines and skip existing
# - exit: only draw selected lines
draw_menu() {
local mode="${initial:-$1}" check=false check_tpl="" str="" msg="" tpl_selected="" tpl_default="" marg=()
if ${drawn} && [[ "$mode" != "exit" ]]; then
# reset position
str+="\r\e[2K"
for i in "${menu[@]}"; do str+="\e[1A"; done
# str+="${TPUT_ED}"
fi
if [[ "$select" == "one" ]]; then
tpl_selected="$UI_WIDGET_SELECT_TPL_SELECTED"
tpl_default="$UI_WIDGET_SELECT_TPL_DEFAULT"
else
tpl_selected="$UI_WIDGET_MULTISELECT_TPL_SELECTED"
tpl_default="$UI_WIDGET_MULTISELECT_TPL_DEFAULT"
fi
for ((i=0;i<${#menu[@]};i++)); do
check=false
if [[ "$select" == "one" ]]; then
# single selection
marg=("${menu[${i}]}")
if [[ ${cur} == ${i} ]]; then
check=true
fi
else
# multi-select
check_tpl="$UI_WIDGET_TPL_UNCHECKED";
if array_contains_value "$i" "${selection_index[@]}"; then
check_tpl="$UI_WIDGET_TPL_CHECKED"; check=true
fi
marg=("${check_tpl}" "${menu[${i}]}")
fi
if [[ "${mode}" != "exit" ]] && [[ ${cur} == ${i} ]]; then
str+="$(printf "\e[2K${tpl_selected}" "${marg[@]}")\n";
elif ([[ "${mode}" != "exit" ]] && ([[ "${oldcur}" == "${i}" ]] || [[ "${mode}" == "initial" ]])) || (${check} && [[ "${mode}" == "exit" ]]); then
str+="$(printf "\e[2K${tpl_default}" "${marg[@]}")\n";
elif [[ "${mode}" -eq "update" ]] && [[ "${mode}" != "exit" ]]; then
str+="\e[1B\r"
fi
done
echo -en "${str}"
export drawn=true
}
# initial draw
draw_menu initial
# action loop
while true; do
oldcur=${cur}
key=$(ui_key_input)
case "${key}" in
up|left|i|j) ((cur > 0)) && ((cur--));;
down|right|k|l) ((cur < ${#menu[@]}-1)) && ((cur++));;
home) cur=0;;
pgup) let cur-=5; if [[ "${cur}" -lt 0 ]]; then cur=0; fi;;
pgdown) let cur+=5; if [[ "${cur}" -gt $((${#menu[@]}-1)) ]]; then cur=$((${#menu[@]}-1)); fi;;
end) ((cur=${#menu[@]}-1));;
space)
if [[ "$select" == "one" ]]; then
continue
fi
if ! array_contains_value "$cur" "${selection_index[@]}"; then
selection_index+=("$cur")
else
selection_index=($(array_without_value "$cur" "${selection_index[@]}"))
fi
;;
enter)
if [[ "${select}" == "multi" ]]; then
export UI_WIDGET_RC=()
for i in ${selection_index[@]}; do
if [[ "${#keys[@]}" -gt 0 ]]; then
export UI_WIDGET_RC+=("${keys[${i}]}")
else
export UI_WIDGET_RC+=("${i}")
fi
done
else
if [[ "${#keys[@]}" -gt 0 ]]; then
export UI_WIDGET_RC="${keys[${cur}]}";
else
export UI_WIDGET_RC=${cur};
fi
fi
if $opt_clearonexit; then clear_menu; fi
if $opt_leaveonexit; then draw_menu exit; fi
return
;;
[1-9])
let "cur = ${key}"
if [[ ${#menu[@]} -gt 9 ]]; then
echo -n "${key}"
sleep 1
key="$(ui_key_input -t 0.5 )"
if [[ "$key" =~ [0-9] ]]; then
let "cur = cur * 10 + ${key}"
elif [[ "$key" != "enter" ]]; then
echo -en "\e[2K\r$key invalid input!"
sleep 1
fi
fi
let "cur = cur - 1"
if [[ ${cur} -gt ${#menu[@]}-1 ]]; then
echo -en "\e[2K\rinvalid index!"
sleep 1
cur="${oldcur}"
fi
echo -en "\e[2K\r"
;;
esc|q|$'\e')
if $opt_clearonexit; then clear_menu; fi
return 1;;
esac
# Redraw menu
draw_menu update
done
}

247
static/nginx/nginx.conf Executable file
View file

@ -0,0 +1,247 @@
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user nobody nobody;
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
# offers the best performance. Don't set it higher than the number of CPU
# cores if changing this parameter.
# The maximum number of connections for Nginx is calculated by:
# max_clients = worker_processes * worker_connections
# (2 Cores = 4 processes) check cores: grep processor /proc/cpuinfo | wc -l
#worker_processes auto;
worker_processes 4;
# Maximum open file descriptors per process;
# should be > worker_connections.
worker_rlimit_nofile 20000;
events {
# The worker_connections command tells our worker processes how many people can simultaneously be served by Nginx.
# When you need > 8000 * cpu_cores connections, you start optimizing your OS,
# and this is probably the point at which you hire people who are smarter than
# you, as this is *a lot* of requests.
# worker_connections 768;
worker_connections 19000;
multi_accept on;
use epoll;
}
# Default error log file
# (this is only used when you don't override error_log on a server{} level)
error_log /var/lib/nginx/error.log warn;
pid /var/run/nginx.pid;
http {
# Hide nginx version information.
server_tokens on;
# Define the MIME types for files.
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Update charset_types due to updated mime.types
charset_types text/css text/plain text/vnd.wap.wml application/javascript application/json application/rss+xml application/xml;
# Speed up file transfers by using sendfile() to copy directly
# between descriptors rather than using read()/write().
# For performance reasons, on FreeBSD systems w/ ZFS
# this option should be disabled as ZFS's ARC caches
# frequently used files in RAM by default.
sendfile on;
# Tell Nginx not to send out partial frames; this increases throughput
# since TCP frames are filled up before being sent out. (adds TCP_CORK)
tcp_nopush off;
# Send packages immediately (on). Otherwise nginx will "wait" 200ms for additional data to fullfill a package.
tcp_nodelay on;
# Timeouts ==================================================================================================================
# 'Body' and 'Header' max response timings. If neither a body or header is sent, the server will issue a 408 error or Request time out. (Default: 60s)
client_body_timeout 12;
client_header_timeout 12;
# Assigns the timeout for keep-alive connections with the client.
# Simply put, Nginx will close connections with the client after this period of time.(Default: 65)
keepalive_timeout 20s;
# Finally, the send_timeout is established not on the entire transfer of answer, but only between two operations of reading;
# if after this time client will take nothing, then Nginx is shutting down the connection.
send_timeout 10s;
# Sets a timeout for name resolution. (Default: 30s)
resolver_timeout 5s;
# Timeout period for connection with FastCGI-server. It should be noted that this value can't exceed 75 seconds. (Default: 60s)
fastcgi_connect_timeout 5s;
# Amount of time for upstream to wait for a fastcgi process to send data.
# Change this directive if you have long running fastcgi processes that do not produce output until they have finished processing.
# If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate. (Default: 60s)
fastcgi_read_timeout 40s;
# Request timeout to the server. The timeout is calculated between two write operations, not for the whole request.
# If no data have been written during this period then serve closes the connection. (Default: 60s)
fastcgi_send_timeout 15s;
# WebSockets ===============================================================================================================
# Buffer ====================================================================================================================
# Similar to the previous directive, only instead it handles the client header size.
# For all intents and purposes, 1K is usually a decent size for this directive.
client_header_buffer_size 1k;
# The maximum number and size of buffers for large client headers.
large_client_header_buffers 4 4k;
# The maximum allowed size for a client request. If the maximum size is exceeded, then Nginx will spit out a 413 error or Request Entity Too Large. (Default: 1m)
# php max upload limit cannot be larger than this
client_max_body_size 8m;
# This handles the client buffer size, meaning any POST actions sent to Nginx. POST actions are typically form submissions.
client_body_buffer_size 32k;
output_buffers 2 32k;
fastcgi_buffering on;
fastcgi_buffers 8 32k;
fastcgi_buffer_size 32k;
# Caching ==================================================================================================================
# Above sample tells nginx to cache a file information as long as minimum 2 requests are made during 5m window.
open_file_cache max=10000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
# Fast CGI
# fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=MYAPP:100m inactive=60m;
# fastcgi_cache_key "$scheme$request_method$host$request_uri";
# Logging ===================================================================================================================
# Format to use in log files
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# Extended Logging (e.g. for Nginx Aplify log graphs)
log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" sn="$server_name" '
'rt=$request_time '
'ua="$upstream_addr" us="$upstream_status" '
'ut="$upstream_response_time" ul="$upstream_response_length" '
'cs=$upstream_cache_status' ;
# This excludes 2xx and 3xx status codes from beeing loged
map $status $loggable {
~^[23] 0;
default 1;
}
# logs just 5xxx errors
map $status $log_production {
~^[1234] 0;
default 1;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server ${CONTAINER_NAME}-socket:8020;
}
# Default log file
# (this is only used when you don't override access_log on a server{} level)
access_log /var/log/nginx/access.log main if=$loggable;
# Compression ===============================================================================================================
# Enable Gzip compressed.
gzip on;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;
# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is bad as that usually leads to
# larger files after gzipping).
gzip_min_length 256;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
# gzip_proxied expired no-cache no-store private auth;
gzip_proxied any;
# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
gzip_vary on;
# Compress all output labeled with one of the following MIME-types.
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# text/html;
# This should be turned on if you are going to have pre-compressed copies (.gz) of
# static files available. If not it should be left off as it will cause extra I/O
# for the check. It is best if you enable this in a location{} block for
# a specific directory, or on an individual server{} level.
gzip_static off;
proxy_buffers 16 16k;
proxy_buffer_size 16k;
# Include files in the sites-enabled folder. server{} configuration files should be
# placed in the sites-available folder, and then the configuration should be enabled
# by creating a symlink to it in the sites-enabled folder.
# See doc/sites-enabled.md for more info.
# include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites_enabled/*.conf;
}

89
static/nginx/site.conf Executable file
View file

@ -0,0 +1,89 @@
server {
listen 80;
listen [::]:80;
#listen [::]:80 default_server ipv6only=on;
server_name $DOMAIN;
# Path to static files
root /var/www/html/pathfinder/;
index index.php index.html index.htm;
# Specify a charset
charset utf-8;
# Logging ===================================================================================================================
location = /setup {
auth_basic "Setup Login";
auth_basic_user_file /etc/nginx/.setup_pass;
try_files $uri $uri/ /index.php?$query_string;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.php
try_files $uri $uri/ /index.php?q=$uri&$args;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/lib/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}
# deny access to . files, for security
#
location ~ /\. {
log_not_found off;
deny all;
}
location /ws/map/update {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 8h;
proxy_send_timeout 5s;
proxy_connect_timeout 3s;
proxy_buffering off;
}
# static sources
location /public/ {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10s;
sendfile_max_chunk 512k;
}
}

View file

@ -0,0 +1,60 @@
; Environment Config
[ENVIRONMENT]
; project environment (DEVELOP || PRODUCTION).
; This effects: DB connection, Mail-Server, SSO, ESI configurations in this file
; configuration below
SERVER = PRODUCTION
[ENVIRONMENT.PRODUCTION]
; path to index.php (Default: leave blank == "auto-detect")
; -> e.g. set /pathfinder if your URL looks like https://www.[YOUR_DOMAIN]/pathfinder (subfolder)
BASE =
; deployment URL (e.g. https://www.pathfinder-w.space)
URL = {{@SCHEME}}://$DOMAIN
; level of debug/error stack trace
DEBUG = 0
; Pathfinder database
DB_PF_DNS = mysql:host=${CONTAINER_NAME}db;port=3306;dbname=
DB_PF_NAME = pf
DB_PF_USER = root
DB_PF_PASS = $MYSQL_PASSWORD
; Universe data (New Eden) cache DB for ESI API respons
DB_UNIVERSE_DNS = mysql:host=${CONTAINER_NAME}db;port=3306;dbname=
DB_UNIVERSE_NAME = eve_universe
DB_UNIVERSE_USER = root
DB_UNIVERSE_PASS = $MYSQL_PASSWORD
; EVE-Online CCP Database export
DB_CCP_DNS = mysql:host=${CONTAINER_NAME}db;port=3306;dbname=
DB_CCP_NAME = eve_lifeblood_min
DB_CCP_USER = root
DB_CCP_PASS = $MYSQL_PASSWORD
; CCP SSO
CCP_SSO_URL = https://login.eveonline.com
CCP_SSO_CLIENT_ID = $CCP_SSO_CLIENT_ID
CCP_SSO_SECRET_KEY = $CCP_SSO_SECRET_KEY
CCP_SSO_DOWNTIME = 11:00
; CCP ESI API
CCP_ESI_URL = https://esi.evetech.net
CCP_ESI_DATASOURCE = tranquility
CCP_ESI_SCOPES = $CCP_ESI_SCOPES
CCP_ESI_SCOPES_ADMIN =
; SMTP settings (optional)
SMTP_HOST = localhost
SMTP_PORT = 25
SMTP_SCHEME = TLS
SMTP_USER =
SMTP_PASS =
SMTP_FROM = registration@pathfinder-w.space
SMTP_ERROR = admin@pathfinder-w.space
; TCP Socket configuration (optional) (advanced)
SOCKET_HOST = ${CONTAINER_NAME}-socket
SOCKET_PORT = 5555

View file

@ -0,0 +1,27 @@
; Route config
[routes]
; DB setup setup
; IMPORTANT: remove/comment this line after setup/update is finished!
GET @setup: /setup [sync] = {{ @NAMESPACE }}\Controller\Setup->init
; login (index) page
GET @login: / [sync] = {{ @NAMESPACE }}\Controller\AppController->init
; CCP SSO redirect
GET @sso: /sso/@action [sync] = {{ @NAMESPACE }}\Controller\Ccp\Sso->@action
; map page
GET @map: /map* [sync] = {{ @NAMESPACE }}\Controller\MapController->init
; admin panel
GET @admin: /admin* [sync] = {{ @NAMESPACE }}\Controller\Admin->dispatch
; AJAX API wildcard endpoints (not cached, throttled)
GET|POST /api/@controller/@action [ajax] = {{ @NAMESPACE }}\Controller\Api\@controller->@action, 0, 512
GET|POST /api/@controller/@action/@arg1 [ajax] = {{ @NAMESPACE }}\Controller\Api\@controller->@action, 0, 512
GET|POST /api/@controller/@action/@arg1/@arg2 [ajax] = {{ @NAMESPACE }}\Controller\Api\@controller->@action, 0, 512
; onUnload route or final map sync (@see https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon)
POST /api/Map/updateUnloadData = {{ @NAMESPACE }}\Controller\Api\Map->updateUnloadData, 0, 512
[maps]
; REST API wildcard endpoints (not cached, throttled)
/api/rest/@controller* [ajax] = {{ @NAMESPACE }}\Controller\Api\Rest\@controller, 0, 512
/api/rest/@controller/@id [ajax] = {{ @NAMESPACE }}\Controller\Api\Rest\@controller, 0, 512

40
static/php/fpm-pool.conf Executable file
View file

@ -0,0 +1,40 @@
[global]
; Log to stderr
error_log = /dev/stderr
[www]
user = nobody
group = nobody
; Enable status page
pm.status_path = /fpm-status
; Ondemand process manager
pm = ondemand
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 50
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500
; Make sure the FPM workers can reach the environment variables for configuration
clear_env = no
; Catch output from PHP
catch_workers_output = yes

14
static/php/php.ini Executable file
View file

@ -0,0 +1,14 @@
upload_max_filesize = 100M
post_max_size = 108M
max_input_vars = 3000
html_errors = 0
cgi.force_redirect=0
cgi.fix_pathinfo=1
fastcgi.impersonate=1
fastcgi.logging=0
request_terminate_timeout = 300
session.save_handler = redis
session.save_path = "tcp://${CONTAINER_NAME}-redis:6379"
[Date]
date.timezone="UTC"

24
static/supervisord.conf Executable file
View file

@ -0,0 +1,24 @@
[supervisord]
nodaemon=true
[program:php-fpm]
command=php-fpm7 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
startretries=0
[program:nginx]
command=nginx -g 'daemon off;'
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=true
startretries=0
[program:cron]
command = /usr/sbin/crond -f -l 8
autostart=true
autorestart=true