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

Use Symfony Local Web Server instead of deprecated WebServerBundle #6850

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yguedidi
Copy link
Contributor

@yguedidi yguedidi commented Aug 17, 2023

closes #6807

WebServerBundle is deprecated in Symfony 4.4 and is removed in Symfony 5.
This PR remove it and make use of the Symfony CLI and its Local Web Server to run Wallabag locally.

Just changing the Dockerfile exposed an issue: the IP visible by Symfony is not anymore 127.0.0.1 but the Docker container IP and so app_dev.php block all requests.
To solve that, we needed the TRUSTED_PROXIES feature to allow Docker container IPs, feature that is available in an up to date index.php file instead of both app.php and app_dev.php.
So I updated some files to match as close as possible to the framework-bundle recipe in version 4.4
If it's requested I can extract those updates in a prerequisite PR to ease the review.

Edit: in order to make tests pass, I also update some test related files to match as close as possible to the phpunit-bridge recipe in version 4.3

@@ -0,0 +1,4 @@
APP_ENV=dev
APP_SECRET=ch4n63m31fy0uc4n
TRUSTED_PROXIES=127.0.0.1/8,10.0.0.0/8,172.16.0.0/12,172.17.0.0/16,172.18.0.0/15,172.20.0.0/14,172.24.0.0/13,192.168.0.0/16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original value is 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
updated to add more based on this article

@@ -0,0 +1,4 @@
APP_ENV=dev
APP_SECRET=ch4n63m31fy0uc4n
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value taken from docker/php/env.example

@@ -20,9 +29,6 @@ docker-compose.override.yml
# Parameters
/app/config/parameters.yml

# Managed by Composer
/vendor/
Copy link
Contributor Author

@yguedidi yguedidi Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed as covered by the ignore rules from framework-bundle recipe

@@ -30,9 +30,6 @@ parameters:

locale: en

# A secret key that's used to generate certain security-related tokens
secret: CHANGE_ME_TO_SOMETHING_SECRET_AND_RANDOM
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed as it became an env var

Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original is Kernel from App namespace, adapted to work with existing AppKernel

Comment on lines +23 to +26
//$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was not in original from recipe, added because it was in app.php

@@ -3,7 +3,7 @@
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
DirectoryIndex index.php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searched for occurences of app.php and app_dev.php in the project to use the new common file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added as is from the recipe

@@ -94,6 +100,7 @@ RUN groupmod -g 1000 www-data ; \
chown -R www-data: /var/www/html \
/usr/local/etc/php/conf.d/wallabag-php.ini \
/var/www/.cache \
/var/www/.yarnrc
/var/www/.yarnrc \
/var/www/.symfony5
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed because Symfony CLI writes in it

/var/www/.cache \
/var/www/.symfony5

WORKDIR /var/www/html
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed because it seems php:8.1 image uses / as default working dir

@@ -15,6 +15,8 @@ RUN apt-get update \
RUN curl 'https://deb.nodesource.com/gpgkey/nodesource.gpg.key' | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_${NODE_VERSION}.x $(lsb_release -cs) main" > /etc/apt/sources.list.d/nodesource.list

RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | bash
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

followed default installation instruction for Ubuntu/Debian from the official website

@yguedidi yguedidi changed the title Use Symfony Local Web Server Use Symfony Local Web Server instead of deprecated WebServerBundle Aug 17, 2023
@yguedidi yguedidi marked this pull request as draft August 17, 2023 22:27
@yguedidi yguedidi force-pushed the use-symfony-local-web-server branch 3 times, most recently from 1b6ffa7 to acadb9c Compare August 17, 2023 23:01
@@ -0,0 +1,5 @@
KERNEL_CLASS='AppKernel'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original is App/Kernel, adapted to work with existing AppKernel

@@ -0,0 +1,5 @@
KERNEL_CLASS='AppKernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=weak
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original is 999999, update to current configuration

@@ -0,0 +1,7 @@
<?php

require dirname(__DIR__) . '/config/bootstrap.php';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original wrap this by a condition that lead to a PHPStan error.
as the file exist for sure in our case, I simplified the code to avoid that error

@yguedidi yguedidi force-pushed the use-symfony-local-web-server branch from acadb9c to 8e6d5fc Compare August 17, 2023 23:14
Comment on lines -16 to -17
.phpunit.result.cache
phpunit.xml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed as covered by the ignore rules from phpunit-bridge recipe

@yguedidi yguedidi marked this pull request as ready for review August 17, 2023 23:15
KERNEL_CLASS='AppKernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=weak
PANTHER_APP_ENV=panther
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symfony\panther is not used in our project

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicosomb I know, I kept it to be as close as possible to the recipe. Maybe one day it will be used for e2e tests. And as it's a env var I don't think it hurts having it.
Another option would be to make those a comment like TRUSTED_HOSTS, what do you think?
If not OK I can of course remove them :)

Copy link
Member

@nicosomb nicosomb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yguedidi do we need to write some documentation?

@yguedidi
Copy link
Contributor Author

do we need to write some documentation?

@nicosomb I don't think so, or at least I don't see what could be documented in this change

@yguedidi yguedidi force-pushed the use-symfony-local-web-server branch from 8e6d5fc to 21d958f Compare August 24, 2023 11:04
@yguedidi yguedidi requested a review from nicosomb August 24, 2023 11:05
@j0k3r j0k3r added this to the 2.7.0 milestone Aug 24, 2023
Copy link
Member

@j0k3r j0k3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should warn that people will have to update their server configuration because web/app.php is replaced by web/index.php.
https://github.com/search?q=repo%3Awallabag%2Fdoc%20app.php&type=code

So maybe we should update the documentation to explain that starting from 2.7.0 version, the index is now web/index.php

@nicosomb
Copy link
Member

nicosomb commented Dec 7, 2023

@yguedidi do you have some work to do on this PR?

@yguedidi
Copy link
Contributor Author

yguedidi commented Dec 7, 2023

@nicosomb first sorry for not being that available lately for wallabag...
I think it's worth doing a rebase just in case, also extract few change to facilitate review, and also I'd like to do few changed so that it can pass in a minor version without BC breaks.
What do you think?

@nicosomb
Copy link
Member

nicosomb commented Dec 7, 2023

So, you suggest to release a 2.6.x ?

@yguedidi
Copy link
Contributor Author

yguedidi commented Dec 7, 2023

@nicosomb had a bit of time during lunch break so I checked again the diff, and maybe the move to env variables may be an issue for users upgrading wallabag, as they'll need to define those env variables in prod.
is this a considered a BC break, and so the must be release in 3.x, or not a BC break but a matter of documenting the upgrade?
if I remember correctly the BC policy is only about the API, is this still true?

@yguedidi
Copy link
Contributor Author

yguedidi commented Dec 7, 2023

@j0k3r @Kdecherf any opinion on is the switch to env vars an issue for a minor/patch release?

@yguedidi yguedidi marked this pull request as draft December 10, 2023 13:12
@yguedidi yguedidi mentioned this pull request Dec 12, 2023
7 tasks
@yguedidi yguedidi modified the milestones: 2.7.0, 2.8.0 Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants