Comments (21)
That's very interesting and definitely a scenario that should work with Flex. I would really like if we could have automatic configuration based on what packages you install (like your Redis example). Not sure we have the right abstractions for that right now, but happy to add anything that would help going in that direction. I wanted to be able to do the same for SensioCloud. So, that would benefit more than just Docker.
The only thing we need to think of is the override of the web/index.php
file.
In any case, please continue working on this, that gets me very excited.
from flex.
the ability to update docker-compose.yaml and the Dockerfile from a recipe.
As long as it is strictly opt-in only.
from flex.
My prototype is almost working. Please wait for it and the related blog post to make an opinion.
Kubernetes support is a must have (it will come). But Docker-compose is shipped with most Docker installations. It will allow to manage the lyfecycle of a Symfony project from installation to production and during all the development cycle.
In term of DX, it will be a game changer, and definitely better than Vagrant, Homestead and other WAMP.
from flex.
The closest thing for now is https://github.com/api-platform/api-platform
from flex.
I have a rather complex Symfony app (WIP, also ApiPlatform) in Docker: development with Docker Compose, deployment to Openshift / Kubernetes, support for environments, a lot of tweaks per each image for example, my app image allows for XDebug on development but it's disabled on production (using the exact same image, different runtime environment) or uses the same image for web app server (PHP-FPM) and async CLI-workers (Console + Enqueue bundle) which, if in development, monitor the src/
folder for changes and auto-restart the workers.
From that experience, it shouldn't be too hard to get a pretty good all-around config, but the problem would be how to allow for extendability as you currently can't extend Dockerfiles (you can extend Docker Compose file, that's how I get the per-environment settings), it would be a run-once deal.
from flex.
I don't believe Symfony Flex should create services in the Docker Compose file (or its equivalent in other container orchestration systems).
But we really need a "developer story" to understand what's the experience like using Symfony Flex with Docker. I believe that for Symfony Flex to be successful, it really needs to treat Docker as a first-class citizen (and this is the perfect opportunity to ensure that is the case). I've just started trying it out...
from flex.
First, @dkarlovi nice work on https://github.com/dkarlovi/symfony-flex-docker, healthcheck and all.
As for extensibility there are a few things we can potentially use here:
- Recipes can be allowed to specify either php extensions to enable (among the once in php source), or to install via pecl
- (One blocker here, pecl is not able to pick latests version of for instance memcached on PHP 5.6, you'll have to specify version for that. Not saying we care about php 5.6, but the same issue will come back at any point there is sufficient breaks in php again for extensions)
- Recipes can provide own services, we can use docker composes support for being able to stack several files after each other (also supported by
COMPOSE_FILE
env variable that can be set in .env) - Makefile with abstraction / simplification for docker use
- Symfony Flex generating .env file for the result, including COMPOSE_FILE, and providing build arguments to app container for php extensions
from flex.
@andrerom I'll open a PR on Flex soon adding the ability to update docker-compose.yaml
and the Dockerfile
from a recipe.
I've also created a new installer for Flex using Docker: https://github.com/dunglas/symfony-docker-skeleton/tree/autoinstall
from flex.
First, @dkarlovi nice work on https://github.com/dkarlovi/symfony-flex-docker
Thanks,
I'm thinking more in line of:
- creating a utility which is able to emit a valid
Dockerfile
while being configured programmatically - setup the base
symfony-flex-docker
repo to allow for placing configuration for 1) in with a classic.d
notation - split the base repo into sub-repos which would add their specific fragments into those
.d
folders (this would allow saysymfony-flex-docker-mysql
to request the app image to supportpdo_mysql
, for example, or similar) - rebuilding the base
Dockerfile
and the base app image when required
It seems like it would go a long way.
from flex.
the ability to update docker-compose.yaml and the Dockerfile from a recipe
Also not a fan of this, TBH.
from flex.
the ability to update docker-compose.yaml and the Dockerfile from a recipe
Not a fan either as i think docker-compose is a too higher level of abstraction for that.
IMO we should build something that use directly the Docker API so it will be easier to maintain and also we would have more capabilites and better integration with Docker.
from flex.
use directly the Docker API
This is a wrong level of abstraction, IMO. You'd need to figure out how to hook into stuff like Kubernetes / OpenShift / other solutions which already do this so you end up between a rock and a hard place. While, using Compose, you get to use more established tools like Kompose.
from flex.
@dunglas , did you publish the blog post you cited in your comment? Where is it? I'd like to read it to understand better Docker use with Symfony other than the code in the repo you are working on... Thank you!
from flex.
@dunglas i have some questions =)
How do you recommend to start new project? via download dunglas/symfony-docker and docker-compose up or via traditional composer create-project symfony/skeleton
? How do you think recommended Dockerfile
and docker-compose.yaml
should be delivered to developer? How do you deploy your projects to production? Do you build docker image with project code? Do you use same docker-compose.yaml
in dev and prod?
from flex.
Hi,
How do you recommend to start new project?
Using download dunglas/symfony-docker and docker-compose up
, but this repository deserves an update (it works, but can be improved thanks to recent changes in both Flex and Docker)
How do you think recommended Dockerfile and docker-compose.yaml should be delivered to developer?
What do you mean exactly? See #128 for the state of the art (nothing ready yet)
How do you deploy your projects to production?
Using Kubernetes.
Do you build docker image with project code?
I'm not sure of what you mean exactly, but I guess the answer is yes.
Do you use same docker-compose.yaml in dev and prod?
I use Kubernetes in dev, not Swarm.
from flex.
What do you mean exactly?
If you recommend to start new project with downloading a repository, then initial recommended Dockerfile
and docker-compose.yaml
will be downloaded together with that repository (and Dockerfile will have its ###> recipes ###
); and #128 is about how to update that initial files. I think a starting point, i.e. how developer creates a new project, is very important. And if i understood you correctly, you suggest to replace composer create-project
with something different.
About building an image with project code: you use build
feature to describe and launch services, not image
, so i guess you do not build images with code to launch them in production. And php from container with application reads files from the host via ./:/srv/app:rw
volume. This is important for me too.
Thank you for your answers, @dunglas
from flex.
@covex-nn I'd suggest adapting from https://github.com/api-platform/api-platform as it's the most up-to-date setup we have.
from flex.
@teohhanhui i am looking for a workflow that start from creating a project and developing with docker-compose
and finish on building docker images and deploying them to production (my own solution is not perfect =)
I would like to have a standard "workflow from Symfony", which most of developers will use without modifications, and with which i could:
- Start a project with
composer create-project symfony/skeleton
; - Copy docker specific files into project, develop symfony app in a team, debug scripts with xdebug;
- Build images, push them to docker repository, and deploy to staging/production;
From api-platform
i potentially could take Dockerfile, but there is no installed xdebug in there. And unfortuntely i cannot manage Alpine Linux (i switched to base image, based on debian:stretch-slim
)
from flex.
@fabpot
the flex recipe for FrameworkBundle would already be more docker friendly, if it would stop forcing on you using either .env.local.php
or DotEnv
. See: symfony/recipes#529
If it instead would check for already existing APP_ENV
and do simply nothing, otherwise fall back to one of the above. But it does not. Instead it expect from you do provide it an FAKE environment in one of two different ways. When you have a clean user per app setup with environment OR docker, this is bad, because your app has a false environment, which in reality does not (have to) exist in the context the app is run. Yout forcefully detach the app environment from its real environment. This way, you do not need environment and can simply name it "configuration variables". The issue though is, that just replacing the new bootstrap and ditching DotEnv (sad I had to do it) does not fix the issue of you forcing the multi-env-file logic on the user. I need to either completely drop using flex OR to "fake" the .dist logic from before making my .env.local the .env, which naming wise kind of is less clear and common practice.
from flex.
While I agree, this does the trick with no real drawbacks: https://github.com/api-platform/api-platform/blob/master/api/Dockerfile#L71
from flex.
@dunglas but why workaround, instead of simple & clean solution? (symfony/recipes#529)
from flex.
Related Issues (20)
- Renaming of docker-compose.yaml in compose.yaml : postgresql does'nt work anymore HOT 8
- Unclear problem description when Flex blocks package installation (by `extra.symfony.require` rule) HOT 1
- [Feature] Recipe endpoint for private recipe should not be in the project but in the bundle
- Missing tag for version v1.21.5 ? HOT 3
- Remove importmap entries when uninstalling a package
- ComposerScriptsConfigurator can break "composer.json" filename in patch
- Symfony Flex 1.8.5 is not compatible with Composer 2.7.0
- Symfony Flex fails when using Composer 2.7.0, running as root HOT 7
- Unable to update recipe HOT 3
- PackageJsonSynchronizer is not fail safe HOT 1
- Invalid version string "master.9999999" HOT 2
- Make packages.json synchronization optional
- `dump-env` command doesn't respect real Env Vars during Expansion.
- OPcache API is restricted by "restrict_api" HOT 4
- Flex tries to install version that are not tagged
- Certificate error https://flex.symfony.com HOT 3
- Suggest adding management of the compose.yml file in addition to docker-compose.yml HOT 1
- Optimized key management to avoid duplication
- Support for local stored recipe files
- Resolving dependencies fails for symfony/psr-http-message-bridge after change of recipe
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flex.