Completely untie the backend from the frontend.

Build nginx and mariadb together with the app image.
Upgrade docker-compose configuration to 3 version.
Add cleanup step to the gitlab-ci.
This commit is contained in:
ErickSkrauch
2019-04-06 15:52:23 +02:00
parent e13b6f0d94
commit f33439d829
21 changed files with 302 additions and 81 deletions

View File

@@ -0,0 +1,66 @@
server {
listen 80;
set $root_path '/var/www/html';
set $frontend_path '${root_path}/frontend';
root $root_path;
charset utf-8;
add_header X-Frame-Options "sameorigin" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
# You can uncomment the next lines to enable debug mode
# rewrite_log on;
# error_log /var/log/nginx/error.log debug;
set $request_url $request_uri;
set $host_with_uri '${host}${request_uri}';
if ($host_with_uri ~ '^${AUTHSERVER_HOST}/auth') {
set $request_url '/api/authserver${request_uri}';
rewrite ^/auth /api/authserver$uri last;
}
if ($host_with_uri ~ '^${AUTHSERVER_HOST}/session') {
set $request_url '/api/minecraft${request_uri}';
rewrite ^/session /api/minecraft$uri last;
}
if ($host_with_uri ~ '^${AUTHSERVER_HOST}/api/(user|profiles)') {
set $request_url '/api/mojang${request_uri}';
rewrite ^/api/(user|profiles) /api/mojang$uri last;
}
location / {
root $frontend_path;
access_log off;
etag on;
expires $cache_duration;
try_files $uri /index.html =404;
}
location /api {
try_files $uri /api/index.php$is_args$args;
}
location /images/emails/assets {
alias '${root_path}/vendor/ely/email-renderer/dist/assets';
access_log off;
}
location ~* \.php$ {
fastcgi_pass php; # Use generated upstream. See generate-upstream.sh
fastcgi_index /index.php;
fastcgi_cache cache;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_url;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
# Override HTTPS param to handle ssl from nginx-proxy container
fastcgi_param HTTPS $http_x_forwarded_ssl if_not_empty;
}
}

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env sh
generate-upstream
envsubst '$AUTHSERVER_HOST' < /etc/nginx/conf.d/account.ely.by.conf.template > /etc/nginx/conf.d/default.conf
exec "$@"

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env sh
result="upstream php {"
for x in $(echo $PHP_SERVERS | tr "," "\n"); do
parts=$(echo $x | tr "x" "\n")
host=$(echo $parts | awk '{print $1}')
weight=$(echo $parts | awk '{print $2}')
result="$result\n server $host weight=${weight:-1};"
done
result="$result\n}"
echo -e $result > /etc/nginx/conf.d/upstream.conf

33
docker/nginx/nginx.conf Normal file
View File

@@ -0,0 +1,33 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 10;
fastcgi_cache_path /data/nginx/cache levels=1:2 keys_zone=cache:128m inactive=600m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
map $uri $cache_duration {
"~*^.+\.(jpe?g|gif|png|svg|js|json|css|zip|rar|eot|ttf|woff|woff2|ico|xml)$" "max";
default "off";
}
include /etc/nginx/conf.d/*.conf;
}