O
O
okkkman2020-10-14 20:54:38
symfony
okkkman, 2020-10-14 20:54:38

How to optimize Symfony inside Docker?

Hello everyone

Can you please tell me how to optimize a Symfony 5 project using Docker-Compose during Dev development?
I make changes to the controller -> I refresh the page and wait for 15-20 seconds -> re-entry is faster, apparently cached

Tired of this

Thank you

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sl0, 2020-10-14
@sl0

I suspect that the problem is not in symphony, but in docker on a poppy.

A known issue with Docker on a Mac is the additional latency that occurs due to different filesystems. On a symfony project, for example, this delay goes up to ~5-10sec for opening one page. This problem is perfectly solved by the docker-sync utility.

1) - sudo gem install docker-sync
2) - Создает docker-sync.yml файл со следующим содержимым (все последующие комманды должны выполняться из папки с проектом-):

version: '2'

options:
  verbose: true

syncs:
  #название volum-а
  app-sync:
    src: '.'
    sync_excludes: ['var', 'node_modules', 'tests']


3) в файле docker-compose-dev.yml вносим следующие изменения:

volumes:  
  app-sync:
    external: true

Меняем код

services:  
  #...

  php:
    #...
    volumes:
      # ...
      - ./app:/var/www/app


На

services:  
  #...

  php:
    #...
    volumes:
      # ...
      - app-sync:/var/www/app

То есть, чтобы php контейнер смотрел на наш новый volum
4) Далее создаем volum коммандой:

docker volume create app-sync


5) Выполняем команду

docker-sync start


6) И запускаем

docker-compose -f docker-compose-dev.yml up

Для того чтобы не вводить команды с 4-6 каждый раз, можно создать Make файл со следующим содержимым:

OS := $(shell uname)

start_dev:  
ifeq ($(OS),Darwin)  
    docker volume create --name=app-sync
    docker-compose -f docker-compose-dev.yml up -d
    docker-sync start
else  
    docker-compose up -d
endif

stop_dev:           ## Stop the Docker containers  
ifeq ($(OS),Darwin)  
    docker-compose stop
    docker-sync stop
else  
    docker-compose stop
endif


И использовать команду

make start_dev

V
Vladislav Lyskov, 2020-10-14
@Vlatqa

https://thewebland.net/development/devops/uskoryae...
the second or third option is more or less adequate, in my opinion, the first game
may have solved the problem with wsl2, I haven't tried
it yet if Windows, don't know about poppy, on everything should work fine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question