Skip to content

CS-Cart development environment based on Docker containers

License

Notifications You must be signed in to change notification settings

cscart/development-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS-Cart Development Environment

Docker-based development environment:

  • PHP versions: 8.2, 8.1, 8.0, 7.4 and 7.3.
  • MySQL 5.7 database server.
  • nginx web server.
  1. Install git, docker and docker-compose.

  2. Clone the environment repository:

    $ git clone [email protected]:cscart/development-docker.git ~/srv
    $ cd ~/srv
  3. Create the directory to store CS-Cart files:

    $ mkdir -p app/www
  4. Clone CS-Cart repository or unpack the distribution archive into the app/www directory.

  5. Enable the default application config for nginx:

    $ cp config/nginx/app.conf.example config/nginx/app.conf
  6. Run application containers:

    $ make -f Makefile run
  • DB host: mysql5.7.
  • User: root.
  • Password: root.

PHP 7.4 is used by default.

To use the specific PHP version for your requests, add the following prefix to the domain you request:

  • php7.3. for PHP 7.3.
  • php7.4. for PHP 7.4.
  • php8.0. for PHP 8.0.
  • php8.1. for PHP 8.1.
  • php8.2. for PHP 8.2.

PHP containers do not send actual e-mails when using the mail() function.

All sent emails will be caught and stored in the app/log/sendmail directory.

See comments in the config/nginx/app.conf.example file if you need to host multiple PHP applications inside single Docker PHP container.

xDebug 3 is already configured for PHP7 and PHP8 containers. All you have to do is to uncomment the extension installation in the config/php*/Dockerfile files.

You can read about configuring PHPStorm to work with Docker and xDebug 3 in the "Debugging PHP" article.

Docker-compose creates a subnet with addresses by default 172.18.[0-255].[0-255].

If you run docker locally with a default subnet, then resources using the same addresses will be unavailable - the response will be returned by the local subnet, not the required resource.

To fix the problem, you need to change the address of the docker subnet.

In the docker-compose file.bml shows an example of replacing addresses with 10.10.[0-255].[0-255].

Uncomment the lines in docker-compose.yml and run the following commands:

$ docker network rm $(docker network ls -q)
$ docker-compose down && docker-compose up -d

Среда для разработки на базе Docker:

  • Версии PHP: 8.2, 8.1, 8.0, 7.4 и 7.3.
  • Сервер баз данных MySQL 5.7.
  • Веб-сервер nginx.
  1. Установите git, docker and docker-compose.

  2. Склонируйте репозиторий с окружением:

    $ git clone [email protected]:cscart/development-docker.git ~/srv
    $ cd ~/srv
  3. Создайте папку для файлов CS-Cart:

    $ mkdir -p app/www
  4. Склонируйте репозиторий CS-Cart или распакуйте дистрибутив в папку app/www.

  5. Включите приложение со стандартным конфигом nginx:

    $ cp config/nginx/app.conf.example config/nginx/app.conf
  6. Запустите контейнеры приложения:

    $ make -f Makefile run
  • Хост БД: mysql5.7.
  • Пользователь: root.
  • Пароль: root.

По умолчанию используется PHP 7.4.

Чтобы явно указать версию PHP для конкретного запроса, добавьте к домену следующую приставку:

  • php7.3. для PHP 7.3.
  • php7.4. для PHP 7.4.
  • php8.0. для PHP 8.0.
  • php8.1. для PHP 8.1.
  • php8.2. для PHP 8.2.

PHP по умолчанию не отправляют настоящих писем при вызове функции mail().

Все исходящие e-mail'ы перехватываются и пишутся в папку app/log/sendmail.

См. комментарии в файле config/nginx/app.conf.example.

xDebug уже настроен для использования в контейнерах с PHP7 и PHP8. Для его включения нужно раскомментировать установку модуля в config/php*/Dockerfile.

О настройке PHPStorm для работы с Docker и xDebug 3 можно прочитать в статье "PHP: Настраиваем отладку".

Docker-compose по умолчанию создаёт подсеть с адресами 172.18.[0-255].[0-255].

Если локально запустить докер с дефолтной подсетью, то ресурсы, использующие такие же адреса, будут недоступны - ответ возвращать будет локальная подсеть, а не требуемый ресурс.

Чтобы исправить проблему, нужно изменить адрес подсети докера.

В файле docker-compose.yml приведён пример замены адресов на 10.10.[0-255].[0-255].

Раскомментируйте строки в docker-compose.yml и выполните следующие команды:

$ docker network rm $(docker network ls -q)
$ docker-compose down && docker-compose up -d