Skip to content
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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CMD [ "frankenphp", "run", "--config", "/etc/caddy/Caddyfile" ]
FROM frankenphp_base AS frankenphp_dev

ENV APP_ENV=dev XDEBUG_MODE=off
ENV FRANKENPHP_CONFIG="import dev.worker.Caddyfile"

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

Expand All @@ -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" ]

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

Copy link
Contributor Author

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

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.

Copy link
Contributor

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:

  1. 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
  2. The second one is frankenphp_dev which takes the base one, adds the debugger and add the --watch argument to the frankenphp command
  3. 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 the worker mode through the line ENV FRANKENPHP_CONFIG="import worker.Caddyfile" (this environment variable is read by the main Caddyfile; the worker.Caddyfile enables the worker mode)

It is well designed by default, but it can be forked and adapted as you prefer as @deluxetom said

Copy link
Contributor Author

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 !


Expand Down
5 changes: 5 additions & 0 deletions frankenphp/dev.worker.Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
worker {
file ./public/index.php
env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime
watch
}
Loading