Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docker environment with Symfony REST API example

License

NotificationsYou must be signed in to change notification settings

systemsdk/docker-symfony-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker environment (based on official php and mysql docker hub repositories) required to run Symfony with JSON REST API example.

Actions StatusCircleCICoverage StatusLatest Stable VersionMIT licensed

Source code

Requirements

  • Docker Engine version 23.0 or later
  • Docker Compose version 2.0 or later
  • An editor or IDE
  • MySQL Workbench

Note: OS recommendation - Linux Ubuntu based.

Components

  1. Nginx 1.27
  2. PHP 8.4 fpm
  3. MySQL 8
  4. Symfony 7
  5. RabbitMQ 4
  6. Elasticsearch 7
  7. Kibana 7
  8. Redis 8
  9. Mailpit (only for debug emails on dev environment)

Setting up Docker Engine with Docker Compose

For installing Docker Engine with docker compose please follow steps mentioned on pageDocker Engine.

Note 1: Please run next cmd after above step if you are using Linux OS:sudo usermod -aG docker $USER

Note 2: If you are using Docker Desktop for MacOS 12.2 or later - please enablevirtiofs for performance (enabled by default since Docker Desktop v4.22).

Setting up DEV environment

1.You can clone this repository from GitHub or install via composer.

If you have installed composer and want to install environment via composer you can use next cmd command:

composer create-project systemsdk/docker-symfony-api api-example-app

2.Set another APP_SECRET for application in .env.prod and .env.staging files.

Note 1: You can get unique secret key for examplehere.

Note 2: Do not use .env.local.php on dev and test environment (delete it if exist).

Note 3: If you want to change default web port/xdebug configuration you can create .env.local file and set some params (see .env file).

Note 4: Delete var/mysql-data folder if it exists.

3.Add domain to local 'hosts' file:

127.0.0.1    localhost

4.Configure/docker/dev/xdebug-main.ini (Linux/Windows) or/docker/dev/xdebug-osx.ini (MacOS) (optional):

  • In case you need debug only requests with IDE KEY: PHPSTORM from frontend in your browser:
xdebug.start_with_request = no

Install locally in Firefox extension "Xdebug helper" and set in settings IDE KEY: PHPSTORM

  • In case you need debug any request to an api (by default):
xdebug.start_with_request = yes

5.Elasticsearch is pre-configured with the following privileged bootstrap user(you can use it in order to enter in Kibana):

user: elasticpassword: changeme

Note: For prod/staging environment another password should be used.

6.Build, start and install the docker images from your terminal:

make buildmake startmake composer-installmake generate-jwt-keys

7.Make sure that you have installed migrations / created roles and groups / cron jobs / messenger transports / elastic template:

make migratemake create-roles-groupsmake migrate-cron-jobsmake messenger-setup-transportsmake elastic-create-or-update-template

8.In order to use this application, please open in your browser next urls:

Setting up STAGING environment locally

1.You can clone this repository from GitHub or install via composer.

Note: Delete var/mysql-data folder if it is exist.

If you have installed composer and want to install environment via composer you can use next cmd command:

composer create-project systemsdk/docker-symfony-api api-example-app

2.Elasticsearch is pre-configured with the following privileged bootstrap user:

user: elasticpassword: changeme

3.Build, start and install the docker images from your terminal:

make build-stagingmake start-stagingmake generate-jwt-keys

4.Make sure that you have installed migrations / created roles and groups / cron jobs / messenger transports / elastic template:

make migrate-no-testmake create-roles-groupsmake migrate-cron-jobsmake messenger-setup-transportsmake elastic-create-or-update-template

Setting up PROD environment locally

1.You can clone this repository from GitHub or install via composer.

If you have installed composer and want to install environment via composer you can use next cmd command:

composer create-project systemsdk/docker-symfony-api api-example-app

2.Edit compose-prod.yaml and set necessary user/password for MySQL and RabbitMQ.

