From 8b48685368a84e6868880f4b8e3e44b7fd7f8d56 Mon Sep 17 00:00:00 2001 From: shadowc Date: Thu, 17 Mar 2022 19:54:00 +0100 Subject: [PATCH 1/6] Add version support for the --public parameter and a small docker support section --- frontend/encore/virtual-machine.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/encore/virtual-machine.rst b/frontend/encore/virtual-machine.rst index 793a74e3d40..33196ceb3b0 100644 --- a/frontend/encore/virtual-machine.rst +++ b/frontend/encore/virtual-machine.rst @@ -58,6 +58,10 @@ If your Symfony application is running on a custom domain (e.g. } } +.. versionadded:: 1.9.0 + + The ``--public`` option was added in Encore 1.9.0 + After restarting Encore and reloading your web page, you will probably see different issues in the web console: @@ -92,6 +96,22 @@ connections: Make sure to run the development server inside your virtual machine only; otherwise other computers can have access to it. +Docker support +~~~~~~~~~~~~~~ + +If you are using ``docker``, to set up a ``nodejs`` ``docker-compose`` setup +that works with the ``localhost:8080`` domain, add: + +.. code-block:: yml + + nodejs: + image: node:16 + working_dir: /var/www + volumes: + - ./:/var/www:rw,cached + - ~/.symfony/certs/default.p12:/root/.symfony/certs/default.p12 + command: bash -c "yarn && yarn run dev-server --public https://localhost:8080 --host 0.0.0.0" + Fix "Invalid Host header" Issue ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 0080dc00fcab10791cf5b9977dbe07f82c337a85 Mon Sep 17 00:00:00 2001 From: shadowc Date: Thu, 17 Mar 2022 20:10:28 +0100 Subject: [PATCH 2/6] Corrected with valid and tested docker config --- frontend/encore/virtual-machine.rst | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/frontend/encore/virtual-machine.rst b/frontend/encore/virtual-machine.rst index 33196ceb3b0..5068abf3dce 100644 --- a/frontend/encore/virtual-machine.rst +++ b/frontend/encore/virtual-machine.rst @@ -104,13 +104,19 @@ that works with the ``localhost:8080`` domain, add: .. code-block:: yml - nodejs: - image: node:16 - working_dir: /var/www - volumes: - - ./:/var/www:rw,cached - - ~/.symfony/certs/default.p12:/root/.symfony/certs/default.p12 - command: bash -c "yarn && yarn run dev-server --public https://localhost:8080 --host 0.0.0.0" + services: + nodejs: + image: node:16 + working_dir: /var/www + ports: + - '8080:8080' + volumes: + - ./:/var/www:rw,cached + - ~/.symfony/certs/default.p12:/root/.symfony/certs/default.p12 + command: bash -c "yarn && yarn run dev-server --public https://localhost:8080 --host 0.0.0.0 --https" + +You may need to load the ``https://localhost:8080`` url once with your browser +and accept the security exception before our assets can be loaded correctly. Fix "Invalid Host header" Issue ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 94f2d6cb8f015a3cda571f4669115e444eff85b9 Mon Sep 17 00:00:00 2001 From: shadowc Date: Thu, 17 Mar 2022 20:12:12 +0100 Subject: [PATCH 3/6] typo --- frontend/encore/virtual-machine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/encore/virtual-machine.rst b/frontend/encore/virtual-machine.rst index 5068abf3dce..29af03e58ba 100644 --- a/frontend/encore/virtual-machine.rst +++ b/frontend/encore/virtual-machine.rst @@ -102,7 +102,7 @@ Docker support If you are using ``docker``, to set up a ``nodejs`` ``docker-compose`` setup that works with the ``localhost:8080`` domain, add: -.. code-block:: yml +.. code-block:: yaml services: nodejs: From 9bf6ec93e3f2cf6e4aa15aa602291749aff7e73c Mon Sep 17 00:00:00 2001 From: shadowc Date: Thu, 17 Mar 2022 21:02:37 +0100 Subject: [PATCH 4/6] better wording --- frontend/encore/virtual-machine.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/encore/virtual-machine.rst b/frontend/encore/virtual-machine.rst index 29af03e58ba..36ee5482145 100644 --- a/frontend/encore/virtual-machine.rst +++ b/frontend/encore/virtual-machine.rst @@ -100,7 +100,8 @@ Docker support ~~~~~~~~~~~~~~ If you are using ``docker``, to set up a ``nodejs`` ``docker-compose`` setup -that works with the ``localhost:8080`` domain, add: +that works with the ``localhost:8080`` domain, add this to your +``docker-compose-yml`` file: .. code-block:: yaml From 232b3056348f407d8c5d2bfaa2e6921d743fd524 Mon Sep 17 00:00:00 2001 From: shadowc Date: Fri, 18 Mar 2022 16:40:18 +0100 Subject: [PATCH 5/6] Some fixes to doc samples, add remark about HMR hub url --- frontend/encore/virtual-machine.rst | 32 ++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/frontend/encore/virtual-machine.rst b/frontend/encore/virtual-machine.rst index 36ee5482145..853bf68785a 100644 --- a/frontend/encore/virtual-machine.rst +++ b/frontend/encore/virtual-machine.rst @@ -58,9 +58,9 @@ If your Symfony application is running on a custom domain (e.g. } } -.. versionadded:: 1.9.0 +.. versionadded:: 1.8.2 - The ``--public`` option was added in Encore 1.9.0 + The ``--public`` option was added in Encore 1.8.2 After restarting Encore and reloading your web page, you will probably see different issues in the web console: @@ -73,6 +73,25 @@ different issues in the web console: You still need to make other configuration changes, as explained in the following sections. +If your Webpack Dev Server HMR hub is unreachable because it is located +in a different url, you may use this option to tell webpack where to look +for it: + +.. code-block:: diff + + { + ... + "scripts": { + - "dev-server": "encore dev-server", + + "dev-server": "encore dev-server --public http://app.vm:8080 --client-web-socket-url ws://app.vm:8080/ws", + ... + } + } + +Note that in this particular case, ``--public`` will do the job of telling +webpack where to locate its HMR hub. But there may be edge cases in which +you may need to specify this as well. + Allow External Access ~~~~~~~~~~~~~~~~~~~~~ @@ -114,10 +133,13 @@ that works with the ``localhost:8080`` domain, add this to your volumes: - ./:/var/www:rw,cached - ~/.symfony/certs/default.p12:/root/.symfony/certs/default.p12 - command: bash -c "yarn && yarn run dev-server --public https://localhost:8080 --host 0.0.0.0 --https" + command: bash -c "yarn && yarn run dev-server --public https://localhost:8080 --host 0.0.0.0 --server-type https" + +.. note:: -You may need to load the ``https://localhost:8080`` url once with your browser -and accept the security exception before our assets can be loaded correctly. + ``https``: You may need to load the ``https://localhost:8080`` url once + with your browser and accept the security exception before your assets + can be loaded correctly under https. Fix "Invalid Host header" Issue ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From e8c04e885ee85f29a61ed0d30317be6f2733f2ee Mon Sep 17 00:00:00 2001 From: shadowc Date: Fri, 18 Mar 2022 16:46:19 +0100 Subject: [PATCH 6/6] allow for versionadded 1.8.2 on encore --- .doctor-rst.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml index 3e716028b86..2bcd1b42a23 100644 --- a/.doctor-rst.yaml +++ b/.doctor-rst.yaml @@ -81,6 +81,7 @@ whitelist: - '# username is your full Gmail or Google Apps email address' - '.. _`LDAP injection`: http://projects.webappsec.org/w/page/13246947/LDAP%20Injection' - '.. versionadded:: 1.9.0' # Encore + - '.. versionadded:: 1.8.2' # Encore - '.. versionadded:: 0.28.4' # Encore - '.. versionadded:: 2.4.0' # SwiftMailer - '.. versionadded:: 1.30' # Twig