From c7231d648c9a1d00a49e306ed3ce4491b44a8a6d Mon Sep 17 00:00:00 2001 From: Florian Meissner Date: Fri, 14 Jul 2023 22:17:12 +0200 Subject: [PATCH] Added proxy and PMA for dev --- .env | 3 ++ .gitignore | 9 ++-- docker-compose.dev.yml | 110 +++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 31 +++++++++--- 4 files changed, 142 insertions(+), 11 deletions(-) create mode 100644 docker-compose.dev.yml diff --git a/.env b/.env index 9d2a6db..d426402 100644 --- a/.env +++ b/.env @@ -33,3 +33,6 @@ NGINX_VERSION=1.23-alpine PHP_VERSION=8.2-fpm-alpine MARIADB_VERSION=10.11 +# Set base URL for the project. This will be used by Traefik. +#BASE_URL=european-airports.org +BASE_URL=localhost diff --git a/.gitignore b/.gitignore index 1be4c4b..c3a0be7 100644 --- a/.gitignore +++ b/.gitignore @@ -26,12 +26,15 @@ # (license.md in the root folder of this project) If not, see . -# Configuration files -config.php +# Log files +*.log # Docker Secrets **/secrets/*_pw.txt +# Backup files +*.bak + # Include all README files !**/README.md @@ -41,8 +44,6 @@ config.php .project .pydevproject -.bak - ### WINDOWS ### desktop.ini diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..7e44b21 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,110 @@ +# **************************************************************************************************** +# * ______ _ _ * +# * | ____| /\ (_) | | * +# * | |__ _ _ _ __ ___ _ __ ___ __ _ _ __ / \ _ _ __ _ __ ___ _ __| |_ ___ * +# * | __|| | | | '__/ _ \| '_ \ / _ \/ _` | '_ \ / /\ \ | | '__| '_ \ / _ \| '__| __/ __| * +# * | |___| |_| | | | (_) | |_) | __/ (_| | | | | / ____ \| | | | |_) | (_) | | | |_\__ \ * +# * |______\__,_|_| \___/| .__/ \___|\__,_|_| |_| /_/ \_\_|_| | .__/ \___/|_| \__|___/ * +# * | | | | * +# * |_| |_| * +# * * +# **************************************************************************************************** + +# 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 . + + +################################################################################################### +# # +# DEVELOPMENT ONLY !!! # +# ====================== # +# # +################################################################################################### + + +# DEVELOPMENT Docker-Compose file for services that cannot be related to any particular project. +# This file is only ment for development purposes. It features a limited amount of servies and only +# works on HTTP. + +# Variables for this file are automatically loaded from the .env file in this directory by the +# Docker daemon. + + +version: '3.6' + +services: + + # Traefik Proxy and Load Balancer + proxy: + container_name: proxy + image: traefik:2.9 + restart: unless-stopped + command: + - "--api.insecure=true" + - "--api.dashboard=true" + - "--providers.docker=true" + - "--providers.file=true" + - "--providers.file.watch=true" + - "--entrypoints.web.address=:80" + - "--log.filepath=/var/log/traefik/traefik.log" + - "--log.level=debug" + - "--accesslog=true" + - "--accesslog.filepath=/var/log/traefik/access.log" + ports: + - 80:80 + - 8080:8080 + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - ./traefik/logs:/var/log/traefik + - ./traefik/letsencrypt:/letsencrypt + labels: + - "traefik.enable=false" + networks: + - european-airports/web + - dev + + # Database GUI + phpmyadmin: + container_name: phpmyadmin + image: phpmyadmin + restart: unless-stopped + environment: + - PMA_HOST=database + - PMA_PMADB=phpmyadmin + labels: + - "traefik.http.routers.phpmyadmin.rule=Host(`pma.${BASE_URL}`)" + - "traefik.http.routers.phpmyadmin.entrypoints=web" + - "traefik.docker.network=development" + networks: + - european-airports/backend + - dev + + +networks: + + # European-Airports services, that will be exposed to the internet + european-airports/web: + name: "european-airports/web" + external: true + + # European-Airports services that are not exposed to the internet. + european-airports/backend: + name: "european-airports/backend" + external: true + + # Services that are used for development purposes. Exposed to the internet. + dev: + name: "development" + driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml index a49b361..ea1d278 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ version: '3.8' services: - + backend-nginx: container_name: european-airports_api-nginx build: @@ -38,8 +38,8 @@ services: NGINX_VERSION: ${NGINX_VERSION} image: european-airports/api-nginx restart: always - ports: - - 8080:80 +# ports: +# - 8080:80 depends_on: - backend-php env_file: @@ -50,7 +50,14 @@ services: networks: - backend - web - + labels: + - "traefik.http.routers.backend-nginx.rule=Host(`api.${BASE_URL}`)" + - "traefik.http.routers.backend-nginx.entrypoints=web" + - "traefik.http.routers.backend-nginx-secure.rule=Host(`api.${BASE_URL}`)" + - "traefik.http.routers.backend-nginx-secure.tls.certresolver=https-resolver" + - "traefik.http.routers.backend-nginx-secure.entrypoints=websecure" + - "traefik.docker.network=european-airports/web" + backend-php: container_name: european-airports_api-php build: @@ -71,6 +78,8 @@ services: secrets: - eaBackendUser - eaBackendPw + labels: + - "traefik.enable=false" frontend-nginx: container_name: european-airports_www-nginx @@ -80,8 +89,8 @@ services: NGINX_VERSION: ${NGINX_VERSION} image: european-airports/www-nginx restart: always - ports: - - 8081:80 +# ports: +# - 8081:80 depends_on: - frontend-php env_file: @@ -91,7 +100,13 @@ services: - ./frontend/src/:/var/www/html networks: - web - + labels: + - "traefik.http.routers.frontend-nginx.rule=Host(`www.${BASE_URL}`)" + - "traefik.http.routers.frontend-nginx.entrypoints=web" + - "traefik.http.routers.frontend-nginx-secure.rule=Host(`www.${BASE_URL}`)" + - "traefik.http.routers.frontend-nginx-secure.tls.certresolver=https-resolver" + - "traefik.http.routers.frontend-nginx-secure.entrypoints=websecure" + frontend-php: container_name: european-airports_www-php build: @@ -107,6 +122,8 @@ services: - ./frontend/src/:/var/www/html networks: - web + labels: + - "traefik.enable=false" database: container_name: european-airports_mariadb