From 33826f9236fd4519b4a181c16774afa24719e9e9 Mon Sep 17 00:00:00 2001 From: Project StokaTV Date: Thu, 11 Jul 2024 14:33:08 +0000 Subject: [PATCH 1/2] Updated project to work on new storm infrastructure --- backend/Dockerfile | 6 +- compose.yaml | 20 ++++--- configuration.php | 119 +++++++++++++++++++++++++++++++++++++++ filegator-entrypoint.sh | 5 ++ frontend/Dockerfile | 2 +- frontend/nginx.conf | 12 ++-- reverse-proxy/Dockerfile | 2 +- reverse-proxy/nginx.conf | 5 +- 8 files changed, 151 insertions(+), 20 deletions(-) create mode 100644 configuration.php create mode 100755 filegator-entrypoint.sh diff --git a/backend/Dockerfile b/backend/Dockerfile index 9e97416..771ceef 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:17-alpine3.12 +FROM docker.io/node:17-alpine3.12 # Create app directory WORKDIR /usr/src/app @@ -8,8 +8,8 @@ COPY package.json ./ RUN npm install # Add support for debugging -RUN npm install -g nodemon -EXPOSE 9229 +# RUN npm install -g nodemon +# EXPOSE 9229 # Switch user USER node diff --git a/compose.yaml b/compose.yaml index 9904e7b..b80172b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,13 +6,18 @@ volumes: services: admin: hostname: admin - image: filegator/filegator + image: docker.io/filegator/filegator:latest restart: unless-stopped + user: root + environment: + - BASE_URL='/admin' + - APP_PUBLIC_PATH='/admin/' volumes: - media:/var/www/filegator/repository - # Persist configuration (credentials, etc.) - /var/www/filegator/private - + - ./configuration.php:/var/www/filegator/configuration.php + - ./filegator-entrypoint.sh:/var/www/filegator/entrypoint.sh + cmd: /var/www/filegator/entrypoint.sh backend: hostname: backend restart: unless-stopped @@ -23,8 +28,8 @@ services: - media:/srv/media:ro # Mount source code to restart without rebuilding image # (TODO only for development) - - ./backend:/usr/src/app - - /usr/src/app/node_modules + #- ./backend:/usr/src/app + #- /usr/src/app/node_modules build: context: ./backend environment: @@ -37,10 +42,9 @@ services: - backend hostname: frontend restart: unless-stopped - volumes: # Mount source code to restart without rebuilding image # (TODO only for development) - - ./frontend:/usr/src/app + #- ./frontend:/usr/src/app build: context: ./frontend @@ -53,7 +57,7 @@ services: hostname: reverse-proxy restart: unless-stopped ports: - - 8080:80 + - 8005:80 build: context: ./reverse-proxy diff --git a/configuration.php b/configuration.php new file mode 100644 index 0000000..027e525 --- /dev/null +++ b/configuration.php @@ -0,0 +1,119 @@ + '/admin/', + 'public_dir' => APP_PUBLIC_DIR, + 'overwrite_on_upload' => false, + 'timezone' => 'UTC', // https://www.php.net/manual/en/timezones.php + 'download_inline' => ['pdf'], // download inline in the browser, array of extensions, use * for all + 'lockout_attempts' => 5, // max failed login attempts before ip lockout + 'lockout_timeout' => 15, // ip lockout timeout in seconds + + 'frontend_config' => [ + 'app_name' => 'FileGator', + 'app_version' => APP_VERSION, + 'language' => 'english', + 'logo' => 'https://filegator.io/filegator_logo.svg', + 'upload_max_size' => 100 * 1024 * 1024, // 100MB + 'upload_chunk_size' => 1 * 1024 * 1024, // 1MB + 'upload_simultaneous' => 3, + 'default_archive_name' => 'archive.zip', + 'editable' => ['.txt', '.css', '.js', '.ts', '.html', '.php', '.json', '.md'], + 'date_format' => 'YY/MM/DD hh:mm:ss', // see: https://momentjs.com/docs/#/displaying/format/ + 'guest_redirection' => '', // useful for external auth adapters + 'search_simultaneous' => 5, + 'filter_entries' => [], + ], + + 'services' => [ + 'Filegator\Services\Logger\LoggerInterface' => [ + 'handler' => '\Filegator\Services\Logger\Adapters\MonoLogger', + 'config' => [ + 'monolog_handlers' => [ + function () { + return new \Monolog\Handler\StreamHandler( + __DIR__.'/private/logs/app.log', + \Monolog\Logger::DEBUG + ); + }, + ], + ], + ], + 'Filegator\Services\Session\SessionStorageInterface' => [ + 'handler' => '\Filegator\Services\Session\Adapters\SessionStorage', + 'config' => [ + 'handler' => function () { + $save_path = null; // use default system path + //$save_path = __DIR__.'/private/sessions'; + $handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler($save_path); + + return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([ + "cookie_samesite" => "Lax", + "cookie_secure" => null, + "cookie_httponly" => true, + ], $handler); + }, + ], + ], + 'Filegator\Services\Cors\Cors' => [ + 'handler' => '\Filegator\Services\Cors\Cors', + 'config' => [ + 'enabled' => APP_ENV == 'production' ? false : true, + ], + ], + 'Filegator\Services\Tmpfs\TmpfsInterface' => [ + 'handler' => '\Filegator\Services\Tmpfs\Adapters\Tmpfs', + 'config' => [ + 'path' => __DIR__.'/private/tmp/', + 'gc_probability_perc' => 10, + 'gc_older_than' => 60 * 60 * 24 * 2, // 2 days + ], + ], + 'Filegator\Services\Security\Security' => [ + 'handler' => '\Filegator\Services\Security\Security', + 'config' => [ + 'csrf_protection' => true, + 'csrf_key' => "123456", // randomize this + 'ip_allowlist' => [], + 'ip_denylist' => [], + 'allow_insecure_overlays' => false, + ], + ], + 'Filegator\Services\View\ViewInterface' => [ + 'handler' => '\Filegator\Services\View\Adapters\Vuejs', + 'config' => [ + 'add_to_head' => '', + 'add_to_body' => '', + ], + ], + 'Filegator\Services\Storage\Filesystem' => [ + 'handler' => '\Filegator\Services\Storage\Filesystem', + 'config' => [ + 'separator' => '/', + 'config' => [], + 'adapter' => function () { + return new \League\Flysystem\Adapter\Local( + __DIR__.'/repository' + ); + }, + ], + ], + 'Filegator\Services\Archiver\ArchiverInterface' => [ + 'handler' => '\Filegator\Services\Archiver\Adapters\ZipArchiver', + 'config' => [], + ], + 'Filegator\Services\Auth\AuthInterface' => [ + 'handler' => '\Filegator\Services\Auth\Adapters\JsonFile', + 'config' => [ + 'file' => __DIR__.'/private/users.json', + ], + ], + 'Filegator\Services\Router\Router' => [ + 'handler' => '\Filegator\Services\Router\Router', + 'config' => [ + 'query_param' => 'r', + 'routes_file' => __DIR__.'/backend/Controllers/routes.php', + ], + ], + ], +]; diff --git a/filegator-entrypoint.sh b/filegator-entrypoint.sh new file mode 100755 index 0000000..52bd751 --- /dev/null +++ b/filegator-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +chown -R 33:33 /var/www/filegator/repository; +apache2-foreground + diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 0cfd929..865ec1a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:stable-alpine +FROM docker.io/nginx:stable-alpine # Create app directory WORKDIR /usr/src/app diff --git a/frontend/nginx.conf b/frontend/nginx.conf index f1c5294..78dda30 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -9,10 +9,10 @@ server { # Disable all caching # (only for development) - add_header Last-Modified $date_gmt; - add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; - if_modified_since off; - expires off; - etag off; + # add_header Last-Modified $date_gmt; + # add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; + # if_modified_since off; + # expires off; + # etag off; } -} \ No newline at end of file +} diff --git a/reverse-proxy/Dockerfile b/reverse-proxy/Dockerfile index 5b91d3a..b16f6da 100644 --- a/reverse-proxy/Dockerfile +++ b/reverse-proxy/Dockerfile @@ -1,4 +1,4 @@ -FROM nginx:stable-alpine +FROM docker.io/nginx:stable-alpine # Apply custom nginx configuration RUN rm /etc/nginx/conf.d/default.conf diff --git a/reverse-proxy/nginx.conf b/reverse-proxy/nginx.conf index 9062439..ce9b05d 100644 --- a/reverse-proxy/nginx.conf +++ b/reverse-proxy/nginx.conf @@ -23,5 +23,8 @@ server { location /admin { proxy_pass http://admin:8080/; + client_max_body_size 50M; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } -} \ No newline at end of file +} + From ddfcbb9ca241a107ad63591076b74261a405de3c Mon Sep 17 00:00:00 2001 From: Tadikas <52595515+TadMaj@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:41:14 +0200 Subject: [PATCH 2/2] Update compose.yaml Co-authored-by: Wilkin van Roosmalen --- compose.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/compose.yaml b/compose.yaml index b80172b..30048ab 100644 --- a/compose.yaml +++ b/compose.yaml @@ -9,9 +9,6 @@ services: image: docker.io/filegator/filegator:latest restart: unless-stopped user: root - environment: - - BASE_URL='/admin' - - APP_PUBLIC_PATH='/admin/' volumes: - media:/var/www/filegator/repository - /var/www/filegator/private