From 70a170af3518afaaf6b47a0d6c788bf618dc95a3 Mon Sep 17 00:00:00 2001 From: "Florian Meissner, DL1MRV" Date: Thu, 13 Jul 2023 11:52:27 +0200 Subject: [PATCH] Handling of service specific nginx config --- backend | 2 +- docker-compose.yml | 36 ++++++++-------- nginx/etc/nginx/templates/README.md | 43 +++++++++++++++++++ .../default.conf.template} | 4 +- 4 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 nginx/etc/nginx/templates/README.md rename nginx/etc/nginx/{conf.d/default.conf => templates/default.conf.template} (96%) diff --git a/backend b/backend index d2e5027..453ecef 160000 --- a/backend +++ b/backend @@ -1 +1 @@ -Subproject commit d2e502712acac5c1f50bfe94fc60d2595f2a6a61 +Subproject commit 453ecef4e8e015de60bf4dfc707a264ef91895bc diff --git a/docker-compose.yml b/docker-compose.yml index f8a6362..c2a6be3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,50 +30,52 @@ version: '3.8' services: - nginx: - container_name: adb-nginx + backend-nginx: + container_name: european-airports_api-nginx build: context: ./nginx args: NGINX_VERSION: ${NGINX_VERSION} - image: fm/adb-nginx + image: european-airports/api-nginx restart: always ports: - 8080:80 depends_on: - - php - env_file: ./nginx/nginx.env + - backend-php + env_file: + - ./nginx/nginx.env + - ./backend/nginx.env volumes: - - ./src/:/var/www/html + - ./backend/src/:/var/www/html networks: - backend - web - php: - container_name: adb-php + backend-php: + container_name: european-airports_api-php build: context: ./php-fpm args: PHP_VERSION: ${PHP_VERSION} - image: fm/adb-php-fpm + image: european-airports/api-php-fpm restart: always env_file: ./php-fpm/php.env volumes: - - ./src/:/var/www/html + - ./backend/src/:/var/www/html networks: - backend - secrets: - - vereinsflieger +# secrets: +# - networks: backend: driver: bridge - name: "adb-backend" + name: "european-airports/backend" web: driver: bridge - name: "adb-web" + name: "european-airports/web" -secrets: - vereinsflieger: - file: ./secrets/vereinsflieger.txt +# secrets: +# vereinsflieger: +# file: ./secrets/vereinsflieger.txt diff --git a/nginx/etc/nginx/templates/README.md b/nginx/etc/nginx/templates/README.md new file mode 100644 index 0000000..6107273 --- /dev/null +++ b/nginx/etc/nginx/templates/README.md @@ -0,0 +1,43 @@ +**************************************************************************************************** +* ______ _ _ * +* | ____| /\ (_) | | * +* | |__ _ _ _ __ ___ _ __ ___ __ _ _ __ / \ _ _ __ _ __ ___ _ __| |_ ___ * +* | __|| | | | '__/ _ \| '_ \ / _ \/ _` | '_ \ / /\ \ | | '__| '_ \ / _ \| '__| __/ __| * +* | |___| |_| | | | (_) | |_) | __/ (_| | | | | / ____ \| | | | |_) | (_) | | | |_\__ \ * +* |______\__,_|_| \___/| .__/ \___|\__,_|_| |_| /_/ \_\_|_| | .__/ \___/|_| \__|___/ * +* | | | | * +* |_| |_| * +* * +**************************************************************************************************** + +This file is part of the European Airports Project, a free, collaborative platform of airport data +extending beyond the official AIPs. + +Copyright (C) 2023 + +Florian Meissner + +This program is free software: you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the Free Software Foundation, either +version 3 of the License, or (at your option) any later version. This program is distributed in the +hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. You should have received a copy of the GNU General Public License along with this program. +(license.md in the root folder of this project) If not, see . + + +# Description of templates + +This folder contains configuration templates for nginx to tailor it to the needs of specific +services. The idea behind it is, that one nginx image can be used for multiple service containers. + +Each file ending with *.template should be a valid nginx configration file. The difference is that +it may contain environment variables in the form of `${VAR_NAME}`. These variables will be +substituted by docker environment variables and a regular nginx config file will be placed under +`/etc/nginx/conf.d` with the same name as the template except for the `*.template` extension. + +# Further reading + +- [Nginx docker Readme](https://github.com/docker-library/docs/tree/master/nginx#using-environment- + variables-in-nginx-configuration-new-in-119) +- [Explaining post from ServerFault](https://serverfault.com/a/755541) diff --git a/nginx/etc/nginx/conf.d/default.conf b/nginx/etc/nginx/templates/default.conf.template similarity index 96% rename from nginx/etc/nginx/conf.d/default.conf rename to nginx/etc/nginx/templates/default.conf.template index 7b082ac..76105a2 100644 --- a/nginx/etc/nginx/conf.d/default.conf +++ b/nginx/etc/nginx/templates/default.conf.template @@ -29,12 +29,12 @@ server { listen 80; root /var/www/html; - server_name adb.european-airports.org; + server_name ${NGINX_HOST} index index.php; location ~ \.php$ { include fastcgi_params; - fastcgi_pass php:9000; + fastcgi_pass ${PHP_HOST}:9000; fastcgi_index index.php; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;