@ -0,0 +1,4 @@ |
|||
**/.git |
|||
**/.gitignore |
|||
/local-www |
|||
**/.gitkeep |
@ -0,0 +1,29 @@ |
|||
FROM php:8.1.8-fpm |
|||
|
|||
COPY . /code |
|||
|
|||
RUN docker-php-ext-install pdo pdo_mysql |
|||
RUN apt-get update -y && apt-get install -y libpng-dev libjpeg-dev libonig-dev |
|||
RUN docker-php-ext-install mbstring |
|||
RUN apt-get update -y && apt-get install -y libmcrypt-dev |
|||
# RUN docker-php-ext-install -j$(nproc) mcrypt |
|||
RUN docker-php-ext-install iconv |
|||
RUN apt-get update -y && apt-get install -y imagemagick |
|||
RUN apt-get update -y && apt-get install -y graphicsmagick |
|||
RUN apt-get update -y && apt-get install -y gifsicle |
|||
# RUN docker-php-ext-configure gd |
|||
# --with-jpeg=/usr/include |
|||
# --with-png-dir=/usr \ |
|||
RUN docker-php-ext-install gd |
|||
RUN apt-get update -y \ |
|||
&& apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev git \ |
|||
&& pecl install memcached \ |
|||
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini \ |
|||
&& apt-get remove -y build-essential libmemcached-dev libz-dev \ |
|||
&& apt-get autoremove -y \ |
|||
&& apt-get clean \ |
|||
&& rm -rf /tmp/pear \ |
|||
&& curl -sS https://getcomposer.org/installer -o composer-setup.php \ |
|||
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ |
|||
&& docker-php-ext-install bcmath \ |
|||
&& cd /code && composer install |
@ -1,16 +1,8 @@ |
|||
<?php |
|||
function getBannerSrc(){ |
|||
$files = scandir(__dir__.'/banners/'); |
|||
$files = array_diff($files, array('.', '..')); |
|||
return $files[array_rand($files)]; |
|||
} |
|||
|
|||
$filename = getBannerSrc(); |
|||
$filename = "banners/" . $filename; |
|||
$fp = fopen($filename, 'rb'); |
|||
$files = scandir(__dir__ . '/static/banners/', SCANDIR_SORT_NONE); |
|||
$files = array_diff($files, ['.', '..']); |
|||
|
|||
header("Content-Type: image/png"); |
|||
header("Content-Length: " . filesize($filename)); |
|||
|
|||
fpassthru($fp); |
|||
?> |
|||
$filename = $files[array_rand($files)]; |
|||
header("Location: /static/banners/$filename", true, 307); |
|||
header('Cache-Control: no-cache'); |
|||
|
@ -1,27 +0,0 @@ |
|||
#!/bin/sh |
|||
|
|||
set -eu |
|||
|
|||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol |
|||
ln -s \ |
|||
/code/banners/ \ |
|||
/code/static/ \ |
|||
/code/stylesheets/ \ |
|||
/code/tools/ \ |
|||
/code/walls/ \ |
|||
/code/*.php \ |
|||
/code/404.html \ |
|||
/code/LICENSE.* \ |
|||
/code/robots.txt \ |
|||
/code/install.sql \ |
|||
/var/www-leftypol/ |
|||
|
|||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/js |
|||
ln -s /code/js/* /var/www-leftypol/js/ |
|||
|
|||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/templates |
|||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/templates/cache |
|||
ln -s /code/templates/* /var/www-leftypol/templates/ |
|||
|
|||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/inc |
|||
ln -s /code/inc/* /var/www-leftypol/inc/ |
@ -0,0 +1,4 @@ |
|||
The `php-fpm` process runs containerized. |
|||
The php application always uses `/var/www` as it's work directory and home folder, and if `/var/www` is bind mounted it |
|||
is necessary to adjust the path passed via FastCGI to `php-fpm` by changing the root directory to `/var/www`. |
|||
This can achieved in nginx by setting the `fastcgi_param SCRIPT_FILENAME` to `/var/www/$fastcgi_script_name;` |
@ -1,11 +1,8 @@ |
|||
FROM nginx:1.25.3-alpine |
|||
|
|||
COPY . /code |
|||
RUN addgroup --system leftypol \ |
|||
&& adduser --system leftypol \ |
|||
&& adduser leftypol leftypol \ |
|||
&& /code/docker/common-setup.sh |
|||
|
|||
RUN adduser --system www-data \ |
|||
&& adduser www-data www-data |
|||
|
|||
CMD [ "nginx", "-g", "daemon off;" ] |
|||
EXPOSE 80 443 |
|||
EXPOSE 80 |
|||
|
@ -1,47 +1,89 @@ |
|||
# Based on https://github.com/dead-guru/devichan/blob/master/php-fpm/Dockerfile |
|||
|
|||
FROM composer AS composer |
|||
FROM php:8.1-fpm-bullseye |
|||
COPY --from=composer /usr/bin/composer /usr/bin/composer |
|||
COPY . /code |
|||
FROM php:7.2-fpm-alpine |
|||
|
|||
RUN apt-get update && apt-get upgrade -y && apt-get install -y \ |
|||
zlib1g-dev libicu-dev g++ \ |
|||
libjpeg62-turbo-dev \ |
|||
libzip-dev \ |
|||
RUN apk add --no-cache \ |
|||
zlib \ |
|||
zlib-dev \ |
|||
libpng \ |
|||
libpng-dev \ |
|||
libjpeg-turbo \ |
|||
libjpeg-turbo-dev \ |
|||
libwebp \ |
|||
libwebp-dev \ |
|||
libfreetype6-dev \ |
|||
libxml2-dev \ |
|||
git \ |
|||
zip \ |
|||
ffmpeg \ |
|||
libonig-dev \ |
|||
unzip \ |
|||
libcurl4-openssl-dev \ |
|||
libmagickwand-dev \ |
|||
gifsicle \ |
|||
libcurl \ |
|||
curl-dev \ |
|||
imagemagick \ |
|||
graphicsmagick \ |
|||
gifsicle \ |
|||
ffmpeg \ |
|||
bind-tools \ |
|||
gettext \ |
|||
imagemagick \ |
|||
locales locales-all \ |
|||
libmagickwand-dev \ |
|||
gettext-dev \ |
|||
icu-dev \ |
|||
oniguruma \ |
|||
oniguruma-dev \ |
|||
libmcrypt \ |
|||
libmcrypt-dev \ |
|||
lz4-libs \ |
|||
lz4-dev \ |
|||
imagemagick-dev \ |
|||
pcre-dev \ |
|||
$PHPIZE_DEPS \ |
|||
&& docker-php-ext-configure gd \ |
|||
--with-webp=/usr/include/webp \ |
|||
--with-jpeg=/usr/include \ |
|||
--with-freetype=/usr/include/freetype2/ \ |
|||
--with-webp-dir=/usr/include/webp \ |
|||
--with-jpeg-dir=/usr/include \ |
|||
&& docker-php-ext-install -j$(nproc) \ |
|||
gd \ |
|||
curl \ |
|||
bcmath \ |
|||
opcache \ |
|||
pdo_mysql \ |
|||
gettext \ |
|||
intl \ |
|||
mbstring \ |
|||
&& pecl update-channels \ |
|||
&& pecl install -o -f igbinary \ |
|||
&& pecl install redis \ |
|||
&& pecl install imagick \ |
|||
&& pecl install -o -f igbinary \ |
|||
&& docker-php-ext-install gd zip opcache intl pdo pdo_mysql mysqli bcmath gettext iconv mbstring curl \ |
|||
&& docker-php-ext-enable igbinary redis imagick \ |
|||
&& useradd -MU leftypol \ |
|||
&& /code/docker/common-setup.sh \ |
|||
&& ln -s /code/composer.json /code/composer.lock /var/www-leftypol/ \ |
|||
&& cd /var/www-leftypol && composer install |
|||
$$ docker-php-ext-enable \ |
|||
igbinary \ |
|||
redis \ |
|||
imagick \ |
|||
&& apk del \ |
|||
zlib-dev \ |
|||
libpng-dev \ |
|||
libjpeg-turbo-dev \ |
|||
libwebp-dev \ |
|||
curl-dev \ |
|||
gettext-dev \ |
|||
oniguruma-dev \ |
|||
libmcrypt-dev \ |
|||
lz4-dev \ |
|||
imagemagick-dev \ |
|||
pcre-dev \ |
|||
$PHPIZE_DEPS \ |
|||
&& rm -rf /var/cache/* |
|||
RUN rmdir /var/www/html \ |
|||
&& install -d -m 744 -o www-data -g www-data /var/www \ |
|||
&& install -d -m 700 -o www-data -g www-data /var/tmp/vichan \ |
|||
&& install -d -m 700 -o www-data -g www-data /var/cache/gen-cache \ |
|||
&& install -d -m 700 -o www-data -g www-data /var/cache/template-cache |
|||
|
|||
COPY --from=composer /usr/bin/composer /usr/local/bin/composer |
|||
|
|||
# Copy the bootstrap script. |
|||
COPY ./docker/php/bootstrap.sh /usr/local/bin/bootstrap.sh |
|||
|
|||
# Copy the actual project (use .dockerignore to exclude stuff). |
|||
COPY . /code |
|||
|
|||
# Make the instance configuration owned by www-data. |
|||
# Make it writable by php. |
|||
# Install the compose depedencies. |
|||
RUN cd /code && composer install |
|||
|
|||
# RUN /code/docker/common-setup.sh php |
|||
WORKDIR "/var/www-leftypol" |
|||
CMD ["php-fpm"] |
|||
WORKDIR "/var/www" |
|||
CMD [ "bootstrap.sh" ] |
|||
EXPOSE 9000 |
@ -0,0 +1,79 @@ |
|||
#!/bin/sh |
|||
|
|||
set -eu |
|||
|
|||
function set_cfg() { |
|||
if [ ! -f "/var/www/inc/$1" ]; then |
|||
echo "INFO: Resetting $1" |
|||
touch "/var/www/inc/$1" |
|||
chown www-data "/var/www/inc/$1" |
|||
chgrp www-data "/var/www/inc/$1" |
|||
chmod 600 "/var/www/inc/$1" |
|||
else |
|||
echo "INFO: Using existing $1" |
|||
fi |
|||
} |
|||
|
|||
if ! mountpoint -q /var/www; then |
|||
echo "WARNING: '/var/www' is not a mountpoint. All the data will remain inside the container!" |
|||
fi |
|||
|
|||
if [ ! -w /var/www ] ; then |
|||
echo "ERROR: '/var/www' is not writable. Closing." |
|||
exit 1 |
|||
fi |
|||
|
|||
# Link the entrypoints from the exposed directory. |
|||
ln -nfs \ |
|||
/code/tools/ \ |
|||
/code/walls/ \ |
|||
/code/*.php \ |
|||
/code/LICENSE.* \ |
|||
/code/404.html \ |
|||
/code/install.sql \ |
|||
/var/www/ |
|||
# Static files accessible from the webserver must be copied. |
|||
cp -ur /code/static /var/www/ |
|||
cp -ur /code/stylesheets /var/www/ |
|||
|
|||
# Ensure correct permissions are set, since this might be bind mount. |
|||
chown www-data /var/www |
|||
chgrp www-data /var/www |
|||
|
|||
# Initialize an empty robots.txt with the default if it doesn't exist. |
|||
touch /var/www/robots.txt |
|||
|
|||
# Link the cache and tmp files directory. |
|||
ln -nfs /var/tmp/vichan /var/www/tmp |
|||
|
|||
# Link the javascript directory. |
|||
ln -nfs /code/js /var/www/ |
|||
|
|||
# Link the html templates directory and it's cache. |
|||
ln -nfs /code/templates /var/www/ |
|||
ln -nfs -T /var/cache/template-cache /var/www/templates/cache |
|||
chown -h www-data /var/www/templates/cache |
|||
chgrp -h www-data /var/www/templates/cache |
|||
|
|||
# Link the generic cache. |
|||
ln -nfs -T /var/cache/gen-cache /var/www/tmp/cache |
|||
chown -h www-data /var/www/tmp/cache |
|||
chgrp -h www-data /var/www/tmp/cache |
|||
|
|||
# Create the included files directory and link them |
|||
install -d -m 700 -o www-data -g www-data /var/www/inc |
|||
for file in /code/inc/*; do |
|||
file="${file##*/}" |
|||
if [ ! -e /var/www/inc/$file ]; then |
|||
ln -s /code/inc/$file /var/www/inc/ |
|||
fi |
|||
done |
|||
|
|||
# Copy an empty instance configuration if the file is a link (it was linked because it did not exist before). |
|||
set_cfg 'instance-config.php' |
|||
|
|||
# Link the composer dependencies. |
|||
ln -nfs /code/vendor /var/www/ |
|||
|
|||
# Start the php-fpm server. |
|||
exec php-fpm |
@ -0,0 +1,54 @@ |
|||
/* |
|||
* hud-pinning.js |
|||
* https://git.leftypol.org/leftypol/leftypol
|
|||
* |
|||
* Released under the MIT license |
|||
* Copyright (c) 2024 Zankaria <zankaria (dot) auxa (at) mailu (dot) io> |
|||
* |
|||
* Usage: |
|||
* $config['additional_javascript'][] = 'js/jquery.min.js'; |
|||
* $config['additional_javascript'][] = 'js/hud-pinning.js'; |
|||
*/ |
|||
|
|||
/** |
|||
* You know the bar on the top of the page that is created if you specify the $config['boards'] array? That one. |
|||
* Also know the bottom bar with the "Return" button and thread update controls? Also that one. |
|||
* |
|||
* Both bars are pinned on the top and bottom of the page. This script adds an option to unpin them. |
|||
*/ |
|||
$(document).ready(function() { |
|||
'use strict'; |
|||
|
|||
if (window.Options && Options.get_tab('general') && window.jQuery) { |
|||
function setHudPinning(pin) { |
|||
let style = pin ? '' : 'initial'; |
|||
$('#top-hud').css('position', style); |
|||
$('#bottom-hud').css('position', style); |
|||
} |
|||
|
|||
// Insert the option in the panel.
|
|||
Options.extend_tab('general', '<label id="hud-pinning"><input type="checkbox">' + _('Unpin the top and bottom bars') + '</label>'); |
|||
|
|||
// Trigger if the panel's checkbox is toggled.
|
|||
$('#hud-pinning>input').on('change', function() { |
|||
if (this.checked) { |
|||
localStorage.hud_pinning = 'false'; |
|||
setHudPinning(false); |
|||
} else { |
|||
localStorage.hud_pinning = 'true'; |
|||
setHudPinning(true); |
|||
} |
|||
}); |
|||
|
|||
// Reload on new post: allows it to work with auto-reload.js etc.
|
|||
$(document).on('new_post', function(e, post) { |
|||
setHudPinning(localStorage.hud_pinning === 'true'); |
|||
}); |
|||
|
|||
// Enforce the setting on loading.
|
|||
if (localStorage.hud_pinning === 'false') { |
|||
$('#hud-pinning>input').attr('checked', 'checked'); |
|||
setHudPinning(false); |
|||
} |
|||
} |
|||
}); |
@ -1,16 +0,0 @@ |
|||
server { |
|||
index index.php index.html; |
|||
error_log /var/log/nginx/error.log; |
|||
access_log /var/log/nginx/access.log; |
|||
root /code; |
|||
|
|||
location ~ \.php$ { |
|||
try_files $uri =404; |
|||
fastcgi_split_path_info ^(.+\.php)(/.+)$; |
|||
fastcgi_pass php:9000; |
|||
fastcgi_index index.php; |
|||
include fastcgi_params; |
|||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
|||
fastcgi_param PATH_INFO $fastcgi_path_info; |
|||
} |
|||
} |
After Width: | Height: | Size: 820 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 380 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |