Giter Club home page Giter Club logo

symfony-docker's Introduction

🐳 Docker + PHP 8.2 + MySQL + Nginx + Symfony 6.2 Boilerplate

Description

This is a complete stack for running Symfony 6.2 into Docker containers using docker-compose tool.

It is composed by 4 containers:

  • nginx, acting as the webserver.
  • php, the PHP-FPM container with the 8.2 version of PHP.
  • db which is the MySQL database container with a MySQL 8.0 image.

Installation

  1. 😀 Clone this repo.

  2. If you are working with Docker Desktop for Mac, ensure you have enabled VirtioFS for your sharing implementation. VirtioFS brings improved I/O performance for operations on bind mounts. Enabling VirtioFS will automatically enable Virtualization framework.

  3. Create the file ./.docker/.env.nginx.local using ./.docker/.env.nginx as template. The value of the variable NGINX_BACKEND_DOMAIN is the server_name used in NGINX.

  4. Go inside folder ./docker and run docker compose up -d to start containers.

  5. You should work inside the php container. This project is configured to work with Remote Container extension for Visual Studio Code, so you could run Reopen in container command after open the project.

  6. Inside the php container, run composer install to install dependencies from /var/www/symfony folder.

  7. Use the following value for the DATABASE_URL environment variable:

DATABASE_URL=mysql://app_user:helloworld@db:3306/app_db?serverVersion=8.0.33

You could change the name, user and password of the database in the env file at the root of the project.

To learn more

I have recorded a Youtube session explaining the different parts of this project. You could see it here:

Boilerplate para Symfony basado en Docker, NGINX y PHP8

symfony-docker's People

Contributors

ger86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony-docker's Issues

NGINX Problem: FastCGI sent in stder

Hi! when you go to localhost , you get File not found.

in docker logs
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.18.0.1, server: dev.symfony-docker.com, request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.3:9000", host: "localhost"

Session Owner problem

Hello there!
I created a user login, but the session file is created as root and after the redirect post login, it's lost.

Here is an example of my session folder:
root@fc6efdbb31d0:/var/www/symfony# ll var/sessions/dev/ total 28 drwxr-xr-x 9 www-data www-data 288 Dec 15 13:19 . drwxr-xr-x 3 www-data www-data 96 Dec 15 11:39 .. -rw------- 1 root root 165 Dec 15 13:18 sess_06e7a9a8c7fba9cf4cbd88017b320951 -rw------- 1 root root 664 Dec 15 13:19 sess_2c5510a07cd78830c3ae819251fb1534 -rw------- 1 www-data www-data 664 Dec 15 12:52 sess_2dcc4a8d4e055368c644b65387f28c44 -rw------- 1 www-data www-data 664 Dec 15 12:38 sess_6c5b1267748fb14f1f9f264285c8152c -rw------- 1 www-data www-data 165 Dec 15 12:52 sess_865851975c66178b34c093a301f421c8 -rw------- 1 www-data www-data 165 Dec 15 12:37 sess_878aea56cb302b85317b81c2fb85e42c -rw------- 1 root root 115 Dec 15 13:19 sess_ffa652566dd353f6bb7dba4a36daae7a

The www-data files exists because I try to change the permissions, but the new files are created as root anyway.

File not found

Hi!

When i try to access localhost:80 it says: File not Found.

Wouldn't be better to give php version?

Wouldn't be better to give php version in line below?
FROM php:fpm-stretch

For example:
FROM php:8.0.10-fpm

Why do you use "fpm-stretch" ? Is it an individual package prepared by someone??

And the similar problem with nginx: FROM nginx:latest Isn't it dangerous to give last version? In a year two, when a new nginx will come?

Problem running on linux Server

I want to run the project on a Ubuntu Server. The problem is, docker sync is for linux not stable. Is it possible to just use docker compose?

For Development on my Mac everything works smooth, working with docker sync and the remote container extension.

Unsupported config option for services.db: 'platform'

I tried to start docker-compose up -d and got next error:

docker-compose up -d
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.db: 'platform'

Help me, please.
What do I need to edit in this?
My system is Ubuntu 20.04

Error you shouldn't be here

Hola @ger86 cuando lanzo el comando docker-sync-stack start me sale el siguiente error:

El sistema no puede encontrar la ruta especificada.
error you shouldn't be here

Tengo bien instalada la librería de docker-sync y la verdad que no se de dónde puede venir el error...

Muchas gracias, como siempre!

docker-sync-stack not found

Hey there,

is the project still useable? Because i did want to start the containers, but I have to use the docker-sync-stack command
like you said in the README-file. The Problem is that it doesn't find the docker-sync command.

  • I use Mac OS
  • I have Docker installed, but not docker-sync

I would appriciate your help.

THANKS

Error al correr el proyecto

Hola,
Al correr el proyecto da el siguiente error:

➜ symfony-docker git:(master) ✗ docker-compose up
Starting symfony-docker_mysql_1 ... done
Starting symfony-docker_nginx_1 ... done
Starting symfony-docker_php_1 ... done
Attaching to symfony-docker_mysql_1, symfony-docker_nginx_1, symfony-docker_php_1
php_1 | [11-Dec-2019 12:43:25] NOTICE: fpm is running, pid 1
php_1 | [11-Dec-2019 12:43:25] NOTICE: ready to handle connections
mysql_1 | mysqld: Can't open file: 'mysql.ibd' (errno: 0 - )
mysql_1 | 2019-12-11T12:43:25.200283Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
mysql_1 | 2019-12-11T12:43:25.201042Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 1
mysql_1 | 2019-12-11T12:43:26.474742Z 1 [ERROR] [MY-013171] [InnoDB] Cannot boot server version 80017 on data directory built by version 80018. Downgrade is not supported
mysql_1 | 2019-12-11T12:43:31.477182Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
mysql_1 | 2019-12-11T12:43:31.477585Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
mysql_1 | 2019-12-11T12:43:31.477956Z 0 [ERROR] [MY-010119] [Server] Aborting
mysql_1 | 2019-12-11T12:43:31.484672Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.
symfony-docker_mysql_1 exited with code 1

Fatal error

Warning: require(/var/www/symfony/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/symfony/config/bootstrap.php on line 5

Fatal error: require(): Failed opening required '/var/www/symfony/vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/symfony/config/bootstrap.php on line 5

What to do?

After 'composer install' my 'vendor' is empty

Thanks for your work and please help me.

I work on Linux.
I committed all points of your 'Installation' guide.
After running 'composer install' the packages were downloaded and installed but after it, I see my 'vendor' folder empty.
I use phpStorm.

Where is the 'vendor' which was installed packages in?
Also, how to use these containers with phpStrom?

Volodymyr

https://localhost/articles - "This site can’t be reached"

At first it worked but after something it stopped working. The error is totally unclear, like its just not working server. But when I go to localhost - it loads homepage, so it means server works. How can this be?

And I do not understand where to check for logs. I just see symbolyc links to symbolic links

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.