Skip to content

DavidMaarek/docker-base-nginx-php-mariadb-for-symfony

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Docker base for Symfony project with Nginx, Php and Mariadb

Test on macOS Catalina 10.15.7 and macOS Big Sur 10.0.1

If you already have a Symfony project, just copy the docker folder and the docker-compose at the root of your application, and go to "4. Configure .env".

1. Clone this project

git clone git@github.com:DavidMaarek/docker-base-nginx-php-mariadb-for-symfony.git
cd docker-base-nginx-php-mariadb-for-symfony

2. Create Symfony project with composer

Run this if if you are building a traditional web application
composer create-project symfony/website-skeleton symfony_project

Run this if your are buliding a microservice, console application or API
composer create-project symfony/skeleton symfony_project

3.Move the contents of the symfony project folder

Run this if if you are building a traditional web application
mv symfony_project/* ./ && mv symfony_project/.* ./
rm -rf symfony_project

4. Configure .env

In the .env file created by composer, configure the DATABASE_URL
DATABASE_URL=mysql://db_user:db_password@mariadb:3306/db_name?serverVersion=mariadb-10.5.5

And add 4 more variables at the end of the file :

MYSQL_DATABASE=db_name
MYSQL_USER=db_user
MYSQL_PASSWORD=db_password
MYSQL_ROOT_PASSWORD=root_password

5. Change domain name (optional)

By default, it's localhost, but if you want to customize the domain name, go to this file docker/nginx/default.conf, and at line 5 and change localhost to whatever you want.
And on MacOS edit this file sudo vi /private/etc/hosts, and add 127.0.0.1 yourCustomDomain

6. Launch the docker-compose

At the root of the project, launch this command :
docker-compose up

About

Docker base for Symfony project with Nginx, Php and Mariadb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published