From eed8b5d223c010f252fa8d41a482bbfdeda20b2b Mon Sep 17 00:00:00 2001 From: Adnan Shahzad Date: Sun, 3 Nov 2024 15:20:58 +0500 Subject: [PATCH] traefik tests --- .env | 2 +- standard-setup/backups/.gitkeep | 0 standard-setup/conf/.env-app.local | 20 ++++ standard-setup/conf/nginx.default.conf | 59 +++++++++++ standard-setup/conf/supervisord.conf | 32 ++++++ standard-setup/docker-compose.yml | 112 ++++++++++++++++++++ standard-setup/env/elasticsearch.env | 2 + standard-setup/env/mailtrap.env | 8 ++ standard-setup/env/pgadmin.env | 2 + standard-setup/env/phpfpm.env | 1 + standard-setup/env/postgres.env | 3 + standard-setup/env/rabbitmq.env | 5 + standard-setup/src/.gitkeep | 0 test/mood/.env | 1 + test/mood/acme.json | 0 test/mood/conf/.env-app.local | 20 ++++ test/mood/conf/nginx.default.conf | 59 +++++++++++ test/mood/conf/supervisord.conf | 32 ++++++ test/mood/docker-compose.yml | 139 +++++++++++++++++++++++++ test/mood/env/elasticsearch.env | 2 + test/mood/env/mailtrap.env | 8 ++ test/mood/env/pgadmin.env | 2 + test/mood/env/phpfpm.env | 1 + test/mood/env/postgres.env | 3 + test/mood/env/rabbitmq.env | 5 + test/mood/src/.env-app.local | 0 test/mood/src/public/index.php | 3 + test/mood/traefik.yml | 28 +++++ test/vibe/.env | 1 + test/vibe/acme.json | 0 test/vibe/conf/.env-app.local | 20 ++++ test/vibe/conf/nginx.default.conf | 59 +++++++++++ test/vibe/conf/supervisord.conf | 32 ++++++ test/vibe/docker-compose.yml | 138 ++++++++++++++++++++++++ test/vibe/env/elasticsearch.env | 2 + test/vibe/env/mailtrap.env | 8 ++ test/vibe/env/pgadmin.env | 2 + test/vibe/env/phpfpm.env | 1 + test/vibe/env/postgres.env | 3 + test/vibe/env/rabbitmq.env | 5 + test/vibe/src/.env-app.local | 0 test/vibe/src/public/index.php | 3 + test/vibe/traefik.yml | 15 +++ traefik.md | 125 ++++++++++++++++++++++ traefik.yml | 13 --- 45 files changed, 962 insertions(+), 14 deletions(-) create mode 100644 standard-setup/backups/.gitkeep create mode 100644 standard-setup/conf/.env-app.local create mode 100644 standard-setup/conf/nginx.default.conf create mode 100644 standard-setup/conf/supervisord.conf create mode 100644 standard-setup/docker-compose.yml create mode 100644 standard-setup/env/elasticsearch.env create mode 100644 standard-setup/env/mailtrap.env create mode 100644 standard-setup/env/pgadmin.env create mode 100644 standard-setup/env/phpfpm.env create mode 100644 standard-setup/env/postgres.env create mode 100644 standard-setup/env/rabbitmq.env create mode 100644 standard-setup/src/.gitkeep create mode 100644 test/mood/.env create mode 100644 test/mood/acme.json create mode 100644 test/mood/conf/.env-app.local create mode 100644 test/mood/conf/nginx.default.conf create mode 100644 test/mood/conf/supervisord.conf create mode 100644 test/mood/docker-compose.yml create mode 100644 test/mood/env/elasticsearch.env create mode 100644 test/mood/env/mailtrap.env create mode 100644 test/mood/env/pgadmin.env create mode 100644 test/mood/env/phpfpm.env create mode 100644 test/mood/env/postgres.env create mode 100644 test/mood/env/rabbitmq.env create mode 100644 test/mood/src/.env-app.local create mode 100644 test/mood/src/public/index.php create mode 100644 test/mood/traefik.yml create mode 100644 test/vibe/.env create mode 100644 test/vibe/acme.json create mode 100644 test/vibe/conf/.env-app.local create mode 100644 test/vibe/conf/nginx.default.conf create mode 100644 test/vibe/conf/supervisord.conf create mode 100644 test/vibe/docker-compose.yml create mode 100644 test/vibe/env/elasticsearch.env create mode 100644 test/vibe/env/mailtrap.env create mode 100644 test/vibe/env/pgadmin.env create mode 100644 test/vibe/env/phpfpm.env create mode 100644 test/vibe/env/postgres.env create mode 100644 test/vibe/env/rabbitmq.env create mode 100644 test/vibe/src/.env-app.local create mode 100644 test/vibe/src/public/index.php create mode 100644 test/vibe/traefik.yml create mode 100644 traefik.md diff --git a/.env b/.env index 7d42e62..cbaf9d7 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -COMPOSE_PROJECT_NAME=adnan +COMPOSE_PROJECT_NAME=mood diff --git a/standard-setup/backups/.gitkeep b/standard-setup/backups/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/standard-setup/conf/.env-app.local b/standard-setup/conf/.env-app.local new file mode 100644 index 0000000..882c70c --- /dev/null +++ b/standard-setup/conf/.env-app.local @@ -0,0 +1,20 @@ +ORO_DB_URL=postgres://root:root@postgres:5432/dev?sslmode=disable&charset=utf8&serverVersion=13.7 +ORO_DB_DSN=${ORO_DB_URL} + +MESSENGER_TRANSPORT_DSN=rabbitmq://rabbit:rabbit@rabbitmq:5672/%2f/messages + + +###> search engine config ### +ORO_SEARCH_URL=http://localhost:9200 +ORO_SEARCH_ENGINE_DSN=${ORO_SEARCH_URL}?prefix=oro_search +ORO_WEBSITE_SEARCH_ENGINE_DSN=${ORO_SEARCH_URL}?prefix=oro_website_search +###< search engine config ### + + +###> websocket config ### +ORO_WEBSOCKET_SERVER_DSN=//0.0.0.0:8080 +ORO_WEBSOCKET_FRONTEND_DSN=//*:8080/ws +ORO_WEBSOCKET_BACKEND_DSN=tcp://127.0.0.1:8080 +###< websocket config ### + +APP_DEBUG=1 diff --git a/standard-setup/conf/nginx.default.conf b/standard-setup/conf/nginx.default.conf new file mode 100644 index 0000000..cbb0d39 --- /dev/null +++ b/standard-setup/conf/nginx.default.conf @@ -0,0 +1,59 @@ +upstream fastcgi_backend { + server unix:/sock/docker.sock; +} + +server { + listen [::]:8000 ipv6only=on; + listen 8000; + + root /var/www/html/public; + + index index.php; + autoindex off; + charset off; + + fastcgi_buffer_size 64k; + fastcgi_buffers 8 128k; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass fastcgi_backend; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} + +server { + listen [::]:8443 ssl http2 ipv6only=on; + listen 8443 ssl http2; + + ssl_certificate /etc/nginx/certs/nginx.crt; + ssl_certificate_key /etc/nginx/certs/nginx.key; + + root /var/www/html/public; + + index index.php; + autoindex off; + charset off; + + fastcgi_buffer_size 64k; + fastcgi_buffers 8 128k; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass fastcgi_backend; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} + diff --git a/standard-setup/conf/supervisord.conf b/standard-setup/conf/supervisord.conf new file mode 100644 index 0000000..1cf440d --- /dev/null +++ b/standard-setup/conf/supervisord.conf @@ -0,0 +1,32 @@ +[unix_http_server] +file=/tmp/supervisor.sock + +[supervisord] +logfile=/var/log/supervisor/supervisord.log +loglevel=info +pidfile=/var/run/supervisor/supervisord.pid + +[supervisorctl] +serverurl=unix:///tmp/supervisor.sock + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[program:oro_web_socket] +command=/usr/local/bin/php /var/www/html/bin/console gos:websocket:server --env=prod +numprocs=1 +autostart=true +autorestart=true +directory=/var/www/html +user=app +redirect_stderr=true + +[program:oro_message_consumer] +command=/usr/local/bin/php /var/www/html/bin/console oro:message-queue:consume --env=prod +process_name=%(program_name)s_%(process_num)02d +numprocs=5 +autostart=true +autorestart=true +directory=/var/www/html +user=app +redirect_stderr=true diff --git a/standard-setup/docker-compose.yml b/standard-setup/docker-compose.yml new file mode 100644 index 0000000..864f24f --- /dev/null +++ b/standard-setup/docker-compose.yml @@ -0,0 +1,112 @@ +version: "3" + +services: + app: + image: adnnor/nginx:1.18 + ports: + - "80:8000" + - "443:8443" + volumes: &appvolumes + - ~/.composer:/var/www/.composer:cached + - ~/.ssh:/var/www/.ssh:cached + - ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached + - ./src:/var/www/html:cached + - ./conf/nginx.default.conf:/etc/nginx/conf.d/default.conf:cached + - ./conf/.env-app.local:/var/www/html/.env-app.local:cached + - sockdata:/sock + - ssldata:/etc/nginx/certs + + phpfpm: + image: adnnor/php:8.3-fpm + volumes: *appvolumes + networks: + - oro + env_file: env/phpfpm.env + + postgres: + image: postgres:latest + command: + - "--max_connections=200" + - "--shared_buffers=256MB" + ports: + - "5432:5432" + env_file: env/postgres.env + networks: + - oro + volumes: + - postgres-data:/var/lib/postgresql/data + + supervisor: + image: adnnor/supervisor + volumes: + - ./src:/var/www/html + - ./conf/supervisord.conf:/etc/supervisord.conf + depends_on: + - phpfpm + networks: + - oro + restart: always + command: /bin/sh -c "rm -f /tmp/supervisor.sock && supervisord -n" + + pgadmin: + image: dpage/pgadmin4 + depends_on: + - postgres + env_file: env/pgadmin.env + networks: + - oro + ports: + - "1435:80" + volumes: + - pgadmin-data:/var/lib/pgadmin + restart: always + + elasticsearch: + image: adnnor/elasticsearch:8.4 + ports: + - "9200:9200" + - "9300:9300" + env_file: env/elasticsearch.env + environment: + - "discovery.type=single-node" + ## Avoid test failures due to small disks + ## More info at https://github.com/markshust/docker-magento/issues/488 + - "cluster.routing.allocation.disk.threshold_enabled=false" + - "index.blocks.read_only_allow_delete" + ## Uncomment to set custom heap size to avoid memory errors + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + ## Uncomment to increase the virtual memory map count + - "max_map_count=262144" + + redis: + image: redis:6.0-alpine + container_name: redis + ports: + - "6379:6379" + + rabbitmq: + image: rabbitmq:3.11-management-alpine + ports: + - "15672:15672" + - "5672:5672" + volumes: + - rabbitmqdata:/var/lib/rabbitmq + env_file: env/rabbitmq.env + + mailcatcher: + image: sj26/mailcatcher + ports: + - "1080:1080" + +networks: + oro: + driver: bridge + +volumes: + appdata: + dbdata: + rabbitmqdata: + pgadmin-data: + sockdata: + ssldata: + postgres-data: diff --git a/standard-setup/env/elasticsearch.env b/standard-setup/env/elasticsearch.env new file mode 100644 index 0000000..5856225 --- /dev/null +++ b/standard-setup/env/elasticsearch.env @@ -0,0 +1,2 @@ +ES_HOST=elasticsearch +ES_PORT=9200 diff --git a/standard-setup/env/mailtrap.env b/standard-setup/env/mailtrap.env new file mode 100644 index 0000000..394b769 --- /dev/null +++ b/standard-setup/env/mailtrap.env @@ -0,0 +1,8 @@ +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=587 +MAIL_USERNAME=60b0889ecafe2b +MAIL_PASSWORD=83c42e3c27db2d +MAIL_ENCRYPTION=tls +MAIL_FROM_ADDRESS=adnnor@gmail.com +MAIL_FROM_NAME="Adnan Shahzad" diff --git a/standard-setup/env/pgadmin.env b/standard-setup/env/pgadmin.env new file mode 100644 index 0000000..4c29e58 --- /dev/null +++ b/standard-setup/env/pgadmin.env @@ -0,0 +1,2 @@ +PGADMIN_DEFAULT_EMAIL=root@adnanshahzad.me +PGADMIN_DEFAULT_PASSWORD=root diff --git a/standard-setup/env/phpfpm.env b/standard-setup/env/phpfpm.env new file mode 100644 index 0000000..20c33e4 --- /dev/null +++ b/standard-setup/env/phpfpm.env @@ -0,0 +1 @@ +COMPOSER_DISABLE_XDEBUG_WARN=1 diff --git a/standard-setup/env/postgres.env b/standard-setup/env/postgres.env new file mode 100644 index 0000000..32a6d67 --- /dev/null +++ b/standard-setup/env/postgres.env @@ -0,0 +1,3 @@ +POSTGRES_USER=root +POSTGRES_PASSWORD=root +POSTGRES_DB=dev diff --git a/standard-setup/env/rabbitmq.env b/standard-setup/env/rabbitmq.env new file mode 100644 index 0000000..c83768a --- /dev/null +++ b/standard-setup/env/rabbitmq.env @@ -0,0 +1,5 @@ +RABBITMQ_HOST=rabbitmq +RABBITMQ_PORT=5672 +RABBITMQ_DEFAULT_USER=rabbit +RABBITMQ_DEFAULT_PASS=rabbit +RABBITMQ_DEFAULT_VHOST=/ diff --git a/standard-setup/src/.gitkeep b/standard-setup/src/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/mood/.env b/test/mood/.env new file mode 100644 index 0000000..cbaf9d7 --- /dev/null +++ b/test/mood/.env @@ -0,0 +1 @@ +COMPOSE_PROJECT_NAME=mood diff --git a/test/mood/acme.json b/test/mood/acme.json new file mode 100644 index 0000000..e69de29 diff --git a/test/mood/conf/.env-app.local b/test/mood/conf/.env-app.local new file mode 100644 index 0000000..882c70c --- /dev/null +++ b/test/mood/conf/.env-app.local @@ -0,0 +1,20 @@ +ORO_DB_URL=postgres://root:root@postgres:5432/dev?sslmode=disable&charset=utf8&serverVersion=13.7 +ORO_DB_DSN=${ORO_DB_URL} + +MESSENGER_TRANSPORT_DSN=rabbitmq://rabbit:rabbit@rabbitmq:5672/%2f/messages + + +###> search engine config ### +ORO_SEARCH_URL=http://localhost:9200 +ORO_SEARCH_ENGINE_DSN=${ORO_SEARCH_URL}?prefix=oro_search +ORO_WEBSITE_SEARCH_ENGINE_DSN=${ORO_SEARCH_URL}?prefix=oro_website_search +###< search engine config ### + + +###> websocket config ### +ORO_WEBSOCKET_SERVER_DSN=//0.0.0.0:8080 +ORO_WEBSOCKET_FRONTEND_DSN=//*:8080/ws +ORO_WEBSOCKET_BACKEND_DSN=tcp://127.0.0.1:8080 +###< websocket config ### + +APP_DEBUG=1 diff --git a/test/mood/conf/nginx.default.conf b/test/mood/conf/nginx.default.conf new file mode 100644 index 0000000..cbb0d39 --- /dev/null +++ b/test/mood/conf/nginx.default.conf @@ -0,0 +1,59 @@ +upstream fastcgi_backend { + server unix:/sock/docker.sock; +} + +server { + listen [::]:8000 ipv6only=on; + listen 8000; + + root /var/www/html/public; + + index index.php; + autoindex off; + charset off; + + fastcgi_buffer_size 64k; + fastcgi_buffers 8 128k; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass fastcgi_backend; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} + +server { + listen [::]:8443 ssl http2 ipv6only=on; + listen 8443 ssl http2; + + ssl_certificate /etc/nginx/certs/nginx.crt; + ssl_certificate_key /etc/nginx/certs/nginx.key; + + root /var/www/html/public; + + index index.php; + autoindex off; + charset off; + + fastcgi_buffer_size 64k; + fastcgi_buffers 8 128k; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass fastcgi_backend; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} + diff --git a/test/mood/conf/supervisord.conf b/test/mood/conf/supervisord.conf new file mode 100644 index 0000000..1cf440d --- /dev/null +++ b/test/mood/conf/supervisord.conf @@ -0,0 +1,32 @@ +[unix_http_server] +file=/tmp/supervisor.sock + +[supervisord] +logfile=/var/log/supervisor/supervisord.log +loglevel=info +pidfile=/var/run/supervisor/supervisord.pid + +[supervisorctl] +serverurl=unix:///tmp/supervisor.sock + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[program:oro_web_socket] +command=/usr/local/bin/php /var/www/html/bin/console gos:websocket:server --env=prod +numprocs=1 +autostart=true +autorestart=true +directory=/var/www/html +user=app +redirect_stderr=true + +[program:oro_message_consumer] +command=/usr/local/bin/php /var/www/html/bin/console oro:message-queue:consume --env=prod +process_name=%(program_name)s_%(process_num)02d +numprocs=5 +autostart=true +autorestart=true +directory=/var/www/html +user=app +redirect_stderr=true diff --git a/test/mood/docker-compose.yml b/test/mood/docker-compose.yml new file mode 100644 index 0000000..ee8bda5 --- /dev/null +++ b/test/mood/docker-compose.yml @@ -0,0 +1,139 @@ +version: "3" + +services: + app: + image: adnnor/nginx:1.18 + volumes: &appvolumes + - ~/.composer:/var/www/.composer:cached + - ~/.ssh:/var/www/.ssh:cached + - ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached + - ./src:/var/www/html:cached + - ./conf/nginx.default.conf:/etc/nginx/conf.d/default.conf:cached + - ./conf/.env-app.local:/var/www/html/.env-app.local:cached + - sockdata:/sock + - ssldata:/etc/nginx/certs + networks: + - oro + labels: + - "traefik.enable=true" + - "traefik.http.routers.mood.rule=Host(`mood.local`)" + - "traefik.http.services.mood.loadbalancer.server.port=8000" + + phpfpm: + image: adnnor/php:8.3-fpm + volumes: *appvolumes + networks: + - oro + env_file: env/phpfpm.env + + traefik: + image: traefik:v2.5 + ports: + - "80:80" + - "443:443" + - "8080:8080" + - "8082:8082" + networks: + - oro + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - "./traefik.yml:/etc/traefik/traefik.yml" + - "./acme.json:/acme.json" + labels: + - "traefik.enable=true" + # Dashboard access + - "traefik.http.routers.traefik-dashboard-mood.rule=Host(`traefik.mood.local`)" + - "traefik.http.routers.traefik-dashboard-mood.service=api@internal" + #- "traefik.http.services.traefik-dashboard-mood.loadbalancer.server.port=8080" + +# supervisor: +# image: adnnor/supervisor +# volumes: +# - ./src:/var/www/html +# - ./conf/supervisord.conf:/etc/supervisord.conf +# depends_on: +# - phpfpm +# networks: +# - oro +# restart: always +# command: /bin/sh -c "rm -f /tmp/supervisor.sock && supervisord -n" + + postgres: + image: postgres:latest + command: + - "--max_connections=200" + - "--shared_buffers=256MB" + env_file: env/postgres.env + networks: + - oro + labels: + - "traefik.enable=true" + - "traefik.tcp.routers.postgres-mood.rule=HostSNI(`postgres.mood.local`)" + - "traefik.tcp.services.postgres-mood.loadbalancer.server.port=5432" + volumes: + - postgres-data:/var/lib/postgresql/data + + pgadmin: + image: dpage/pgadmin4 + depends_on: + - postgres + env_file: env/pgadmin.env + networks: + - oro + labels: + - "traefik.enable=true" + - "traefik.http.routers.pgadmin-mood.rule=Host(`pgadmin.mood.local`)" + - "traefik.http.services.pgadmin-mood.loadbalancer.server.port=80" + volumes: + - pgadmin-data:/var/lib/pgadmin + restart: always + + elasticsearch: + image: adnnor/elasticsearch:8.4 + labels: + - "traefik.enable=true" + - "traefik.http.routers.elasticsearch.rule=Host(`elasticsearch.mood.local`)" + - "traefik.http.services.elasticsearch.loadbalancer.server.port=9200" + env_file: env/elasticsearch.env + environment: + - "discovery.type=single-node" + ## Avoid test failures due to small disks + ## More info at https://github.com/markshust/docker-magento/issues/488 + - "cluster.routing.allocation.disk.threshold_enabled=false" + - "index.blocks.read_only_allow_delete" + ## Uncomment to set custom heap size to avoid memory errors + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + ## Uncomment to increase the virtual memory map count + - "max_map_count=262144" + +# redis: +# image: redis:6.0-alpine +# ports: +# - "6379:6379" + +# rabbitmq: +# image: rabbitmq:3.11-management-alpine +# ports: +# - "15672:15672" +# - "5672:5672" +# volumes: +# - rabbitmqdata:/var/lib/rabbitmq +# env_file: env/rabbitmq.env + +# mailcatcher: +# image: sj26/mailcatcher +# ports: +# - "1080:1080" + +networks: + oro: + driver: bridge + +volumes: + appdata: + dbdata: + rabbitmqdata: + pgadmin-data: + sockdata: + ssldata: + postgres-data: diff --git a/test/mood/env/elasticsearch.env b/test/mood/env/elasticsearch.env new file mode 100644 index 0000000..5856225 --- /dev/null +++ b/test/mood/env/elasticsearch.env @@ -0,0 +1,2 @@ +ES_HOST=elasticsearch +ES_PORT=9200 diff --git a/test/mood/env/mailtrap.env b/test/mood/env/mailtrap.env new file mode 100644 index 0000000..394b769 --- /dev/null +++ b/test/mood/env/mailtrap.env @@ -0,0 +1,8 @@ +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=587 +MAIL_USERNAME=60b0889ecafe2b +MAIL_PASSWORD=83c42e3c27db2d +MAIL_ENCRYPTION=tls +MAIL_FROM_ADDRESS=adnnor@gmail.com +MAIL_FROM_NAME="Adnan Shahzad" diff --git a/test/mood/env/pgadmin.env b/test/mood/env/pgadmin.env new file mode 100644 index 0000000..4c29e58 --- /dev/null +++ b/test/mood/env/pgadmin.env @@ -0,0 +1,2 @@ +PGADMIN_DEFAULT_EMAIL=root@adnanshahzad.me +PGADMIN_DEFAULT_PASSWORD=root diff --git a/test/mood/env/phpfpm.env b/test/mood/env/phpfpm.env new file mode 100644 index 0000000..20c33e4 --- /dev/null +++ b/test/mood/env/phpfpm.env @@ -0,0 +1 @@ +COMPOSER_DISABLE_XDEBUG_WARN=1 diff --git a/test/mood/env/postgres.env b/test/mood/env/postgres.env new file mode 100644 index 0000000..32a6d67 --- /dev/null +++ b/test/mood/env/postgres.env @@ -0,0 +1,3 @@ +POSTGRES_USER=root +POSTGRES_PASSWORD=root +POSTGRES_DB=dev diff --git a/test/mood/env/rabbitmq.env b/test/mood/env/rabbitmq.env new file mode 100644 index 0000000..c83768a --- /dev/null +++ b/test/mood/env/rabbitmq.env @@ -0,0 +1,5 @@ +RABBITMQ_HOST=rabbitmq +RABBITMQ_PORT=5672 +RABBITMQ_DEFAULT_USER=rabbit +RABBITMQ_DEFAULT_PASS=rabbit +RABBITMQ_DEFAULT_VHOST=/ diff --git a/test/mood/src/.env-app.local b/test/mood/src/.env-app.local new file mode 100644 index 0000000..e69de29 diff --git a/test/mood/src/public/index.php b/test/mood/src/public/index.php new file mode 100644 index 0000000..83f1549 --- /dev/null +++ b/test/mood/src/public/index.php @@ -0,0 +1,3 @@ + search engine config ### +ORO_SEARCH_URL=http://localhost:9200 +ORO_SEARCH_ENGINE_DSN=${ORO_SEARCH_URL}?prefix=oro_search +ORO_WEBSITE_SEARCH_ENGINE_DSN=${ORO_SEARCH_URL}?prefix=oro_website_search +###< search engine config ### + + +###> websocket config ### +ORO_WEBSOCKET_SERVER_DSN=//0.0.0.0:8080 +ORO_WEBSOCKET_FRONTEND_DSN=//*:8080/ws +ORO_WEBSOCKET_BACKEND_DSN=tcp://127.0.0.1:8080 +###< websocket config ### + +APP_DEBUG=1 diff --git a/test/vibe/conf/nginx.default.conf b/test/vibe/conf/nginx.default.conf new file mode 100644 index 0000000..cbb0d39 --- /dev/null +++ b/test/vibe/conf/nginx.default.conf @@ -0,0 +1,59 @@ +upstream fastcgi_backend { + server unix:/sock/docker.sock; +} + +server { + listen [::]:8000 ipv6only=on; + listen 8000; + + root /var/www/html/public; + + index index.php; + autoindex off; + charset off; + + fastcgi_buffer_size 64k; + fastcgi_buffers 8 128k; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass fastcgi_backend; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} + +server { + listen [::]:8443 ssl http2 ipv6only=on; + listen 8443 ssl http2; + + ssl_certificate /etc/nginx/certs/nginx.crt; + ssl_certificate_key /etc/nginx/certs/nginx.key; + + root /var/www/html/public; + + index index.php; + autoindex off; + charset off; + + fastcgi_buffer_size 64k; + fastcgi_buffers 8 128k; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass fastcgi_backend; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} + diff --git a/test/vibe/conf/supervisord.conf b/test/vibe/conf/supervisord.conf new file mode 100644 index 0000000..1cf440d --- /dev/null +++ b/test/vibe/conf/supervisord.conf @@ -0,0 +1,32 @@ +[unix_http_server] +file=/tmp/supervisor.sock + +[supervisord] +logfile=/var/log/supervisor/supervisord.log +loglevel=info +pidfile=/var/run/supervisor/supervisord.pid + +[supervisorctl] +serverurl=unix:///tmp/supervisor.sock + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[program:oro_web_socket] +command=/usr/local/bin/php /var/www/html/bin/console gos:websocket:server --env=prod +numprocs=1 +autostart=true +autorestart=true +directory=/var/www/html +user=app +redirect_stderr=true + +[program:oro_message_consumer] +command=/usr/local/bin/php /var/www/html/bin/console oro:message-queue:consume --env=prod +process_name=%(program_name)s_%(process_num)02d +numprocs=5 +autostart=true +autorestart=true +directory=/var/www/html +user=app +redirect_stderr=true diff --git a/test/vibe/docker-compose.yml b/test/vibe/docker-compose.yml new file mode 100644 index 0000000..2207167 --- /dev/null +++ b/test/vibe/docker-compose.yml @@ -0,0 +1,138 @@ +version: "3" + +services: + app: + image: adnnor/nginx:1.18 + volumes: &appvolumes + - ~/.composer:/var/www/.composer:cached + - ~/.ssh:/var/www/.ssh:cached + - ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached + - ./src:/var/www/html:cached + - ./conf/nginx.default.conf:/etc/nginx/conf.d/default.conf:cached + - ./conf/.env-app.local:/var/www/html/.env-app.local:cached + - sockdata:/sock + - ssldata:/etc/nginx/certs + networks: + - oro + labels: + - "traefik.enable=true" + - "traefik.http.routers.vibe.rule=Host(`vibe.local`)" + - "traefik.http.services.vibe.loadbalancer.server.port=8000" + + phpfpm: + image: adnnor/php:8.3-fpm + volumes: *appvolumes + networks: + - oro + env_file: env/phpfpm.env + + traefik: + image: traefik:v2.5 + ports: + - "8088:80" + - "8443:443" + - "8083:8080" + networks: + - oro + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - "./traefik.yml:/etc/traefik/traefik.yml" + - "./acme.json:/acme.json" + labels: + - "traefik.enable=true" + # Dashboard access + - "traefik.http.routers.traefik-dashboard-vibe.rule=Host(`traefik.vibe.local`)" + - "traefik.http.routers.traefik-dashboard-vibe.service=api@internal" + #- "traefik.http.services.traefik-dashboard-vibe.loadbalancer.server.port=8083" + +# supervisor: +# image: adnnor/supervisor +# volumes: +# - ./src:/var/www/html +# - ./conf/supervisoro2network.conf:/etc/supervisoro2network.conf +# depends_on: +# - phpfpm +# networks: +# - oro +# restart: always +# command: /bin/sh -c "rm -f /tmp/supervisor.sock && supervisoro2network -n" + + postgres: + image: postgres:latest + command: + - "--max_connections=200" + - "--shared_buffers=256MB" + env_file: env/postgres.env + networks: + - oro + labels: + - "traefik.enable=true" + - "traefik.tcp.routers.postgres-vibe.rule=HostSNI(`postgres.vibe.local`)" + - "traefik.tcp.services.postgres-vibe.loadbalancer.server.port=5432" + volumes: + - postgres-data:/var/lib/postgresql/data + + pgadmin: + image: dpage/pgadmin4 + depends_on: + - postgres + env_file: env/pgadmin.env + networks: + - oro + labels: + - "traefik.enable=true" + - "traefik.http.routers.pgadmin-vibe.rule=Host(`pgadmin.vibe.local`)" + - "traefik.http.services.pgadmin-vibe.loadbalancer.server.port=80" + volumes: + - pgadmin-data:/var/lib/pgadmin + restart: always + + elasticsearch: + image: adnnor/elasticsearch:8.4 + labels: + - "traefik.enable=true" + - "traefik.http.routers.elasticsearch-vibe.rule=Host(`elasticsearch.vibe.local`)" + - "traefik.http.services.elasticsearch-vibe.loadbalancer.server.port=9200" + env_file: env/elasticsearch.env + environment: + - "discovery.type=single-node" + ## Avoid test failures due to small disks + ## More info at https://github.com/markshust/docker-magento/issues/488 + - "cluster.routing.allocation.disk.threshold_enabled=false" + - "index.blocks.read_only_allow_delete" + ## Uncomment to set custom heap size to avoid memory errors + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + ## Uncomment to increase the virtual memory map count + - "max_map_count=262144" + +# redis: +# image: redis:6.0-alpine +# ports: +# - "6379:6379" + +# rabbitmq: +# image: rabbitmq:3.11-management-alpine +# ports: +# - "15672:15672" +# - "5672:5672" +# volumes: +# - rabbitmqdata:/var/lib/rabbitmq +# env_file: env/rabbitmq.env + +# mailcatcher: +# image: sj26/mailcatcher +# ports: +# - "1080:1080" + +networks: + oro: + driver: bridge + +volumes: + appdata: + dbdata: + rabbitmqdata: + pgadmin-data: + sockdata: + ssldata: + postgres-data: diff --git a/test/vibe/env/elasticsearch.env b/test/vibe/env/elasticsearch.env new file mode 100644 index 0000000..5856225 --- /dev/null +++ b/test/vibe/env/elasticsearch.env @@ -0,0 +1,2 @@ +ES_HOST=elasticsearch +ES_PORT=9200 diff --git a/test/vibe/env/mailtrap.env b/test/vibe/env/mailtrap.env new file mode 100644 index 0000000..394b769 --- /dev/null +++ b/test/vibe/env/mailtrap.env @@ -0,0 +1,8 @@ +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=587 +MAIL_USERNAME=60b0889ecafe2b +MAIL_PASSWORD=83c42e3c27db2d +MAIL_ENCRYPTION=tls +MAIL_FROM_ADDRESS=adnnor@gmail.com +MAIL_FROM_NAME="Adnan Shahzad" diff --git a/test/vibe/env/pgadmin.env b/test/vibe/env/pgadmin.env new file mode 100644 index 0000000..4c29e58 --- /dev/null +++ b/test/vibe/env/pgadmin.env @@ -0,0 +1,2 @@ +PGADMIN_DEFAULT_EMAIL=root@adnanshahzad.me +PGADMIN_DEFAULT_PASSWORD=root diff --git a/test/vibe/env/phpfpm.env b/test/vibe/env/phpfpm.env new file mode 100644 index 0000000..20c33e4 --- /dev/null +++ b/test/vibe/env/phpfpm.env @@ -0,0 +1 @@ +COMPOSER_DISABLE_XDEBUG_WARN=1 diff --git a/test/vibe/env/postgres.env b/test/vibe/env/postgres.env new file mode 100644 index 0000000..32a6d67 --- /dev/null +++ b/test/vibe/env/postgres.env @@ -0,0 +1,3 @@ +POSTGRES_USER=root +POSTGRES_PASSWORD=root +POSTGRES_DB=dev diff --git a/test/vibe/env/rabbitmq.env b/test/vibe/env/rabbitmq.env new file mode 100644 index 0000000..c83768a --- /dev/null +++ b/test/vibe/env/rabbitmq.env @@ -0,0 +1,5 @@ +RABBITMQ_HOST=rabbitmq +RABBITMQ_PORT=5672 +RABBITMQ_DEFAULT_USER=rabbit +RABBITMQ_DEFAULT_PASS=rabbit +RABBITMQ_DEFAULT_VHOST=/ diff --git a/test/vibe/src/.env-app.local b/test/vibe/src/.env-app.local new file mode 100644 index 0000000..e69de29 diff --git a/test/vibe/src/public/index.php b/test/vibe/src/public/index.php new file mode 100644 index 0000000..83f1549 --- /dev/null +++ b/test/vibe/src/public/index.php @@ -0,0 +1,3 @@ + labels` section, set the Traefik dashboard port to `8083` for accessibility: + +```yaml +labels: + - "traefik.http.services.traefik-dashboard-vibe.loadbalancer.server.port=8083" +``` + +If there are any issues accessing the dashboard, you can comment out this line to troubleshoot: + +```yaml + # - "traefik.http.services.traefik-dashboard-vibe.loadbalancer.server.port=8083" +``` + +Note that while `nginx.conf` supports secure URLs, SSL is not yet set up here. You can add an SSL certificate if possible; otherwise, SSL support will be added soon. + +Add the following URLs to your `/etc/hosts` file: + +- `vibe.local` +- `pgadmin.vibe.local` +- `traefik.vibe.local` + +After making these changes, start the project by running: + +```bash +docker-compose up -d +``` + +This will set up `vibe` as a separate project with the following URLs: + +- `vibe.local:8088` +- `pgadmin.vibe.local:8088` +- `traefik.vibe.local:8088` + diff --git a/traefik.yml b/traefik.yml index 3c9c037..b619aae 100644 --- a/traefik.yml +++ b/traefik.yml @@ -3,8 +3,6 @@ entryPoints: address: ":80" websecure: address: ":443" - metrics: - address: ":8082" providers: docker: @@ -15,14 +13,3 @@ api: dashboard: true accessLog: {} - -metrics: - prometheus: - entryPoint: metrics # Custom entry point for metrics - buckets: - - 0.1 - - 0.3 - - 1.2 - - 5.0 - addEntryPointsLabels: true - addServicesLabels: true