Note: Delete var/mysql-data folder if it is exist.

3.Edit env.prod and set necessary user/password for MySQL and RabbitMQ.

4.Elasticsearch is pre-configured with the following privileged bootstrap user:

user: elasticpassword: changeme

5.Build, start and install the docker images from your terminal:

make build-prodmake start-prodmake generate-jwt-keys

6.Make sure that you have installed migrations / created roles and groups / cron jobs / messenger transports / elastic template:

make migrate-no-testmake create-roles-groupsmake migrate-cron-jobsmake messenger-setup-transportsmake elastic-create-or-update-template

How to enable paid features for Elasticsearch

Switch the value of Elasticsearch'sxpack.license.self_generated.type option frombasic totrial (/docker/elasticsearch/config/elasticsearch.yml).

Getting shell to container

After application will start (make start) and in order to get shell access inside symfony container you can run following command:

make ssh

Note 1: Please use next make commands in order to enter in other containers:make ssh-nginx,make ssh-supervisord,make ssh-mysql,make ssh-rabbitmq.

Note 2: Please useexit command in order to return from container's shell to local shell.

Building containers

In case you edited Dockerfile or other environment configuration you'll need to build containers again using next commands:

make downmake buildmake start

Note: Please use environment-specific commands if you need to build test/staging/prod environment, more details can be found using helpmake help.

Start and stop environment containers

Please use next make commands in order to start and stop environment:

make startmake stop

Note 1: For staging environment need to be used next make commands:make start-staging,make stop-staging.

Note 2: For prod environment need to be used next make commands:make start-prod,make stop-prod.

Stop and remove environment containers, networks

Please use next make commands in order to stop and remove environment containers, networks:

make down

Note: Please use environment-specific commands if you need to stop and remove test/staging/prod environment, more details can be found using helpmake help.

Additional main command available

make buildmake build-testmake build-stagingmake build-prodmake startmake start-testmake start-stagingmake start-prodmake stopmake stop-testmake stop-stagingmake stop-prodmake downmake down-testmake down-stagingmake down-prodmake restartmake restart-testmake restart-stagingmake restart-prodmake env-stagingmake env-prodmake generate-jwt-keysmake sshmake ssh-rootmake fishmake ssh-nginxmake ssh-supervisordmake ssh-mysqlmake ssh-rabbitmqmake ssh-elasticsearchmake ssh-kibanamake composer-install-no-devmake composer-installmake composer-updatemake composer-auditmake infomakehelpmake logsmake logs-nginxmake logs-supervisordmake logs-mysqlmake logs-rabbitmqmake logs-elasticsearchmake logs-kibanamake drop-migratemake migratemake migrate-no-testmake migrate-cron-jobsmake fixturesmake create-roles-groupsmake messenger-setup-transportsmake elastic-create-or-update-templatemake phpunitmake report-code-coveragemake phpcsmake ecsmake ecs-fixmake phpmetricsmake phpcpdmake phpcpd-html-reportmake phpmdmake phpstanmake phpinsightsetc....

Notes: Please see more commands in Makefile

Architecture & packages

External links / resources

Guidelines

Working on your project

  1. For new feature development, forkdevelop branch into a new branch with one of the two patterns:
    • feature/{ticketNo}
  2. Commit often, and write descriptive commit messages, so its easier to follow steps taken when reviewing.
  3. Push this branch to the repo and create pull request intodevelop to get feedback, with the formatfeature/{ticketNo} - "Short descriptive title of Jira task".
  4. Iterate as needed.
  5. Make sure that "All checks have passed" on CircleCI(or another one in case you are not using CircleCI) and status is green.
  6. When PR is approved, it will be squashed & merged, intodevelop and later merged intorelease/{No} for deployment.

Note: You can find git flow detail examplehere.

License

The MIT License (MIT)


[8]ページ先頭

©2009-2025 Movatter.jp