-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create the best possible docker-compose.yml for this project #802
Comments
An important note mentioned to me by a person on Symfony Slack (I don't remember exactly who, I'm sorry). In the normal Symfony Demo app, we must use SQLite because it's our only option to use a database that requires zero setup. However, when using Docker, we can use any database with zero setup. So, let's use PostgreSQL in the Docker config file. (I suggest PosgreSQL because to me it looks more popular among Symfony devs than MySQL). |
the hard part is that our |
@stof could we run a quick |
@javiereguiluz if we copy the file inside the image at build time, we could. If we want to mount the source code instead (to make it a dev-like environment where you can edit things), we cannot modify files in the image (as they are not in the image) |
@javiereguiluz we can remove
then we can create a new .env file for the docker environment |
Hay all, subscribed to this issue when it was being talked about in slack. Was toying around with docker the other day and got reminded of this. Not the most experienced with Docker but can try and help where I can 😄 Do we have any ideas what base image we would want to use. |
we can take this : https://github.com/dunglas/symfony-docker ? |
I would vote for sqlite because you do not have to start an additional container for this database. About the requirements:
|
@OlivierToussaint the aim of your linked docker setup is to start a new Symfony project not to use an existing one. Btw: The project uses the second approach I mentioned in my prior comment. |
@frastel yes I know, but the base of dockerfile & docker-compose is here, we can be inspired |
@OlivierToussaint Ok, for inspiration it is good enough. @syther101 The question of the base image is a good one. |
There are several possibilities, but to summarize:
I personally prefer the approach where everything is provided by a dedicated container. |
I am using this guy
It's good (not include yarn support for assets yet) |
How about building each image from alpine with 3 |
This one is based on a setup from phpdocker.io, with a couple of modifications. I know it can be improved on. Contents are here |
I built this one recently: https://github.com/o-alquimista/symfony-demo-docker
However:
If anyone knows how to automatically detect the UID for the compose file, then things get a lot more simple.
After the containers I haven't discovered any errors or limitations so far. |
@javiereguiluz is help still wanted? Update: #1275 |
@mehdibo hi! Sadly, there's a big problem when trying to solve this. The technical part is not a problem, because many people here know how to dockerize this app. Problem is that there are many different ways of solving it ... and people using Docker can't agree on "the best way" to solve this for this project. Discussions usually end up being an endless debate about why doing XXX is better than doing YYY, and later someone comes and says that both XXX and YYY are wrong and we should do ZZZ. It's a shame, but how things are 😐 |
@javiereguiluz Oh, that's a shame, can't someone from the core team just decide "dectatorally"? I don't think such a debate is important for a demo app. If you have an example of a debate I'd be happy to take a look at it (I promise I won't jump in xD) |
The decision taken by the core team for the Symfony way of running a dev environment is to run PHP on the host and not in Docker (see the book for an example using that setup). |
Yes, I would either implement the "core way"/"Symfony CLI way" or don't implement anything at all. |
I see, well as Javier said that's a shame, from 2018 and we still don't have a Dockerized demo 😅 |
Hi, just saw this old issue. I think the main problem besides the many possibilities to dockerize it are the somewhat unclear requirements or the unclear context. Is it about creating a local symfony dev environment? To give an example what one way is how to develop symfony in a docker environment? This is possible, i did such a setup already, but has some problems like performance when you have to mount too much files you mount into the container. As @stof and @wouterj already said there is the better way to have a local setup. Or is it about creating a docker image that starts up locally to show the demo, but does not mount files from the local computer. So a docker image that could also run anywhere else in the cloud. More a blueprint for a dockerfile to use it in an environment. Just to show a basefile that can be copied and modified (install other php extensions or whatever needed) when you plan to have a containerized running envrionment for your application. Then you could use this blueprint, modify it, create the image during the build process e.g. in the build pipeline and then deploy it to dev or whatever. @javiereguiluz what do you think? |
Personally I think it should run the demo, but allow development of the demo (not the Symfony itself), however requirements are really outdated and should be reviewed. Anyway, I'm interested too, maybe I could help with it if there are clear requirements.
I don't get the problem, we work on Docker locally with the app that mounts >430k files and it's totally usable, why Symfony Demo would be problematic here 🤔? |
@Wirone on which OS are you working ? Based on past feedback (maybe things have changed since them), such volume mounts are very good on Linux but suffer from abysmal performance in Docker for Windows or Docker for Mac because of the additional VM layer being used to run a Linux kernel (the mounts are fast between the container and the Linux VM but slow between the Linux VM and the host). |
@stof I'm on MacOS (M1) with OrbStack, but previously also on Docker Desktop. Yes, the performance is not as good as on Linux, but I'm pretty sure it's totally doable to run Symfony Demo with volume mounts, that would work on any OS. I believe really often these performance problems are caused by wrong Docker setup, not Docker per se. |
@Wirone the performance we talk about here would also be the performance of editing the demo (if we only care about running it, we don't need a volume). Anyway, my local stack runs PHP on the host (with the symfony-cli project) and relies on Docker only for the services. So I don't have the answers for which Docker config will have the right performance. |
@stof I know it's about being able to edit the demo 🙂. I work with Docker stacks for years now, and many times it wasn't even required to have anything installed locally more than Docker itself, everything happened inside containers - both when it comes to serving backend and rebuilding frontend in real-time. I now have PHP installed locally for convenience only and because of PHPStan which is significantly slower on our main project when run in Docker (but it's 30k+ PHP project-only files). I am pretty sure Symfony Demo can be run through Docker with full development support 🙂. |
@Wirone I totally agree that the symfony/demo project can probably be run with good performance on almost any configuration due to being very small. But the whole point of the symfony/demo is to demonstrate how to do things. It is a learning tool. So we cannot select a solution that is acceptable only thanks to the small size of the project as it would defeat its goal. |
@stof but the same solutions work for really large projects I worked or still work with, so... 🤷. IMHO this Demo should lead the path and show how things can (should?) be done, but it just can't cover all real-world scenarios, because each project is different. It can certainly show how to utilise Docker, and if anyone picks this to any real-world project and encounters any problems, then these must be solved in the context of that project. In fact, I believe any other concept picked from this demo can turn out to be problematic just like Docker, so it's only about familiarity - developers most probably won't have problems with PHP or Symfony, while not everyone knows Docker enough. But it should not be a blocker in my opinion 😉. |
Calling for help from Docker experts. We need to create the best possible
docker-compose.yml
file for this project. The application requirements are well defined (we use env vars, Webpack Encore, PHP 7.1, Symfony 4.1, SQLite database, etc.) so it should be possible to create that file.The text was updated successfully, but these errors were encountered: