Open raulbethencourt opened 4 years ago
tried a lot of things, including reverse proxy (similar to Nginx configs in devilbox Docs), exposing 8080 in docker-compose.yml etc, ... didn't get it to work.
So +1
Finally I was able to manage this. So this works now somewhat perfect, with a few sideeffects, see below:
First, your start command needs to look something like this:
encore dev-server --https --host 0.0.0.0
Note: Symfony does still output localhost
if I only configure host
in webpack.config.js
, also --https
needs to be included here for the same reason.
Also tell Devilbox to listen for the webpack-dev-server Port, create a docker-compose.override.yml
from the devilbox example file and add the ports to the php container:
version: '2.3'
################################################################################
# SERVICES
################################################################################
services:
# .....
# ------------------------------------------------------------
# PHP
# ------------------------------------------------------------
php:
image: devilbox/php-fpm:${PHP_SERVER}-work-0.109
hostname: php
# add ports for webpack dev-server
ports:
- "8080:8080"
Third, for the websocket, add some configuration to Encore
in webpack.config.js
.configureDevServerOptions(options => {
options.client = {
host: '0.0.0.0'
};
options.firewall = false;
options.https = true;
})
The only problem is that the browser marks the page as insecure, as the default webpack-dev-server certificate is only signed for localhost
or 127.0.0.1
, but not 0.0.0.0
. Any suggestions?
Temp fix: open a single created file, like https://0.0.0.0/runtime.js
in the browser and add an Exception to the SSL warning.
Webpack Encore 1.0.4 Webpack 5.20.1 Webpack-dev-server: 4.0.0-beta.0 Devilbox 1.7.1
Thanks. Have you lunch encore dev-server inside php container ?
yes, its inside the PHP container.
Forgot to mention, you will also have to update/create docker-compose.override.yml with Ports for PHP container, I'll update my answer ASAP
Sorry, can you give me the code that you have write in your docker-compose.oveerride.yml ? Thanks
I edited my first comment with all the info needed. Also note the versions. Webpack dev server 4 has quite some breaking changes.
Hey, @raulbethencourt does it work?
for docker-compose.override.yml
you could cp docker-compose.yml docker-compose.override.yml
and then simply add this to the php section:
ports:
- "8080:8080"
Still works for me, however its a bit nasty, cause I'll have to add an certificate exception to my browser every now and then.
Sorry ptmrio Ill check it tomorrow. i been working in other projects and I haven't give it the time. Ill tell you tomorrow. But thanks a lot
Hi ptmrio. I'm triying but its not working.
devilbox@php-7.4.10 in /shared/httpd/plataform/plataform/public $ yarn dev-server │
yarn run v1.22.5 │
$ encore dev-server --https --host 0.0.0.0 │
Running webpack-dev-server ... │
│
WARNING Webpack is already provided by Webpack Encore, also adding it to your package.json file may c│
ause issues. │
WARNING Webpack Encore requires version ^8.0.0 of sass-loader. Your version 10.0.2 is too new. The re│
lated feature *may* still work properly. If you have issues, try downgrading the library, or upgrading En│
core. │
WARNING Webpack Encore requires version ^8.0.0 of sass-loader. Your version 10.0.2 is too new. The re│
lated feature *may* still work properly. If you have issues, try downgrading the library, or upgrading En│
core. │
ℹ 「wds」: Project is running at https://0.0.0.0:8080/ │
ℹ 「wds」: webpack output is served from https://0.0.0.0:8080/build/ │
ℹ 「wds」: Content not from webpack is served from /shared/httpd/plataform/plataform/public │
ℹ 「wds」: 404s will fallback to /index.html │
DONE Compiled successfully in 5221ms
I'm geting this error if i dont add anithing in webpack.config.js. And.
devilbox@php-7.4.10 in /shared/httpd/plataform/plataform/public $ yarn dev-server │
yarn dev-server │
yarn run v1.22.5 │
$ encore dev-server --https --host 0.0.0.0 │
Running webpack-dev-server ... │
│
WARNING Webpack is already provided by Webpack Encore, also adding it to your package.json file may c│
ause issues. │
WARNING Webpack Encore requires version ^8.0.0 of sass-loader. Your version 10.0.2 is too new. The re│
lated feature *may* still work properly. If you have issues, try downgrading the library, or upgrading En│
core. │
WARNING Webpack Encore requires version ^8.0.0 of sass-loader. Your version 10.0.2 is too new. The re│
lated feature *may* still work properly. If you have issues, try downgrading the library, or upgrading En│
core. │
error Command failed with exit code 1. │
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
this error if i add the lines into the webpack.config.js
I also did everything you put about docker-compose.override.yml
networks:
app_net:
ipv4_address: 172.16.238.100
# ------------------------------------------------------------
# PHP
# ------------------------------------------------------------
php:
image: devilbox/php-fpm:${PHP_SERVER}-work-0.112
hostname: php
ports:
- "8080:8080"
##
## All .env variables
##
## Source all variables defined in .env
## This also makes any custom variable available in each PHP/HHVM container
##
env_file:
- ./.env
Thank you @ptmrio the --host 0.0.0.0
did it for me!
Hi. I'm trying to use dev-server in docker containers with devilbox and i did all configuration to use dev-server in virtual machine that i found: https://symfony.com/doc/current/frontend/encore/virtual-machine.html But in chrome consol i have this error:
And also i dont have autorefreshing window when i save.
I do the command
$ yarn dev-server
and tha answer is:So it look that its working.
My webpack.config.js:
And my package.json:
My build/manifest.json:
And my entrypoints.json:
So any solution ?