-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
feat: activate the watch mode in dev #717
Conversation
The watch mode should only be enabled en dev. It should be useless in prod. |
yes that was my first idea, will see to change it thx |
@dunglas @maxhelias i am really unsure of the way to achieve this worker {
file ./public/index.php
env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime
{$WATCH_MODE} # where WATCH_MODE can be defined as "watch" or not defined
} |
@@ -63,6 +64,7 @@ RUN set -eux; \ | |||
; | |||
|
|||
COPY --link frankenphp/conf.d/20-app.dev.ini $PHP_INI_DIR/app.conf.d/ | |||
COPY --link frankenphp/dev.worker.Caddyfile /etc/caddy/dev.worker.Caddyfile | |||
|
|||
CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--watch" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frankenphp is already running in watch
mode for dev, if you add the worker for dev (which I think should be in your own Dockerfile
, not the one in this repo) it shouldn't run in watch mode here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @deluxetom thx for commenting
I am very new to both caddy and frankenphp
What you mean is that the actual code already watch new code for exemple a php class inside src or a js file inside asset folder ?
Does this PR is useless then ?
thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think its useless but I think what you're trying to do it out of scope of this repository.
Worker mode isn't meant to be used for development, and watch mode isn't supposed to be used on prod.
What you might want to do is to fork this repository and change the Dockerfile for your own application. This is what I ended up doing on my end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deluxetom is right: the Dockerfile in the symfony-docker project already manages the watch and worker modes.
The Dockerfile builds the project with 3 targets:
- The first one, the frankenphp_base build target, is a common target for development and production image. It contains all dependencies which are common to both type of environement
- The second one is frankenphp_dev which takes the base one, adds the debugger and add the
--watch
argument to thefrankenphp
command - The third one is frankenphp_prod which is independent from the dev one (so the
--watch
argument is not used) and which downloads dependencies and enables theworker
mode through the lineENV FRANKENPHP_CONFIG="import worker.Caddyfile"
(this environment variable is read by the main Caddyfile; theworker.Caddyfile
enables the worker mode)
It is well designed by default, but it can be forked and adapted as you prefer as @deluxetom said
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oki thx both of you with all your comments
of course after using this repo as base I've tweaked some file and perhaps missed something regarding such watch logic as when testing as I had to rebuild to have y code available
will double check this specifically
in the meantime lets close here if it wont bring value as it should be already the case
thx again !
hey
the blog post https://dunglas.dev/2024/11/frankenphp-1-3-massive-performance-improvements-watcher-mode-dedicated-prometheus-metrics-and-more/
the paragraph "File Watchers" talks about this feature
watch
Questions:
prod
worker.Caddyfile
fromdev
orprod
?ENV FRANKENPHP_CONFIG="import dev.worker.Caddyfile"
inside thefrankenphp_dev
docker compose up --watch
afterdocker compose build --no-cache --pull
?thank you,