From 4a71134688ac66c8c521ee46251a2966ce4582e2 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Wed, 27 Sep 2023 02:14:13 -0400 Subject: [PATCH] Updating to much more recent pixelfed! --- contrib/docker-default.conf.template | 39 +++++++++++++ contrib/docker-nginx.conf | 51 ++++++++--------- contrib/docker/Dockerfile.fpm | 83 +++++++++++++--------------- contrib/docker/start.fpm.sh | 4 +- contrib/docker/start.nginx.sh | 3 - docker-compose.yml | 14 ++--- 6 files changed, 109 insertions(+), 85 deletions(-) create mode 100644 contrib/docker-default.conf.template diff --git a/contrib/docker-default.conf.template b/contrib/docker-default.conf.template new file mode 100644 index 0000000..dc91767 --- /dev/null +++ b/contrib/docker-default.conf.template @@ -0,0 +1,39 @@ +upstream fpm { + server pixelfed-app:9000; +} + +server { + listen ${NGINX_PORT}; + server_name pix.solarpunk.moe; # change this to your fqdn + root /var/www/public; # path to repo/public + + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Content-Type-Options "nosniff"; + + index index.html index.htm index.php; + + charset utf-8; + client_max_body_size 125M; # or your desired limit + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + error_page 404 /index.php; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass fpm; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # or $request_filename + } + + location ~ /\.(?!well-known).* { + deny all; + } +} diff --git a/contrib/docker-nginx.conf b/contrib/docker-nginx.conf index dc91767..cdd31ac 100644 --- a/contrib/docker-nginx.conf +++ b/contrib/docker-nginx.conf @@ -1,39 +1,32 @@ -upstream fpm { - server pixelfed-app:9000; + +user www-data; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; } -server { - listen ${NGINX_PORT}; - server_name pix.solarpunk.moe; # change this to your fqdn - root /var/www/public; # path to repo/public - add_header X-Frame-Options "SAMEORIGIN"; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Content-Type-Options "nosniff"; +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; - index index.html index.htm index.php; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; - charset utf-8; - client_max_body_size 125M; # or your desired limit + access_log /var/log/nginx/access.log main; - location / { - try_files $uri $uri/ /index.php?$query_string; - } + sendfile on; + #tcp_nopush on; - location = /favicon.ico { access_log off; log_not_found off; } - location = /robots.txt { access_log off; log_not_found off; } + keepalive_timeout 65; - error_page 404 /index.php; + #gzip on; - location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass fpm; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # or $request_filename - } - - location ~ /\.(?!well-known).* { - deny all; - } + include /etc/nginx/conf.d/*.conf; } diff --git a/contrib/docker/Dockerfile.fpm b/contrib/docker/Dockerfile.fpm index a685be2..bfbea86 100644 --- a/contrib/docker/Dockerfile.fpm +++ b/contrib/docker/Dockerfile.fpm @@ -1,29 +1,28 @@ -FROM php:7.4-fpm-buster +FROM php:8.1-fpm-bullseye # Use the default production configuration COPY contrib/docker/php.production.ini "$PHP_INI_DIR/php.ini" # Install Composer -ENV COMPOSER_VERSION 2.4.2 -ENV COMPOSER_HOME /var/www/.composer -RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \ - && curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \ - && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" \ - && php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --version=${COMPOSER_VERSION} && rm -rf /tmp/composer-setup.php +ENV COMPOSER_MEMORY_LIMIT=-1 +ARG DEBIAN_FRONTEND=noninteractive +WORKDIR /var/www/ + +COPY --from=composer:2.4.4 /usr/bin/composer /usr/bin/composer # Update OS Packages -RUN apt-get update +RUN apt-get update && apt-get upgrade -y # Install OS Packages -RUN apt-get install -y --no-install-recommends apt-utils RUN apt-get install -y --no-install-recommends \ ## Standard - locales locales-all \ + locales \ + locales-all \ git \ gosu \ zip \ - unzip \ - libzip-dev \ + unzip \ + libzip-dev \ libcurl4-openssl-dev \ ## Image Optimization optipng \ @@ -33,60 +32,56 @@ RUN apt-get install -y --no-install-recommends \ ## Image Processing libjpeg62-turbo-dev \ libpng-dev \ + libmagickwand-dev \ # Required for GD libxpm4 \ libxpm-dev \ libwebp6 \ libwebp-dev \ ## Video Processing - ffmpeg - -# Update Local data -RUN sed -i '/en_US/s/^#//g' /etc/locale.gen && locale-gen && update-locale - + ffmpeg \ +## Database +# libpq-dev \ +# libsqlite3-dev \ + mariadb-client \ +# Locales Update + && sed -i '/en_US/s/^#//g' /etc/locale.gen \ + && locale-gen \ + && update-locale \ # Install PHP extensions -RUN docker-php-source extract - + && docker-php-source extract #PHP Imagemagick extensions -RUN apt-get install -y --no-install-recommends libmagickwand-dev RUN pecl install imagick -RUN docker-php-ext-enable imagick - -# PHP GD extensions -RUN docker-php-ext-configure gd \ +RUN docker-php-ext-enable imagick \ + && docker-php-ext-configure gd \ --with-freetype \ --with-jpeg \ --with-webp \ - --with-xpm -RUN docker-php-ext-install -j$(nproc) gd - + --with-xpm \ + && docker-php-ext-install -j$(nproc) gd #PHP Redis extensions RUN pecl install redis RUN docker-php-ext-enable redis - -#PHP Database extensions -RUN apt-get install -y --no-install-recommends libpq-dev libsqlite3-dev -RUN docker-php-ext-install pdo_mysql pdo_pgsql pdo_sqlite - -#PHP extensions (dependencies) -RUN docker-php-ext-configure intl -RUN docker-php-ext-install -j$(nproc) intl bcmath zip pcntl exif curl - +RUN docker-php-ext-install pdo_mysql \ + && docker-php-ext-configure intl \ + && docker-php-ext-install -j$(nproc) intl bcmath zip pcntl exif curl #Cleanup -RUN docker-php-source delete -RUN apt-get autoremove --purge -y -RUN rm -rf /var/cache/apt -RUN rm -rf /var/lib/apt/lists/* -ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}" +RUN docker-php-source delete +RUN apt-get autoremove --purge -y \ + && apt-get clean \ + && rm -rf /var/cache/apt \ + && rm -rf /var/lib/apt/lists/ COPY . /var/www/ -WORKDIR /var/www/ RUN cp -r storage storage.skel RUN composer install --prefer-dist --no-interaction --no-ansi --optimize-autoloader -RUN rm -rf html && ln -s public html +RUN rm -rf html && ln -s public html \ + && chown -R www-data:www-data /var/www + +RUN php artisan horizon:publish VOLUME /var/www/storage /var/www/bootstrap - + CMD ["/var/www/contrib/docker/start.fpm.sh"] diff --git a/contrib/docker/start.fpm.sh b/contrib/docker/start.fpm.sh index 6488244..199489f 100755 --- a/contrib/docker/start.fpm.sh +++ b/contrib/docker/start.fpm.sh @@ -2,14 +2,14 @@ # Create the storage tree if needed and fix permissions cp -r storage.skel/* storage/ -chown -R www-data:www-data storage/ bootstrap/ public/ +chown -R www-data:www-data storage/ bootstrap/ # Refresh the environment +php artisan config:cache php artisan storage:link php artisan horizon:publish php artisan route:cache php artisan view:cache -php artisan config:cache # Finally run FPM php-fpm diff --git a/contrib/docker/start.nginx.sh b/contrib/docker/start.nginx.sh index 32bb5b9..53742e3 100755 --- a/contrib/docker/start.nginx.sh +++ b/contrib/docker/start.nginx.sh @@ -3,7 +3,4 @@ rm -rf /var/www/public/storage ln -s /var/www/storage/app/public /var/www/public/storage -# nginx user inside container -chown -R 101:101 /var/www/public/ - ./docker-entrypoint.sh nginx -g "daemon off;" diff --git a/docker-compose.yml b/docker-compose.yml index 2a0c258..e6da854 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,11 +13,10 @@ version: '3' services: ## App and Worker pixelfed-app: - # Comment to use dockerhub image + image: git.solarpunk.moe/solarpunk/pixelfed:latest build: context: . dockerfile: contrib/docker/Dockerfile.fpm - # image: git.solarpunk.moe/pixelfed restart: unless-stopped env_file: - .env.docker @@ -30,14 +29,14 @@ services: mail: depends_on: - - db + - pixelfed-db - redis worker: + image: git.solarpunk.moe/solarpunk/pixelfed:latest build: context: . dockerfile: contrib/docker/Dockerfile.fpm - #image: git.solarpunk.moe/pixelfed restart: unless-stopped env_file: - .env.docker @@ -49,11 +48,11 @@ services: mail: command: gosu www-data php artisan horizon depends_on: - - db + - pixelfed-db - redis ## DB and Cache - db: + pixelfed-db: image: mysql:8.0 restart: unless-stopped networks: @@ -82,7 +81,8 @@ services: httpsproxy: external: volumes: - - ./contrib/docker-nginx.conf:/etc/nginx/templates/default.conf.template + - ./contrib/docker-nginx.conf:/etc/nginx/nginx.conf + - ./contrib/docker-default.conf.template:/etc/nginx/templates/default.conf.template - ./contrib/docker/start.nginx.sh:/var/www/start.nginx.sh - ./public:/var/www/public - app-storage:/var/www/storage