From 7cc3c951a528ce1391949b30f2d2d917b4d04793 Mon Sep 17 00:00:00 2001 From: x Date: Fri, 12 Sep 2025 23:50:21 +0200 Subject: [PATCH] [W0-0] fixing upload problem --- Dockerfile | 24 ++++++++++------ README.md | 22 ++++++++++++++- conf/entrypoint.sh | 2 +- conf/nginx/nginx.conf | 57 ++++++++++++++++++++++++++++++++++++++ conf/nginx/nginx_w0bm.conf | 43 ++++++++++++++++++++++++++++ conf/nginx_w0bm.conf | 33 ---------------------- docker-compose.yaml | 23 +++++++++------ 7 files changed, 153 insertions(+), 51 deletions(-) create mode 100644 conf/nginx/nginx.conf create mode 100644 conf/nginx/nginx_w0bm.conf delete mode 100644 conf/nginx_w0bm.conf diff --git a/Dockerfile b/Dockerfile index 754ceea..e76e5f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,32 @@ # w0bm legacy -FROM debian:bookworm -COPY ./conf/entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +FROM debian:trixie RUN apt update -y -RUN apt install sudo curl -y +RUN apt install sudo curl vim -y RUN curl -sSL https://packages.sury.org/php/README.txt | bash -x RUN apt update -y RUN apt install php7.1 php7.1-cli php7.1-ctype php7.1-curl php7.1-fileinfo php7.1-fpm php7.1-gd php7.1-iconv php7.1-mysql php7.1-opcache php7.1-pdo php7.1-phar php7.1-tokenizer php7.1-zip php7.1-json php7.1-mbstring php7.1-dom nginx ffmpeg imagemagick git -y +# cli RUN sed -i 's/^post_max_size = .*/post_max_size = 500M/' /etc/php/7.1/cli/php.ini RUN sed -i 's/^upload_max_size = .*/upload_max_size = 100M/' /etc/php/7.1/cli/php.ini -COPY ./conf/nginx_w0bm.conf /etc/nginx/conf.d/nginx_w0bm.conf +# fpm +RUN sed -i 's/^post_max_size = .*/post_max_size = 500M/' /etc/php/7.1/fpm/php.ini +RUN sed -i 's/^upload_max_size = .*/upload_max_size = 100M/' /etc/php/7.1/fpm/php.ini +RUN sed -i 's/^user = .*/user = root/' /etc/php/7.1/fpm/pool.d/www.conf +RUN sed -i 's/^group = .*/group = root/' /etc/php/7.1/fpm/pool.d/www.conf +RUN sed -i 's/^listen.owner = .*/user = root/' /etc/php/7.1/fpm/pool.d/www.conf +RUN sed -i 's/^listen.group = .*/group = root/' /etc/php/7.1/fpm/pool.d/www.conf +COPY ./conf/nginx/nginx.conf /etc/nginx/nginx.conf +COPY ./conf/nginx/nginx_w0bm.conf /etc/nginx/conf.d/nginx_w0bm.conf WORKDIR /opt RUN git clone https://git.lat/w0bm/w0bm.git -COPY ./conf/.env /opt/w0bm/ WORKDIR /opt/w0bm +COPY ./conf/.env /opt/w0bm/ RUN chown -R www-data:www-data /opt/w0bm RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" RUN php composer-setup.php --2.2 -USER www-data RUN php7.1 composer.phar dump-autoload RUN php7.1 composer.phar install --no-scripts -USER root +RUN rm -rf public/ +COPY ./conf/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 17792d5..f9d85ca 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,24 @@ First of all put a .webm file named 1.webm in `w0bm-data/b` `php7.1 artisan tags` -Now visit http://localhost:8080 \ No newline at end of file +Now visit http://localhost:8080 + +To get upload working do this + +``` +$ git clone https://git.lat/w0bm/w0bm.git +$ cd w0bm +$ mkdir public/thumbs +$ mkdir public/b +$ mkdir public/thumbs/beta +$ mkdir public/thumbs/blurred +``` + +`docker exec -it w0bm /bin/bash` + +``` +root@703c9472fed5:/opt/w0bm/public# chmod -R 777 thumbs/ +root@703c9472fed5:/opt/w0bm/public# chmod -R 777 b +``` + +inside the container, it applied to the mount \ No newline at end of file diff --git a/conf/entrypoint.sh b/conf/entrypoint.sh index 0274822..a7939ac 100644 --- a/conf/entrypoint.sh +++ b/conf/entrypoint.sh @@ -1,4 +1,4 @@ #!/bin/bash set -e -php-fpm7.1 -F & +php-fpm7.1 -F -R & exec nginx -g "daemon off;" \ No newline at end of file diff --git a/conf/nginx/nginx.conf b/conf/nginx/nginx.conf new file mode 100644 index 0000000..69c8fe2 --- /dev/null +++ b/conf/nginx/nginx.conf @@ -0,0 +1,57 @@ +user root; +worker_processes auto; +worker_cpu_affinity auto; +pid /run/nginx.pid; +error_log /var/log/nginx/error.log; +include /etc/nginx/modules-enabled/*.conf; +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + types_hash_max_size 2048; + server_tokens off; # Recommended practice is to turn this off + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + ## + # SSL Settings + ## + + ssl_protocols TLSv1.2 TLSv1.3; # Dropping SSLv3 (POODLE), TLS 1.0, 1.1 + ssl_prefer_server_ciphers off; # Don't force server cipher order. + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + + ## + # Gzip Settings + ## + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file diff --git a/conf/nginx/nginx_w0bm.conf b/conf/nginx/nginx_w0bm.conf new file mode 100644 index 0000000..8dcc6eb --- /dev/null +++ b/conf/nginx/nginx_w0bm.conf @@ -0,0 +1,43 @@ +#w0bm.com +server { + server_name w0bm.local; + + listen 8090; + #listen [::]:8443 ssl proxy_protocol; + http2 on; + + root /opt/w0bm/public; + + allow all; + index index.php; + try_files $uri $uri/ /index.php?$args; + access_log off; + client_max_body_size 500M; + #add_header 'Access-Control-Allow-Origin' '*'; + + location = /database/cNsH4YbaKtwQWsKQk47LVAEJTyt3yi6Cz2npPF9izxJ8q7GWg.php { + auth_basic "Restricted Area"; + auth_basic_user_file /etc/nginx/.htpasswd; +fastcgi_split_path_info ^(.+\.php)(/.+)$; +include fastcgi_params; +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_pass unix:/run/php/php7.1-fpm.sock; + } + + location /api/video/upload { + client_max_body_size 500M; + fastcgi_param PHP_VALUE "upload_max_filesize=500M \n post_max_size=500M"; +fastcgi_split_path_info ^(.+\.php)(/.+)$; +include fastcgi_params; +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_pass unix:/run/php/php7.1-fpm.sock; + fastcgi_param SCRIPT_FILENAME $document_root/index.php; + } + + location /index.php { +fastcgi_split_path_info ^(.+\.php)(/.+)$; +include fastcgi_params; +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_pass unix:/run/php/php7.1-fpm.sock; + } +} \ No newline at end of file diff --git a/conf/nginx_w0bm.conf b/conf/nginx_w0bm.conf deleted file mode 100644 index 36126da..0000000 --- a/conf/nginx_w0bm.conf +++ /dev/null @@ -1,33 +0,0 @@ -server { - listen 8080 default_server; - server_name _; - access_log /var/log/nginx/w0bm_access.log; - error_log /var/log/nginx/w0bm_error.log; - root /opt/w0bm/public; - index index.php; - client_max_body_size 500M; - gzip on; - large_client_header_buffers 4 32k; - location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_index index.php; - include fastcgi.conf; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name; - #fastcgi_param GEOIP_ADDR $remote_addr; - #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_pass unix:/run/php/php7.1-fpm.sock; - } - location ~* \.(?:css|js)$ { - gzip on; - expires 1y; - add_header Cache-Control "public"; - } - location ~* \.(?:jpg|jpeg|gif|png|ico|svg)$ { - expires 1M; - access_log off; - add_header Cache-Control "public"; - } - location / { - try_files $uri $uri/ /index.php?$args; - } -} \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 259be99..6a75a71 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,21 +1,28 @@ #w0bm legacy deployment services: - w0bm-legacy: - container_name: w0bm-legacy - image: w0bm-legacy:opt-1 #dev + w0bm: + container_name: w0bm + image: w0bm:legacy-0.0.20 #public fix? + # hostname: "w0bm.lokal" build: dockerfile: Dockerfile + environment: + COMPOSER_ALLOW_SUPERUSER: 1 depends_on: - mariadb networks: - w0bm volumes: - - ./w0bm-data/b:/opt/w0bm/public/b - - ./w0bm-data/thumbs:/opt/w0bm/public/thumbs - - ./w0bm-data/thumbs/beta:/opt/w0bm/public/thumbs/beta - - ./w0bm-data/images:/opt/w0bm/public/image + - ./w0bm/public:/opt/w0bm/public + # - ./w0bm-data/logs/:/opt/w0bm/storage/logs/ + # - ./w0bm-data/b/:/opt/w0bm/public/b/ + # - ./w0bm-data/thumbs/:/opt/w0bm/public/thumbs/ + # - ./w0bm-data/thumbs/beta/:/opt/w0bm/public/thumbs/beta/ + # - ./w0bm-data/thumbs/beta/blurred:/opt/w0bm/public/thumbs/beta/blurred/ + # - ./w0bm-data/images/:/opt/w0bm/public/image/ ports: - - "8080:8080" + - "8090:8090" + - "8000:800" restart: on-failure mariadb: image: mariadb:latest