Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Thibaut-gauvin/symfony3_docker

Repository files navigation

GET STARTED WITH DOCKER :

More Infos :

Docker Documentation

-----------------------------------------------------

Prerequisites

Install Docker on your system.

Note that using "Docker Toolbox" on Windows OS can occur unexpected issues ...

Install Docker Compose on your system.

Check that you can use docker commands without sudo ! [LINUX USER ONLY]

  • To run docker command without sudo, you need to add your user (who has root privileges) to docker group & restart your sessions.

      $ sudo usermod -aG docker <user_name>
    

-----------------------------------------------------

Installation:

A Makefile is used to provide some useful shortcuts for manipulating docker & docker-compose commands

  • 1- Create .env file :

    First, you need to create a copy of .env.example and call it .env

      # Assume you are in project root, on Unix system
      $ cp .env.example .env
    

    This files contains sensible data that not be committed on GIT, you can modify it to you own needs !

  • 1- Set the .env file :

    Update variables in .env file to fit your config

      # Assume you are in project root, on Unix system
      $ vi .env
    

    Because we use grumphp, we need to configure git inside the container to be able to commit properly

  • 2- Make the ☕ :

    Run following command :

      $ make init
    

    This command will create & build Docker images, also start & configures required Containers, and run provisioning script. A lot of stuff is downloaded from Internet, so it can take a lot of time, depending on your Internet speed.

  • 3- Your done !

You can now access to following services on your host machine:

When you reboot your computer :

  • Just simply run following command to start your Containers (docker Images already created):

      $ make start
    

-----------------------------------------------------

Makefile "tasks" :

You can read Makefile located at project root, it contain some comments on what "recipes" do. Feel free to add more extra recipes depending on your needs.

# List available make commands:
$ make help
Recipes Utility
start Start containers (Also builds & pull images, if there not exists)
stop Stop containers & remove docker networks
list List current running containers
ssh Start new bash terminal inside the Symfony Container
init Execute "start" tasks and run provisioning scripts
tests Execute the entire Unitary & Functional PhpUnit tests suit
code-coverage Run the entire tests with code coverage
logs Display current running containers logs (Press "Ctrl + c" to exit)
clean-sf-cache Clean symfony cache & logs files
clean-container Remove stopped useless containers
help Display available make commands

-----------------------------------------------------

Dev Tools :

You can use make ssh to connect inside the symfony container.

What is inside ?

Other service

  • Mailhog for email testing during development
  • PhpMyAdmin a simply mysql administrator

-----------------------------------------------------

Deploy in Production :

If you want to use in production, you need to :

  • Get SSL certificates, Let's Encrypt provide them for free

  • You also need to generate a dhparam.pem keys to enforce SSL encryption

      # To generate your dhparam.pem file, run in the terminal
      openssl dhparam -out dhparam.pem 4096
    
  • Copy your fullchain.pem & privkey.pem & dhparam.pem to .data/web directory

  • Update .env file and set ENV to "prod"

  • Update nginx prod conf and set server_name at line 4 & line 39

  • Run make start

  • The first time, you need to build app yourself (like installing vendor & set parameter.yml ...)

Test your app, http redirect to https. ssl labs analysis give you a A+ baby !

About

Symfony 3 boilerplate with docker & docker-compose

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published