Skip to content

FaustineLarmagna/symfony3-api-docker

Repository files navigation

Docker Symfony3 - API project

Used docker-symfony repository: https://github.com/maxpou/docker-symfony.git

Installation

  1. Create a .env from the .env.dist file. Adapt it according to your symfony application

    cp .env.dist .env
  2. Build/run containers with (with and without detached mode)

    $ docker-compose build
    $ docker-compose up -d
    # shut down containers:
    $ docker-compose down
    # see containers' status:
    $ docker-compose ps
  3. Update your system host file (add electronic-store.dev)

    # UNIX only: get containers IP address and update host (replace IP according to your configuration) (on Windows, edit C:\Windows\System32\drivers\etc\hosts)
    $ sudo echo $(docker network inspect bridge | grep Gateway | grep -o -E '[0-9\.]+') "electronic-store.dev" >> /etc/hosts
  4. Prepare Symfony app: see ElecStoreAPI/README.md

  5. Enjoy :-)

Usage

Just run docker-compose up -d, then:

How it works?

Have a look at the docker-compose.yml file, here are the docker-compose built images:

  • db: This is the MySQL database container,
  • php: This is the PHP-FPM container in which the application volume is mounted,
  • nginx: This is the Nginx webserver container in which application volume is mounted too,
  • elk: This is a ELK stack container which uses Logstash to collect logs, send them into Elasticsearch and visualize them with Kibana.

This results in the following running containers:

$ docker-compose ps
           Name                          Command               State              Ports            
--------------------------------------------------------------------------------------------------
dockersymfony_db_1            /entrypoint.sh mysqld            Up      0.0.0.0:3306->3306/tcp      
dockersymfony_elk_1           /usr/bin/supervisord -n -c ...   Up      0.0.0.0:81->80/tcp          
dockersymfony_nginx_1         nginx                            Up      443/tcp, 0.0.0.0:80->80/tcp
dockersymfony_php_1           php-fpm                          Up      0.0.0.0:9000->9000/tcp      

Useful commands

# bash commands
$ docker-compose exec php bash

# Composer (e.g. composer update)
$ docker-compose exec php composer update

# F***ing cache/logs folder
$ sudo chmod -R 777 var/cache var/logs var/sessions # Symfony3

About

Used https://github.com/maxpou/docker-symfony.git repository for docker configuration and developed a small API project in Symfony3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published