From 6f7094cc41ac7f097b689088fd65cd5a11c70fa3 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 3 Mar 2026 15:57:57 +0300 Subject: [PATCH] feat(livekit): add service --- .env | 25 +++ Makefile | 168 +++++++++++++++++ docker-compose.yml | 205 +++++++++++++++++++++ phpdocker/README.html | 208 ++++++++++++++++++++++ phpdocker/README.md | 144 +++++++++++++++ phpdocker/front-end/Dockerfile | 16 ++ phpdocker/front-end/laravel-worker.conf | 23 +++ phpdocker/front-end/php-ini-overrides.ini | 2 + phpdocker/nginx/nginx.conf | 83 +++++++++ phpdocker/php-fpm/Dockerfile | 21 +++ phpdocker/php-fpm/laravel-worker.conf | 23 +++ phpdocker/php-fpm/php-ini-overrides.ini | 2 + phpdocker/typesense/Dockerfile | 3 + phpdocker/worker/Dockerfile | 12 ++ phpdocker/worker/laravel-worker.conf | 55 ++++++ phpdocker/worker/php-ini-overrides.ini | 2 + 16 files changed, 992 insertions(+) create mode 100755 .env create mode 100755 Makefile create mode 100755 docker-compose.yml create mode 100755 phpdocker/README.html create mode 100755 phpdocker/README.md create mode 100755 phpdocker/front-end/Dockerfile create mode 100755 phpdocker/front-end/laravel-worker.conf create mode 100755 phpdocker/front-end/php-ini-overrides.ini create mode 100755 phpdocker/nginx/nginx.conf create mode 100755 phpdocker/php-fpm/Dockerfile create mode 100755 phpdocker/php-fpm/laravel-worker.conf create mode 100755 phpdocker/php-fpm/php-ini-overrides.ini create mode 100755 phpdocker/typesense/Dockerfile create mode 100755 phpdocker/worker/Dockerfile create mode 100755 phpdocker/worker/laravel-worker.conf create mode 100755 phpdocker/worker/php-ini-overrides.ini diff --git a/.env b/.env new file mode 100755 index 0000000..e4b6be2 --- /dev/null +++ b/.env @@ -0,0 +1,25 @@ +SOKETI_DEBUG=1 +SOKETI_METRICS_SERVER_PORT=9701 +SOKETI_DEFAULT_APP_ID="Avipaidaecachai6Thai" +SOKETI_DEFAULT_APP_KEY="EiquuV7uy3aiReith0te" +SOKETI_DEFAULT_APP_SECRET="veeyohHaef2ieShohj4j" +SOKETI_DEFAULT_APP_ENABLE_CLIENT_MESSAGES=true +SOKETI_DEFAULT_APP_USER_AUTHENTICATION=true +SOKETI_PORT=6201 +MYSQL_ROOT_PASSWORD="otheejoov3Oh" +MYSQL_DATABASE="eatviosandbox" +MYSQL_USER="eatvio_user" +MYSQL_PASSWORD="ohmaiHu4AhHa" +PROD_DB_USER=some_user +PROD_DB_PASS=taih4eeNg7Ka +PROD_DB_FILE="latest-prod-db.sql" +ASSETS_CLONE_TOKEN="acd1bda46abae3601ce43f292fa348d4afb9b66f" +MY_APP_GIT_URL="ssh://git@10.55.5.123:222/eatvio/eatvio.git" +LIVEKIT_URL="livekit.eatv.io" +LIVEKIT_WS_URL="livekit.eatv.io" +LIVEKIT_TURN_DOMAIN="turn.eatv.io" +LIVEKIT_API_KEY=APITRajpYFYdtk9 +LIVEKIT_API_SECRET=VKCfO954C3OU0IeeXxZ1fiUDx9ZmWtvNNp9fCHRfO2JH +LIVEKIT_PORT=7880 +LIVEKIT_RTC_TCP_PORT=7881 +LIVEKIT_TURN_UDP_PORT=3478 diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..99888f9 --- /dev/null +++ b/Makefile @@ -0,0 +1,168 @@ +include .env + +clone: + git clone ${MY_APP_GIT_URL} app + +start: + docker compose up -d + +stop: + docker compose down --remove-orphans -v + +restart: stop start + +status: + docker compose ps + +bash: + docker compose exec php-fpm bash + +worker-restart: + docker compose exec worker supervisorctl restart laravel-worker:* + +clear-images: + docker compose exec php-fpm ./artisan clear:orphaned-images + +links-images: + jdupes -r -1 -l app/storage/app + +tinker: + docker compose exec php-fpm ./artisan tinker + +reseed-db: + docker compose exec php-fpm bash -c "./artisan migrate:refresh; ./artisan db:seed" + +setup-laravel-key: + docker compose exec php-fpm php /application/artisan key:generate + +setup-laravel-packages: + docker compose exec php-fpm composer install + +copy-laravel-env: + docker compose exec php-fpm cp /application/.env.example /application/.env + +copy-infra-env: + cp .env.infra-example .env + +run-migrations: + docker compose exec php-fpm ./artisan migrate + +run-plan-seed: + docker compose exec php-fpm ./artisan db:seed --class=PlanSeeder + +run-user-seed: + docker compose exec php-fpm ./artisan db:seed --class=UserSeeder + +seed-db: + docker compose exec php-fpm ./artisan db:seed + +fix-permissions: + docker compose exec php-fpm chown -R www-data:www-data storage + +fix-code-style: + docker compose exec -T php-fpm vendor/bin/pint + +fix-blade-formatting: + docker compose exec -T php-fpm ./node_modules/.bin/prettier --write resources/**/**/**/**/*.blade.php + +artisan: + docker compose exec php-fpm ./artisan $(ARGS) + +mysql-console: + docker compose exec mysql mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE} + +mysql-restore: + docker compose exec mysql mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE} \< /application/eatvio-11-03-2025.sql + +mysql-save-prod-db: + mysqldump --single-transaction -u${PROD_DB_USER} -p${PROD_DB_PASS} -h10.55.5.7 -P1094 eatvio > ${PROD_DB_FILE} + +mysql-restore-saved-from-prod-db: + docker compose exec mysql bash -c "cat ./${PROD_DB_FILE} | mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE}" + +mysql-remove-latest-prod-db: + rm -f ${PROD_DB_FILE} + +mysql-import-db-from-prod: mysql-save-prod-db mysql-restore-saved-from-prod-db mysql-remove-latest-prod-db + +start-frontend: + docker compose exec php-fpm npm run watch + +build-frontend-prod: + docker compose exec php-fpm npm run production + +make-storage-link: + docker compose exec php-fpm ./artisan storage:link + +node-frontend-deps: + docker compose exec php-fpm npm i --legacy-peer-deps + +paratest-bin: + docker compose exec -u www-data php-fpm vendor/bin/paratest + +paratest-artisan: + docker compose exec -u www-data -T php-fpm ./artisan test --parallel --stop-on-failure --env=testing + +fix-insights: + docker compose exec php-fpm vendor/bin/phpinsights --fix --config-path=./config/insights.php --no-interaction --min-quality=80 --min-complexity=90 --min-architecture=75 --min-style=95 + +insights: + docker compose exec -T php-fpm vendor/bin/phpinsights --config-path=./config/insights.php --no-interaction --min-quality=80 --min-complexity=90 --min-architecture=75 --min-style=95 --flush-cache + +rector: + docker compose exec -T php-fpm vendor/bin/rector process --dry-run + +static-analysis: + docker compose exec -T php-fpm composer static-analysis + +detect-magic-numbers: + docker compose exec -u www-data -T php-fpm vendor/bin/phpmnd app/ tests/ + +fix-web-permissions: + docker compose exec -T php-fpm chown -R www-data:www-data bootstrap/cache storage + +clear-app-cache: + docker compose exec php-fpm ./artisan optimize:clear + +build-front: + docker compose exec php-fpm npm run production + +composer-do: + docker compose exec php-fpm composer dump-auto + +reload-wokers: + docker compose exec worker ./artisan queue:restart + +run-once-oprations: + docker compose exec php-fpm bash -c "./artisan operations:process" + +reset-sandbox: + docker compose exec php-fpm bash -c "rm -rf database/assets; git clone http://git:${ASSETS_CLONE_TOKEN}@10.55.5.123:3000/eatvio/fixtures_and_assets.git database/assets; ./artisan sandbox:reset --force" + +after-deploy-light: composer-do run-migrations run-once-oprations reset-sandbox clear-app-cache build-front fix-permissions reload-wokers + +after-deploy: composer-do clear-app-cache run-migrations run-once-oprations build-front fix-permissions reload-wokers reindex-search + +# ci: fix-web-permissions fix-code-style detect-magic-numbers test rector insights static-analysis fix-web-permissions +ci: fix-web-permissions detect-magic-numbers test rector insights static-analysis fix-web-permissions + +local-composer-ci: + docker compose exec php-fpm composer ci + +test: fix-web-permissions paratest-artisan + +test-file-by-path: + docker compose exec php-fpm ./artisan test --env=testing $(ARGS) + +local-ci: fix-web-permissions local-composer-ci fix-web-permissions + +init: clone copy-infra-env restart setup-laravel-packages copy-laravel-env setup-laravel-key run-migrations node-frontend-deps build-frontend-prod fix-permissions make-storage-link + +rebuild-services: + docker compose build --no-cache + +pull-services: + docker compose pull + +force-rebuild-services: stop rebuild-services pull-services start + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..6b8c0eb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,205 @@ +services: + soketi: + image: "quay.io/soketi/soketi:latest-16-alpine" + environment: + SOKETI_DEBUG: ${SOKETI_DEBUG} + SOKETI_METRICS_SERVER_PORT: ${SOKETI_METRICS_SERVER_PORT} + SOKETI_DEFAULT_APP_ID: ${SOKETI_DEFAULT_APP_ID} + SOKETI_DEFAULT_APP_KEY: ${SOKETI_DEFAULT_APP_KEY} + SOKETI_DEFAULT_APP_SECRET: ${SOKETI_DEFAULT_APP_SECRET} + SOKETI_DEFAULT_APP_ENABLE_CLIENT_MESSAGES: ${SOKETI_DEFAULT_APP_ENABLE_CLIENT_MESSAGES} + SOKETI_DEFAULT_APP_USER_AUTHENTICATION: ${SOKETI_DEFAULT_APP_USER_AUTHENTICATION} + ports: + - "${SOKETI_PORT:-6001}:6001" + - "${SOKETI_METRICS_SERVER_PORT:-9601}:9601" + networks: + - ns-eatvio + labels: + - "traefik.enable=false" + restart: always + + memcached: + image: "memcached:alpine" + networks: + - ns-eatvio + restart: always + labels: + - "traefik.enable=false" + + mysql: + image: "mysql:8.0" + working_dir: /application + networks: + - ns-eatvio + volumes: + - ".:/application" + - "./mysql_data:/var/lib/mysql" + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DATABASE} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + TZ: "Evrope/Moscow" + ports: + - "1394:3306" + labels: + - "traefik.enable=false" + restart: always + + php-fpm: + build: phpdocker/php-fpm + working_dir: /application + environment: + - TZ=Europe/Moscow + depends_on: + - mysql + - worker + # - frontend + - memcached + #- typesense + networks: + - ns-eatvio + volumes: + - "./app:/application" + - "./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/8.4/fpm/conf.d/99-overrides.ini" + - "./tbank_certs:/tbank_certs" + # - "./eatvio-3467b-firebase-adminsdk-fbsvc-6e149b2a5a.json:/eatvio-3467b-firebase-adminsdk-fbsvc-6e149b2a5a.json" + labels: + - "traefik.enable=false" + restart: always + +# frontend: +# build: phpdocker/front-end +# command: "npm run dev" +# working_dir: /application +# environment: +# - TZ=Europe/Moscow +# #- CHOKIDAR_USEPOLLING=true +# networks: +# - ns-eatvio +# volumes: +# - "./app:/application" +# labels: +# - "traefik.enable=false" +# restart: unless-stopped +# + worker: + build: phpdocker/worker + working_dir: /application + environment: + - TZ=Europe/Moscow + command: "service supervisor start" + depends_on: + - mysql + networks: + - ns-eatvio + volumes: + - "./app:/application" + - "./phpdocker/worker/php-ini-overrides.ini:/etc/php/8.4/fpm/conf.d/99-overrides.ini" + - "./phpdocker/worker/laravel-worker.conf:/etc/supervisor/conf.d/laravel-worker.conf" + - "./tbank_certs:/tbank_certs" + # - "./eatvio-3467b-firebase-adminsdk-fbsvc-6e149b2a5a.json:/eatvio-3467b-firebase-adminsdk-fbsvc-6e149b2a5a.json" + labels: + - "traefik.enable=false" + restart: always + + webserver: + image: "nginx:alpine" + working_dir: /application + restart: always + depends_on: + - php-fpm + - soketi + volumes: + - "./app:/application" + - "./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf" + #- "./phpdocker/nginx/hasan.eatvio.local+4.pem:/etc/nginx/hasan.eatvio.local+4.pem" + #- "./phpdocker/nginx/hasan.eatvio.local+4-key.pem:/etc/nginx/hasan.eatvio.local+4-key.pem" + ports: + - "12443:5000" + - "1392:80" + networks: + - web + - ns-eatvio + labels: + - "traefik.docker.network=web" + - "traefik.enable=true" + - "traefik.frontend.rule=Host:wstesting.eatv.io,testing.eatv.io" + - "traefik.port=80" + - "traefik.protocol=http" + + #mailhog: + #image: "mailhog/mailhog" + #ports: + #- "8082:8025" + #networks: + #- ns-eatvio + + typesense: + build: ./phpdocker/typesense + restart: always + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8108/health"] + networks: + - ns-eatvio + volumes: + - ./typesense-data:/data + command: "--data-dir /data --api-key=typesense --enable-cors" + + livekit-redis: + image: redis:7-alpine + command: ["redis-server", "--appendonly", "no", "--maxmemory", "500mb", "--maxmemory-policy", "allkeys-lru"] + networks: + - ns-eatvio + volumes: + - livekit_redis_data:/data + restart: always + labels: + - "traefik.enable=false" + + livekit: + image: livekit/livekit-server:latest + depends_on: + - livekit-redis + networks: + - ns-eatvio + - web + ports: + - "${LIVEKIT_PORT:-7880}:7880" + - "${LIVEKIT_RTC_TCP_PORT:-7881}:7881" + - "50000-50100:50000-50100/udp" + - "${LIVEKIT_TURN_UDP_PORT:-3478}:3478/udp" + environment: + LIVEKIT_CONFIG: | + port: 7880 + log_level: info + rtc: + tcp_port: 7881 + port_range_start: 50000 + port_range_end: 50100 + use_external_ip: true + redis: + address: livekit-redis:6379 + keys: + ${LIVEKIT_API_KEY}: ${LIVEKIT_API_SECRET} + turn: + enabled: true + domain: ${LIVEKIT_TURN_DOMAIN} + udp_port: 3478 + # tls_port: 5349 + restart: always + labels: + - "traefik.docker.network=web" + - "traefik.enable=true" + - "traefik.frontend.rule=Host:turn.eatv.io,livekit.eatv.io" + - "traefik.port=${LIVEKIT_PORT:-7880}" + - "traefik.protocol=http" + +networks: + web: + external: true + ns-eatvio: + external: false + +volumes: + livekit_redis_data: diff --git a/phpdocker/README.html b/phpdocker/README.html new file mode 100755 index 0000000..e5ec0b8 --- /dev/null +++ b/phpdocker/README.html @@ -0,0 +1,208 @@ + + + PHPDocker.io Readme + + + + + + +
+
+
+

PHPDocker.io generated environment

+ +

Add to your project

+ +

Simply, unzip the file into your project, this will create docker-compose.yml on the root of your project and a folder +named phpdocker containing nginx and php-fpm config for it.

+ +

Ensure the webserver config on phpdocker/nginx/nginx.conf is correct for your project. PHPDocker.io will have +customised this file according to the front controller location relative to the docker-compose file you chose on the +generator (by default public/index.php).

+ +

Note: you may place the files elsewhere in your project. Make sure you modify the locations for the php-fpm dockerfile, +the php.ini overrides and nginx config on docker-compose.yml if you do so.

+ +

How to run

+ +

Dependencies:

+ + + +

Once you're done, simply cd to your project and run docker-compose up -d. This will initialise and start all the +containers, then leave them running in the background.

+ +

Services exposed outside your environment

+ +

You can access your application via localhost. Mailhog and nginx both respond to any hostname, in case you want to +add your own hostname on your /etc/hosts

+ + + + + + + + + + + + + + + + + + +
ServiceAddress outside containers
Webserverlocalhost:1092
MySQLhost: localhost; port: 1094
+ +

Hosts within your environment

+ +

You'll need to configure your application to use any services you enabled:

+ + + + + + + + + + + + + + + + + + + + + +
ServiceHostnamePort number
php-fpmphp-fpm9000
MySQLmysql3306 (default)
+ +

Docker compose cheatsheet

+ +

Note: you need to cd first to where your docker-compose.yml file lives.

+ +
    +
  • Start containers in the background: docker-compose up -d
  • +
  • Start containers on the foreground: docker-compose up. You will see a stream of logs for every container running. +ctrl+c stops containers.
  • +
  • Stop containers: docker-compose stop
  • +
  • Kill containers: docker-compose kill
  • +
  • View container logs: docker-compose logs for all containers or docker-compose logs SERVICE_NAME for the logs of +all containers in SERVICE_NAME.
  • +
  • Execute command inside of container: docker-compose exec SERVICE_NAME COMMAND where COMMAND is whatever you want +to run. Examples: + +
      +
    • Shell into the PHP container, docker-compose exec php-fpm bash
    • +
    • Run symfony console, docker-compose exec php-fpm bin/console
    • +
    • Open a mysql shell, docker-compose exec mysql mysql -uroot -pCHOSEN_ROOT_PASSWORD
    • +
  • +
+ +

Application file permissions

+ +

As in all server environments, your application needs the correct file permissions to work properly. You can change the +files throughout the container, so you won't care if the user exists or has the same ID on your host.

+ +

docker-compose exec php-fpm chown -R www-data:www-data /application/public

+ +

Recommendations

+ +

It's hard to avoid file permission issues when fiddling about with containers due to the fact that, from your OS point +of view, any files created within the container are owned by the process that runs the docker engine (this is usually +root). Different OS will also have different problems, for instance you can run stuff in containers +using docker exec -it -u $(id -u):$(id -g) CONTAINER_NAME COMMAND to force your current user ID into the process, but +this will only work if your host OS is Linux, not mac. Follow a couple of simple rules and save yourself a world of +hurt.

+ +
    +
  • Run composer outside of the php container, as doing so would install all your dependencies owned by root within your +vendor folder.
  • +
  • Run commands (ie Symfony's console, or Laravel's artisan) straight inside of your container. You can easily open a +shell as described above and do your thing from there.
  • +
+ +

Simple basic Xdebug configuration with integration to PHPStorm

+ +

Xdebug 2

+ +

To configure Xdebug 2 you need add these lines in php-fpm/php-ini-overrides.ini:

+ +

For linux:

+ +
xdebug.remote_enable = 1
+xdebug.remote_connect_back = 1
+xdebug.remote_autostart = 1
+
+ +

For macOS and Windows:

+ +
xdebug.remote_enable = 1
+xdebug.remote_host = host.docker.internal
+xdebug.remote_autostart = 1
+
+ +

Xdebug 3

+ +

To configure Xdebug 3 you need add these lines in php-fpm/php-ini-overrides.ini:

+ +

For linux:

+ +
xdebug.mode = debug
+xdebug.remote_connect_back = true
+xdebug.start_with_request = yes
+
+ +

For macOS and Windows:

+ +
xdebug.mode = debug
+xdebug.remote_host = host.docker.internal
+xdebug.start_with_request = yes
+
+ +

Add the section “environment” to the php-fpm service in docker-compose.yml:

+ +
environment:
+  PHP_IDE_CONFIG: "serverName=Docker"
+
+ +

Create a server configuration in PHPStorm:

+ +
    +
  • In PHPStorm open Preferences | Languages & Frameworks | PHP | Servers
  • +
  • Add new server
  • +
  • The “Name” field should be the same as the parameter “serverName” value in “environment” in docker-compose.yml (i.e. * +Docker* in the example above)
  • +
  • A value of the "port" field should be the same as first port(before a colon) in "webserver" service in +docker-compose.yml
  • +
  • Select "Use path mappings" and set mappings between a path to your project on a host system and the Docker container.
  • +
  • Finally, add “Xdebug helper” extension in your browser, set breakpoints and start debugging
  • +
+
+
+
+ + + + diff --git a/phpdocker/README.md b/phpdocker/README.md new file mode 100755 index 0000000..3452aaa --- /dev/null +++ b/phpdocker/README.md @@ -0,0 +1,144 @@ +PHPDocker.io generated environment +================================== + +# Add to your project # + +Simply, unzip the file into your project, this will create `docker-compose.yml` on the root of your project and a folder +named `phpdocker` containing nginx and php-fpm config for it. + +Ensure the webserver config on `phpdocker/nginx/nginx.conf` is correct for your project. PHPDocker.io will have +customised this file according to the front controller location relative to the docker-compose file you chose on the +generator (by default `public/index.php`). + +Note: you may place the files elsewhere in your project. Make sure you modify the locations for the php-fpm dockerfile, +the php.ini overrides and nginx config on `docker-compose.yml` if you do so. + +# How to run # + +Dependencies: + +* docker. See [https://docs.docker.com/engine/installation](https://docs.docker.com/engine/installation) +* docker-compose. See [docs.docker.com/compose/install](https://docs.docker.com/compose/install/) + +Once you're done, simply `cd` to your project and run `docker-compose up -d`. This will initialise and start all the +containers, then leave them running in the background. + +## Services exposed outside your environment ## + +You can access your application via **`localhost`**. Mailhog and nginx both respond to any hostname, in case you want to +add your own hostname on your `/etc/hosts` + +Service|Address outside containers +-------|-------------------------- +Webserver|[localhost:1092](http://localhost:1092) +MySQL|**host:** `localhost`; **port:** `1094` + +## Hosts within your environment ## + +You'll need to configure your application to use any services you enabled: + +Service|Hostname|Port number +------|---------|----------- +php-fpm|php-fpm|9000 +MySQL|mysql|3306 (default) + +# Docker compose cheatsheet # + +**Note:** you need to cd first to where your docker-compose.yml file lives. + +* Start containers in the background: `docker-compose up -d` +* Start containers on the foreground: `docker-compose up`. You will see a stream of logs for every container running. + ctrl+c stops containers. +* Stop containers: `docker-compose stop` +* Kill containers: `docker-compose kill` +* View container logs: `docker-compose logs` for all containers or `docker-compose logs SERVICE_NAME` for the logs of + all containers in `SERVICE_NAME`. +* Execute command inside of container: `docker-compose exec SERVICE_NAME COMMAND` where `COMMAND` is whatever you want + to run. Examples: + * Shell into the PHP container, `docker-compose exec php-fpm bash` + * Run symfony console, `docker-compose exec php-fpm bin/console` + * Open a mysql shell, `docker-compose exec mysql mysql -uroot -pCHOSEN_ROOT_PASSWORD` + +# Application file permissions # + +As in all server environments, your application needs the correct file permissions to work properly. You can change the +files throughout the container, so you won't care if the user exists or has the same ID on your host. + +`docker-compose exec php-fpm chown -R www-data:www-data /application/public` + +# Recommendations # + +It's hard to avoid file permission issues when fiddling about with containers due to the fact that, from your OS point +of view, any files created within the container are owned by the process that runs the docker engine (this is usually +root). Different OS will also have different problems, for instance you can run stuff in containers +using `docker exec -it -u $(id -u):$(id -g) CONTAINER_NAME COMMAND` to force your current user ID into the process, but +this will only work if your host OS is Linux, not mac. Follow a couple of simple rules and save yourself a world of +hurt. + +* Run composer outside of the php container, as doing so would install all your dependencies owned by `root` within your + vendor folder. +* Run commands (ie Symfony's console, or Laravel's artisan) straight inside of your container. You can easily open a + shell as described above and do your thing from there. + +# Simple basic Xdebug configuration with integration to PHPStorm + +## Xdebug 2 + +To configure **Xdebug 2** you need add these lines in php-fpm/php-ini-overrides.ini: + +### For linux: + +``` +xdebug.remote_enable = 1 +xdebug.remote_connect_back = 1 +xdebug.remote_autostart = 1 +``` + +### For macOS and Windows: + +``` +xdebug.remote_enable = 1 +xdebug.remote_host = host.docker.internal +xdebug.remote_autostart = 1 +``` + +## Xdebug 3 + +To configure **Xdebug 3** you need add these lines in php-fpm/php-ini-overrides.ini: + +### For linux: + +``` +xdebug.mode = debug +xdebug.remote_connect_back = true +xdebug.start_with_request = yes +``` + +### For macOS and Windows: + +``` +xdebug.mode = debug +xdebug.remote_host = host.docker.internal +xdebug.start_with_request = yes +``` + +## Add the section “environment” to the php-fpm service in docker-compose.yml: + +``` +environment: + PHP_IDE_CONFIG: "serverName=Docker" +``` + +### Create a server configuration in PHPStorm: + +* In PHPStorm open Preferences | Languages & Frameworks | PHP | Servers +* Add new server +* The “Name” field should be the same as the parameter “serverName” value in “environment” in docker-compose.yml (i.e. * + Docker* in the example above) +* A value of the "port" field should be the same as first port(before a colon) in "webserver" service in + docker-compose.yml +* Select "Use path mappings" and set mappings between a path to your project on a host system and the Docker container. +* Finally, add “Xdebug helper” extension in your browser, set breakpoints and start debugging + + + diff --git a/phpdocker/front-end/Dockerfile b/phpdocker/front-end/Dockerfile new file mode 100755 index 0000000..9d0ea28 --- /dev/null +++ b/phpdocker/front-end/Dockerfile @@ -0,0 +1,16 @@ +FROM phpdockerio/php:8.4-fpm +WORKDIR "/application" + +RUN curl -sL https://deb.nodesource.com/setup_24.x | bash - +RUN apt-get update && \ + apt-get -y --no-install-recommends install \ + git \ + php8.4-gd \ + php8.4-mysql \ + php8.4-sqlite3 \ + php8.4-pgsql \ + nodejs && npm install -g npm@latest \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +ENV PATH=node_modules/.bin:$PATH diff --git a/phpdocker/front-end/laravel-worker.conf b/phpdocker/front-end/laravel-worker.conf new file mode 100755 index 0000000..3826cdc --- /dev/null +++ b/phpdocker/front-end/laravel-worker.conf @@ -0,0 +1,23 @@ +[supervisord] +nodaemon=true + +[program:laravel-worker] +process_name=%(program_name)s_%(process_num)02d +command=php /application/artisan queue:work --sleep=3 --tries=3 --max-time=3600 +autostart=true +autorestart=true +stopasgroup=true +killasgroup=true +user=www-data +numprocs=2 +redirect_stderr=true +stdout_logfile=/application/storage/logs/worker.log +stopwaitsecs=3600 + +[program:php-fpm] +command=php-fpm8.2 -F +process_name=%(program_name)s_%(process_num)02d +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stdderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/phpdocker/front-end/php-ini-overrides.ini b/phpdocker/front-end/php-ini-overrides.ini new file mode 100755 index 0000000..850ae11 --- /dev/null +++ b/phpdocker/front-end/php-ini-overrides.ini @@ -0,0 +1,2 @@ +upload_max_filesize = 100M +post_max_size = 108M diff --git a/phpdocker/nginx/nginx.conf b/phpdocker/nginx/nginx.conf new file mode 100755 index 0000000..c82d76a --- /dev/null +++ b/phpdocker/nginx/nginx.conf @@ -0,0 +1,83 @@ +upstream phpupstream { + server php-fpm:9000 fail_timeout=5s max_fails=5; +} + +resolver 127.0.0.11 ipv6=off; + +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +# 1. Основной сайт (Laravel) - делаем его default_server +server { + listen 80 default_server; # Добавили default_server + server_name testing.eatv.io; + + client_max_body_size 108M; + rewrite_log on; + + access_log /dev/stdout; + error_log /dev/stdout info; + + root /application/public; + index index.php; + + # # Vite HMR + # location /_vite { + # proxy_pass http://frontend:5173; + # 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-Real-IP $remote_addr; + # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # proxy_set_header X-Forwarded-Proto $scheme; + # proxy_connect_timeout 7d; + # proxy_send_timeout 7d; + # proxy_read_timeout 7d; + # } + # + # location /build { + # try_files $uri $uri/ =404; + # expires 1y; + # add_header Cache-Control "public, immutable"; + # } + + location / { + try_files $uri /index.php$is_args$args; + } + + location ~ \.php$ { + fastcgi_pass phpupstream; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log"; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + include fastcgi_params; + } +} + +# 2. Soketi - меняем server_name на тот, что в traefik labels (wstesting.eatv.io) +server { + listen 80; + server_name wstesting.eatv.io; # ВАЖНО: Используем поддомен для сокетов + + location / { + proxy_pass http://soketi:6001; + proxy_read_timeout 60; + proxy_connect_timeout 60; + proxy_redirect off; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } + + error_log /dev/stdout info; + access_log /dev/stdout; +} + diff --git a/phpdocker/php-fpm/Dockerfile b/phpdocker/php-fpm/Dockerfile new file mode 100755 index 0000000..8ac338a --- /dev/null +++ b/phpdocker/php-fpm/Dockerfile @@ -0,0 +1,21 @@ +FROM phpdockerio/php:8.4-fpm +WORKDIR "/application" + +RUN curl -sL https://deb.nodesource.com/setup_24.x | bash - +RUN apt-get update && \ + apt-get -y --no-install-recommends install \ + git \ + imagemagick php8.4-imagick \ + php8.4-gd \ + php8.4-mysql \ + php8.4-sqlite3 \ + php8.4-intl \ + php8.4-memcached \ + php8.4-pgsql \ + php8.4-xdebug \ + python3-pkg-resources supervisor ffmpeg jpegoptim \ + nodejs && npm install -g npm@latest \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* + +ENV PATH=node_modules/.bin:$PATH diff --git a/phpdocker/php-fpm/laravel-worker.conf b/phpdocker/php-fpm/laravel-worker.conf new file mode 100755 index 0000000..3826cdc --- /dev/null +++ b/phpdocker/php-fpm/laravel-worker.conf @@ -0,0 +1,23 @@ +[supervisord] +nodaemon=true + +[program:laravel-worker] +process_name=%(program_name)s_%(process_num)02d +command=php /application/artisan queue:work --sleep=3 --tries=3 --max-time=3600 +autostart=true +autorestart=true +stopasgroup=true +killasgroup=true +user=www-data +numprocs=2 +redirect_stderr=true +stdout_logfile=/application/storage/logs/worker.log +stopwaitsecs=3600 + +[program:php-fpm] +command=php-fpm8.2 -F +process_name=%(program_name)s_%(process_num)02d +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stdderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/phpdocker/php-fpm/php-ini-overrides.ini b/phpdocker/php-fpm/php-ini-overrides.ini new file mode 100755 index 0000000..850ae11 --- /dev/null +++ b/phpdocker/php-fpm/php-ini-overrides.ini @@ -0,0 +1,2 @@ +upload_max_filesize = 100M +post_max_size = 108M diff --git a/phpdocker/typesense/Dockerfile b/phpdocker/typesense/Dockerfile new file mode 100755 index 0000000..030c9ad --- /dev/null +++ b/phpdocker/typesense/Dockerfile @@ -0,0 +1,3 @@ +FROM typesense/typesense:29.0 +USER root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* diff --git a/phpdocker/worker/Dockerfile b/phpdocker/worker/Dockerfile new file mode 100755 index 0000000..6a57d1e --- /dev/null +++ b/phpdocker/worker/Dockerfile @@ -0,0 +1,12 @@ +FROM phpdockerio/php:8.4-fpm +WORKDIR "/application" + +RUN apt-get update && \ + apt-get -y --no-install-recommends install git \ + php8.4-gd php8.4-mysql php8.4-sqlite3 php8.4-pgsql ffmpeg jpegoptim \ + php8.4-intl \ + php8.4-memcached \ + imagemagick php8.4-imagick \ + python3-pkg-resources supervisor && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* diff --git a/phpdocker/worker/laravel-worker.conf b/phpdocker/worker/laravel-worker.conf new file mode 100755 index 0000000..8cc5818 --- /dev/null +++ b/phpdocker/worker/laravel-worker.conf @@ -0,0 +1,55 @@ +[supervisord] +nodaemon=true + +[program:laravel-worker] +process_name=%(program_name)s_%(process_num)02d +command=php /application/artisan queue:work --sleep=3 --tries=3 --max-time=3600 +autostart=true +autorestart=true +stopasgroup=true +killasgroup=true +user=www-data +numprocs=2 +redirect_stderr=true +stdout_logfile=/application/storage/logs/worker.log +stopwaitsecs=3600 + +[program:laravel-schedule] +process_name=%(program_name)s_%(process_num)02d +command=php /application/artisan schedule:work +directory=/application +autostart=true +autorestart=true +stopasgroup=true +killasgroup=true +user=www-data +numprocs=1 +redirect_stderr=true +stdout_logfile=/application/storage/logs/schedule.log +stopwaitsecs=3600 + +[program:laravel-feed-generation-worker] +process_name=%(program_name)s_%(process_num)02d +command=php /application/artisan queue:work --queue=feed-generation --sleep=1 --tries=3 --timeout=1800 --max-time=3600 +autostart=true +autorestart=true +stopasgroup=true +killasgroup=true +user=www-data +numprocs=8 +redirect_stderr=true +stdout_logfile=/application/storage/logs/feed-generation-worker.log +stopwaitsecs=3600 + +[program:laravel-scout-worker] +process_name=%(program_name)s_%(process_num)02d +command=php /application/artisan queue:work --queue=scout --sleep=1 --tries=3 --timeout=300 --max-time=3600 +autostart=true +autorestart=true +stopasgroup=true +killasgroup=true +user=www-data +numprocs=8 +redirect_stderr=true +stdout_logfile=/application/storage/logs/scout-worker.log +stopwaitsecs=3600 diff --git a/phpdocker/worker/php-ini-overrides.ini b/phpdocker/worker/php-ini-overrides.ini new file mode 100755 index 0000000..850ae11 --- /dev/null +++ b/phpdocker/worker/php-ini-overrides.ini @@ -0,0 +1,2 @@ +upload_max_filesize = 100M +post_max_size = 108M