diff --git a/.env.infra-example b/.env.infra-example index bc641a7..85db77a 100644 --- a/.env.infra-example +++ b/.env.infra-example @@ -17,3 +17,11 @@ PROD_DB_FILE="latest-prod-db.sql" PROD_DB_HOST="10.nn.n.n" PROD_DB_PORT="10nn" 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 index 5d97d44..81c8ef8 100644 --- a/Makefile +++ b/Makefile @@ -184,4 +184,3 @@ pull-services: docker compose pull force-rebuild-services: stop rebuild-services pull-services start - diff --git a/docker-compose.yml b/docker-compose.yml index 4fedb08..5ed9410 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,8 @@ services: networks: - ns-eatvio restart: always + labels: + - "traefik.enable=false" mysql: image: "mysql:8.0" @@ -37,6 +39,7 @@ services: MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} + TZ: "Evrope/Moscow" ports: - "1094:3306" labels: @@ -119,7 +122,7 @@ services: labels: - "traefik.docker.network=web" - "traefik.enable=true" - - "traefik.frontend.rule=Host:dev2.eatvio.com,socket.eatvio.com" + - "traefik.frontend.rule=Host:wstesting.eatv.io,testing.eatv.io" - "traefik.port=80" - "traefik.protocol=http" @@ -131,23 +134,79 @@ services: - ns-eatvio typesense: - image: typesense/typesense:29.0 + build: ./phpdocker/typesense restart: always healthcheck: - test: - - CMD - - wget - - "--no-verbose" - - "--spider" - - "http://localhost:8108/health" + 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 index e5ec0b8..2dec403 100644 --- a/phpdocker/README.html +++ b/phpdocker/README.html @@ -1,208 +1,232 @@ - - PHPDocker.io Readme - - + + PHPDocker.io Readme + + + + -
+
-

PHPDocker.io generated environment

+

PHPDocker.io generated environment

-

Add to your project

+

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.

+

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).

+

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.

+

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

+

How to run

-

Dependencies:

+

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.

+

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

+

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

+

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
+ + + + + + + + + + + + + + + + + +
ServiceAddress outside containers
Webserverlocalhost:1092
MySQLhost: localhost; port: 1094
-

Hosts within your environment

+

Hosts within your environment

-

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

+

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

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

Docker compose cheatsheet

+

Docker compose cheatsheet

-

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

+

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: +
      +
    • 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
      • -
    • -
    +
      +
    • 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

+

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.

+

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

+

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

-

Recommendations

+

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.

+

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.
  • -
+
    +
  • 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

+

Simple basic Xdebug configuration with integration to PHPStorm

-

Xdebug 2

+

Xdebug 2

-

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

+

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

-

For linux:

+

For linux:

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

For macOS and Windows:

+

For macOS and Windows:

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

Xdebug 3

+

Xdebug 3

-

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

+

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

-

For linux:

+

For linux:

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

For macOS and Windows:

+

For macOS and Windows:

-
xdebug.mode = debug
-xdebug.remote_host = host.docker.internal
-xdebug.start_with_request = yes
-
+
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:

+

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

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

Create a server configuration in PHPStorm:

+

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
  • -
+
    +
  • 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 index 3452aaa..dfc0309 100644 --- a/phpdocker/README.md +++ b/phpdocker/README.md @@ -139,6 +139,3 @@ environment: 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/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/*