diff options
-rw-r--r-- | .devcontainer/Dockerfile | 3 | ||||
-rw-r--r-- | .devcontainer/README.md | 22 | ||||
-rw-r--r-- | .devcontainer/devcontainer.json | 9 | ||||
-rwxr-xr-x | .devcontainer/postCreateCommand.sh | 7 | ||||
-rw-r--r-- | Docker/Dockerfile | 1 | ||||
-rw-r--r-- | Docker/Dockerfile-Alpine | 1 | ||||
-rw-r--r-- | Docker/Dockerfile-Newest | 1 | ||||
-rw-r--r-- | Docker/Dockerfile-Oldest | 1 | ||||
-rw-r--r-- | Docker/Dockerfile-QEMU-ARM | 1 | ||||
-rw-r--r-- | Docker/README.md | 1 | ||||
-rw-r--r-- | README.fr.md | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | constants.php | 7 | ||||
-rw-r--r-- | lib/lib_install.php | 14 | ||||
-rw-r--r-- | lib/lib_rss.php | 20 |
15 files changed, 60 insertions, 32 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a2c1a2a2b..73073dcf1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.17 +FROM alpine:3.18 ENV TZ UTC SHELL ["/bin/ash", "-eo", "pipefail", "-c"] @@ -26,6 +26,7 @@ RUN adduser --ingroup www-data --disabled-password developer && \ ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' +ENV DATA_PATH '' ENV FRESHRSS_ENV 'development' ENV LISTEN '0.0.0.0:8080' diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 000000000..22380bc8a --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,22 @@ +# Dev Container for FreshRSS + +This is a [Development Container](https://containers.dev) to provide a one-click full development environment +with all the needed tools and configurations, to develop and test [FreshRSS](https://github.com/FreshRSS/FreshRSS/). + +It can be used on your local machine (see for instance the [Dev Containers extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)), +or as [GitHub Codespaces](https://github.com/features/codespaces) simply in a Web browser: + +[](https://github.com/codespaces/new?hide_repo_select=true&ref=edge&repo=6322699) + +## Test instance of FreshRSS + +A test instance of FreshRSS is automatically started as visible from the *Ports* tab: check the *Local Address* column, and click on the *Open in browser* 🌐 icon. +It runs the FreshRSS code that you are currently editing. + +## Software tests + +Running the tests can be done directly from the built-in terminal, e.g.: + +```sh +make test-all +``` diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a30fdf5c7..615d81741 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,15 @@ "build": { "dockerfile": "Dockerfile" }, + "containerEnv": { + "DATA_PATH": "/home/developer/freshrss-data" + }, "customizations": { + "codespaces": { + "openFiles": [ + ".devcontainer/README.md" + ] + }, "vscode": { "extensions": [ "bmewburn.vscode-intelephense-client", @@ -13,6 +21,7 @@ "eamodio.gitlens", "EditorConfig.EditorConfig", "foxundermoon.shell-format", + "GitHub.vscode-pull-request-github", "mrmlnc.vscode-apache", "ms-azuretools.vscode-docker", "redhat.vscode-yaml", diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index f5398efb9..930ede974 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -4,14 +4,9 @@ ln -s "$(pwd)" /var/www/FreshRSS cp ./Docker/*.Apache.conf /etc/apache2/conf.d/ -cat <<EOT >./constants.local.php -<?php -define('DATA_PATH', '/home/developer/freshrss-data'); -EOT - ./Docker/entrypoint.sh chown -R developer:www-data /home/developer/freshrss-data -chmod -R g+w /home/developer/freshrss-data +chmod -R g+rwX /home/developer/freshrss-data httpd diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 08e6dce43..211df9aaa 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -52,6 +52,7 @@ RUN sed -r -i "/^\s*(CustomLog|ErrorLog|Listen) /s/^/#/" /etc/apache2/apache2.co ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' +ENV DATA_PATH '' ENV FRESHRSS_ENV '' ENV LISTEN '' diff --git a/Docker/Dockerfile-Alpine b/Docker/Dockerfile-Alpine index 68e25faa8..6aa1d7359 100644 --- a/Docker/Dockerfile-Alpine +++ b/Docker/Dockerfile-Alpine @@ -50,6 +50,7 @@ RUN rm -f /etc/apache2/conf.d/languages.conf /etc/apache2/conf.d/info.conf \ ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' +ENV DATA_PATH '' ENV FRESHRSS_ENV '' ENV LISTEN '' diff --git a/Docker/Dockerfile-Newest b/Docker/Dockerfile-Newest index 37783494b..bee845771 100644 --- a/Docker/Dockerfile-Newest +++ b/Docker/Dockerfile-Newest @@ -52,6 +52,7 @@ RUN rm -f /etc/apache2/conf.d/languages.conf /etc/apache2/conf.d/info.conf \ ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' +ENV DATA_PATH '' ENV FRESHRSS_ENV '' ENV LISTEN '' diff --git a/Docker/Dockerfile-Oldest b/Docker/Dockerfile-Oldest index ede1ba643..11dd34a65 100644 --- a/Docker/Dockerfile-Oldest +++ b/Docker/Dockerfile-Oldest @@ -52,6 +52,7 @@ RUN rm -f /etc/apache2/conf.d/languages.conf /etc/apache2/conf.d/info.conf \ ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' +ENV DATA_PATH '' ENV FRESHRSS_ENV '' ENV LISTEN '' diff --git a/Docker/Dockerfile-QEMU-ARM b/Docker/Dockerfile-QEMU-ARM index 892cbc955..b878399ac 100644 --- a/Docker/Dockerfile-QEMU-ARM +++ b/Docker/Dockerfile-QEMU-ARM @@ -64,6 +64,7 @@ RUN rm /usr/bin/qemu-* /var/www/FreshRSS/Docker/qemu-* ENV COPY_LOG_TO_SYSLOG On ENV COPY_SYSLOG_TO_STDERR On ENV CRON_MIN '' +ENV DATA_PATH '' ENV FRESHRSS_ENV '' ENV LISTEN '' diff --git a/Docker/README.md b/Docker/README.md index 42085f38a..0e8b16c55 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -83,6 +83,7 @@ and with newer packages in general (Apache, PHP). * `TZ`: (default is `UTC`) A [server timezone](http://php.net/timezones) * `CRON_MIN`: (default is disabled) Define minutes for the built-in cron job to automatically refresh feeds (see below for more advanced options) +* `DATA_PATH`: (default is empty, defined by `./constants.local.php` or `./constants.php`) Defines the path for writeable data. * `FRESHRSS_ENV`: (default is `production`) Enables additional development information if set to `development` (increases the level of logging and ensures that errors are displayed) (see below for more development options) * `COPY_LOG_TO_SYSLOG`: (default is `On`) Copy all the logs to syslog * `COPY_SYSLOG_TO_STDERR`: (default is `On`) Copy syslog to Standard Error so that it is visible in docker logs diff --git a/README.fr.md b/README.fr.md index 56d70636d..68a6a1d31 100644 --- a/README.fr.md +++ b/README.fr.md @@ -30,7 +30,7 @@ Enfin, il permet l’ajout d’[extensions](#extensions) pour encore plus de per Les demandes de fonctionnalités, rapports de bugs, et autres contributions sont les bienvenues. Privilégiez pour cela des [demandes sur GitHub](https://github.com/FreshRSS/FreshRSS/issues). Nous sommes une communauté amicale. -Pour faciliter les contributions, l’option suivante est disponible : +Pour faciliter les contributions, [l’option suivante](.devcontainer/README.md) est disponible : [](https://github.com/codespaces/new?hide_repo_select=true&ref=edge&repo=6322699) @@ -30,7 +30,7 @@ Finally, it supports [extensions](#extensions) for further tuning. Feature requests, bug reports, and other contributions are welcome. The best way is to [open an issue on GitHub](https://github.com/FreshRSS/FreshRSS/issues). We are a friendly community. -To facilitate contributions, the following option is available: +To facilitate contributions, the [following option](.devcontainer/README.md) is available: [](https://github.com/codespaces/new?hide_repo_select=true&ref=edge&repo=6322699) diff --git a/constants.php b/constants.php index d2b76fb64..f2adc78db 100644 --- a/constants.php +++ b/constants.php @@ -40,7 +40,12 @@ defined('COPY_SYSLOG_TO_STDERR') or define('COPY_SYSLOG_TO_STDERR', filter_var(g defined('MAX_LOG_SIZE') or define('MAX_LOG_SIZE', 1048576); //This directory must be writable -defined('DATA_PATH') or define('DATA_PATH', FRESHRSS_PATH . '/data'); +$dataPath = getenv('DATA_PATH'); +if (is_string($dataPath) && $dataPath !== '') { + define('DATA_PATH', $dataPath); +} else { + defined('DATA_PATH') or define('DATA_PATH', FRESHRSS_PATH . '/data'); +} defined('UPDATE_FILENAME') or define('UPDATE_FILENAME', DATA_PATH . '/update.php'); defined('USERS_PATH') or define('USERS_PATH', DATA_PATH . '/users'); diff --git a/lib/lib_install.php b/lib/lib_install.php index 780115b63..80af02d4f 100644 --- a/lib/lib_install.php +++ b/lib/lib_install.php @@ -40,15 +40,11 @@ function checkRequirements(string $dbType = ''): array { $xml = function_exists('xml_parser_create'); $json = function_exists('json_encode'); $mbstring = extension_loaded('mbstring'); - // @phpstan-ignore-next-line - $data = DATA_PATH != '' && touch(DATA_PATH . '/index.html'); // is_writable() is not reliable for a folder on NFS - // @phpstan-ignore-next-line - $cache = CACHE_PATH != '' && touch(CACHE_PATH . '/index.html'); - $tmp = TMP_PATH != '' && is_writable(TMP_PATH); - // @phpstan-ignore-next-line - $users = USERS_PATH != '' && touch(USERS_PATH . '/index.html'); - // @phpstan-ignore-next-line - $favicons = DATA_PATH != '' && touch(DATA_PATH . '/favicons/index.html'); + $data = is_dir(DATA_PATH) && touch(DATA_PATH . '/index.html'); // is_writable() is not reliable for a folder on NFS + $cache = is_dir(CACHE_PATH) && touch(CACHE_PATH . '/index.html'); + $tmp = is_dir(TMP_PATH) && is_writable(TMP_PATH); + $users = is_dir(USERS_PATH) && touch(USERS_PATH . '/index.html'); + $favicons = is_dir(DATA_PATH) && touch(DATA_PATH . '/favicons/index.html'); return array( 'php' => $php ? 'ok' : 'ko', diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 1ae99e6a1..01ec7fa98 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -724,26 +724,20 @@ function check_install_php(): array { ); } - /** * Check different data files and directories exist. - * * @return array<string,bool> of tested values. */ function check_install_files(): array { - return array( - // @phpstan-ignore-next-line - 'data' => DATA_PATH && touch(DATA_PATH . '/index.html'), // is_writable() is not reliable for a folder on NFS - // @phpstan-ignore-next-line - 'cache' => CACHE_PATH && touch(CACHE_PATH . '/index.html'), - // @phpstan-ignore-next-line - 'users' => USERS_PATH && touch(USERS_PATH . '/index.html'), - 'favicons' => touch(DATA_PATH . '/favicons/index.html'), - 'tokens' => touch(DATA_PATH . '/tokens/index.html'), - ); + return [ + 'data' => is_dir(DATA_PATH) && touch(DATA_PATH . '/index.html'), // is_writable() is not reliable for a folder on NFS + 'cache' => is_dir(CACHE_PATH) && touch(CACHE_PATH . '/index.html'), + 'users' => is_dir(USERS_PATH) && touch(USERS_PATH . '/index.html'), + 'favicons' => is_dir(DATA_PATH) && touch(DATA_PATH . '/favicons/index.html'), + 'tokens' => is_dir(DATA_PATH) && touch(DATA_PATH . '/tokens/index.html'), + ]; } - /** * Check database is well-installed. * |