ginsen / docker-sf-app

The goal of this app is run a symfony (3.4 & 4.x) app using docker & docker-compose.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker-sf-app

The goal of this app is run a symfony (3.4 & 4.x) app using docker & docker-compose in DEVELOP environment, this app is not optimize to use in PRODUCTION environment.

NOTE: This app use docker-services to consume services as MySQL and others network services.

Install

Copy and rename .env.dist to .env and edit with your custom params.

$ cp .env.dist .env

Copy your SSH keys for access into the container.

$ cp ~/.ssh/id_rsa.pub ./docker/bash/ssh/
$ cp ~/.ssh/id_rsa ./docker/bash/ssh/

Download your symfony 4 application into this root, with name app

git clone https://github.com/symfony/your-symfony-app.git app

SonarQube

If you has sonar-project.properties.dist in your project, clone it

$ cd app
$ cp sonar-project.properties.dist sonar-project.properties

And change Sonar server to http://sonarqube:9000, such as ...

# ./app/sonar-project.properties

#----- SonarQube server
sonar.host.url=http://sonarqube:9000

Xdebug

For use xdebug in your develop environment you need know what is your IP host on your IDE (PhpStorm) is running, for this issue, run this command.

If your has Ubuntu and awk installed, run it

ip route|awk '/eno1 proto kernel/ { print $9 }'

You see your default network IP as 10.128.80.xxx, copy your IP in your environment file (.env) as:

# .env

# Xdebug
# IP host when run your IDE (PhpStorm). Run in your shell: ip route|awk '/eno1 proto kernel/ { print $9 }'
IP_LISTEN_XDEBUG=10.128.80.5
XDEBUG_PORT=9001

Replace 10.128.80.5 with your default network IP and set XDEBUG_PORT with the port you choice.

PHPStorm configuration Xdebug

Make sure you have the some port that you have configured previously in "XDEBUG_PORT" environment variable:

alt text

Next, we need to configure a server. This is how PHPStorm will map the file paths in your local system to the ones in your container.

Go to File -> Settings -> Languages and Frameworks -> PHP -> Servers

alt text

Give a name to your server. It should match the value you have defined in your "APP" environment variable and replace "symfony-demo" with your "APP" name and replace Port 8888 with your "NGINX_PORT" environment variable.

Up containers

Now you ar ready to up project with docker-compose. Run this commands:

$ docker-compose up -d

Show containers is up.

$ docker-compose ps

Access into container

$ docker-compose exec web bash

When you access into container you access as root, you need change to normal user profile.

$ su {yourname}

Now you are into your project with your profile user, then you can run command to build your symfony app, remember edit the params of your .env app.

$ composer install
...
# yarn install
# ./bin/console doctrine:schema:create
# ... and other stuff

Or run test, sonar-scanner, ...

$ ./bin/phpunit
$ sonar-scanner

About

The goal of this app is run a symfony (3.4 & 4.x) app using docker & docker-compose.

License:MIT License


Languages

Language:Shell 59.8%Language:Dockerfile 40.2%