redaction (#1)

Add the redacted source file for demo purposes

Reviewed-on: #1
Co-authored-by: Michael DiLeo <[email protected]>
Co-committed-by: Michael DiLeo <[email protected]>
This commit was merged in pull request #1.
This commit is contained in:
michael_dileo authored and michael_dileo committed 2025-12-24 13:40:47 +00:00
1 parent 612235d52b
commit 7327d77dcd
333 files changed
+39286 -1

No files matched your search

+208
View File
@@ -0,0 +1,208 @@
# Multi-stage build for Pixelfed - optimized base image
FROM php:8.3-fpm-alpine AS builder
# Set environment variables
ENV PIXELFED_VERSION=v0.12.6
ENV TZ=UTC
ENV APP_ENV=production
ENV APP_DEBUG=false
# Use HTTP repositories and install build dependencies
RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.22/main" > /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/v3.22/community" >> /etc/apk/repositories \
&& apk update \
&& apk add --no-cache \
ca-certificates \
git \
curl \
zip \
unzip \
# Build dependencies for PHP extensions
libpng-dev \
oniguruma-dev \
libxml2-dev \
freetype-dev \
libjpeg-turbo-dev \
libzip-dev \
postgresql-dev \
icu-dev \
gettext-dev \
imagemagick-dev \
# Node.js and build tools for asset compilation
nodejs \
npm \
# Compilation tools for native modules
build-base \
python3 \
make \
# Additional build tools for PECL extensions
autoconf \
pkgconfig \
$PHPIZE_DEPS
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
pdo_pgsql \
pgsql \
gd \
zip \
intl \
bcmath \
exif \
pcntl \
opcache \
# Install ImageMagick PHP extension via PECL
&& pecl install imagick \
&& docker-php-ext-enable imagick
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/pixelfed
# Create pixelfed user
RUN addgroup -g 1000 pixelfed \
&& adduser -u 1000 -G pixelfed -s /bin/sh -D pixelfed
# Clone Pixelfed source
RUN git clone --depth 1 --branch ${PIXELFED_VERSION} https://github.com/pixelfed/pixelfed.git . \
&& chown -R pixelfed:pixelfed /var/www/pixelfed
# Switch to pixelfed user for dependency installation
USER pixelfed
# Install PHP dependencies and clear any cached Laravel configuration
RUN composer install --no-dev --optimize-autoloader --no-interaction \
&& php artisan config:clear || true \
&& php artisan route:clear || true \
&& php artisan view:clear || true \
&& php artisan cache:clear || true \
&& rm -f bootstrap/cache/packages.php bootstrap/cache/services.php || true \
&& php artisan package:discover --ansi || true
# Install Node.js and build assets (skip post-install scripts to avoid node-datachannel compilation)
USER root
RUN apk add --no-cache nodejs npm
USER pixelfed
RUN echo "ignore-scripts=true" > .npmrc \
&& npm ci \
&& npm run production \
&& rm -rf node_modules .npmrc
# Switch back to root for final setup
USER root
# ================================
# Runtime stage - optimized final image
# ================================
FROM php:8.3-fpm-alpine AS pixelfed-base
# Set environment variables
ENV TZ=UTC
ENV APP_ENV=production
ENV APP_DEBUG=false
# Install only runtime dependencies (no -dev packages, no build tools)
RUN echo "http://dl-cdn.alpinelinux.org/alpine/v3.22/main" > /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/v3.22/community" >> /etc/apk/repositories \
&& apk update \
&& apk add --no-cache \
ca-certificates \
curl \
su-exec \
dcron \
# Runtime libraries for PHP extensions (no -dev versions)
libpng \
oniguruma \
libxml2 \
freetype \
libjpeg-turbo \
libzip \
libpq \
icu \
gettext \
# Image optimization tools (runtime only)
jpegoptim \
optipng \
pngquant \
gifsicle \
imagemagick \
ffmpeg \
&& rm -rf /var/cache/apk/*
# Re-install PHP extensions in runtime stage (this ensures compatibility)
RUN apk add --no-cache --virtual .build-deps \
libpng-dev \
oniguruma-dev \
libxml2-dev \
freetype-dev \
libjpeg-turbo-dev \
libzip-dev \
postgresql-dev \
icu-dev \
gettext-dev \
imagemagick-dev \
# Additional build tools for PECL extensions
autoconf \
pkgconfig \
git \
$PHPIZE_DEPS \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
pdo_pgsql \
pgsql \
gd \
zip \
intl \
bcmath \
exif \
pcntl \
opcache \
# Install ImageMagick PHP extension from source (PHP 8.3 compatibility)
&& git clone https://github.com/Imagick/imagick.git --depth 1 /tmp/imagick \
&& cd /tmp/imagick \
&& git fetch origin master \
&& git switch master \
&& phpize \
&& ./configure \
&& make \
&& make install \
&& docker-php-ext-enable imagick \
&& rm -rf /tmp/imagick \
&& apk del .build-deps \
&& rm -rf /var/cache/apk/*
# Create pixelfed user
RUN addgroup -g 1000 pixelfed \
&& adduser -u 1000 -G pixelfed -s /bin/sh -D pixelfed
# Set working directory
WORKDIR /var/www/pixelfed
# Copy application from builder (source + compiled assets + vendor dependencies)
COPY --from=builder --chown=pixelfed:pixelfed /var/www/pixelfed /var/www/pixelfed
# Copy custom assets (logo, banners, etc.) to override defaults. Doesn't override the png versions.
COPY --chown=pixelfed:pixelfed custom-assets/img/*.svg /var/www/pixelfed/public/img/
# Clear any cached configuration files and set proper permissions
RUN rm -rf /var/www/pixelfed/bootstrap/cache/*.php || true \
&& chmod -R 755 /var/www/pixelfed/storage \
&& chmod -R 755 /var/www/pixelfed/bootstrap/cache \
&& chown -R pixelfed:pixelfed /var/www/pixelfed/bootstrap/cache
# Configure PHP for better performance
RUN echo "opcache.enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& echo "opcache.revalidate_freq=0" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& echo "opcache.validate_timestamps=0" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& echo "opcache.max_accelerated_files=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& echo "opcache.memory_consumption=192" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& echo "opcache.max_wasted_percentage=10" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& echo "opcache.interned_strings_buffer=16" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& echo "opcache.fast_shutdown=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
# Copy shared entrypoint utilities
COPY entrypoint-common.sh /usr/local/bin/entrypoint-common.sh
RUN chmod +x /usr/local/bin/entrypoint-common.sh
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 801.9341 804.3024"><defs><clipPath id="clippath"><circle cx="537.39" cy="582.0518" r="20.6082" style="fill:none;"/></clipPath><clipPath id="clippath-1"><circle cx="305.3055" cy="525.2927" r="36.9511" style="fill:none;"/></clipPath></defs><g id="Components"><g id="_313c3f54-f0fe-4200-907c-e1cdd787c827_1"><rect x=".8237" y="4.3024" width="800" height="594.8786" style="fill:#d3edf2;"/><path d="M761.3942,233.0792c-.7254-.0491-1.447.0301-2.168.0548-7.1602-26.4612-31.3262-45.9337-60.0522-45.9337-30.4792,0-55.8223,21.9217-61.1658,50.8544-.3521-.0059-.7007-.0267-1.0544-.0267-34.3633,0-62.2202,27.857-62.2202,62.2203,0,6.6791,1.0642,13.107,3.0122,19.1377-1.8926-.1733-3.8064-.2743-5.7441-.2743-34.3633,0-62.2205,27.8569-62.2205,62.2202s27.8572,62.2203,62.2205,62.2203,62.2202-27.8569,62.2202-62.2203c0-6.6791-1.0642-13.107-3.0125-19.1377,1.8928.1733,3.8066.2743,5.7444.2743,30.4792,0,55.8223-21.9217,61.1658-50.8544.3523.0059.7009.0267,1.0544.0267.7273,0,1.447-.0301,2.1682-.0548,7.1602,26.4612,31.3262,45.9337,60.052,45.9337,34.3633,0,39.4294-25.8788,39.4294-60.2421s0-61.5295-39.4294-64.1983Z" style="fill:#fff8ed;"/><path d="M251.0434,337.1133c-1.938,0-3.8516.101-5.7444.2743,1.948-6.0307,3.0122-12.4586,3.0122-19.1377,0-34.3633-27.8569-62.2202-62.2202-62.2202-.3538,0-.7024.0208-1.0544.0267-5.3438-28.9327-30.6865-50.8545-61.1658-50.8545-28.7261,0-52.8921,19.4724-60.0522,45.9337-.7209-.0247-1.4409-.0548-2.168-.0548-34.3633,0-60.8269,28.9142-60.8269,63.2775s26.4636,61.163,60.8269,61.163c28.7261,0,52.8921-19.4724,60.052-45.9337.7212.0247,1.4409.0548,2.1682.0548.3538,0,.7024-.0208,1.0544-.0267,5.3435,28.9327,30.6865,50.8544,61.1658,50.8544,1.938,0,3.8516-.101,5.7444-.2743-1.948,6.0307-3.0122,12.4586-3.0122,19.1377,0,34.3633,27.8569,62.2203,62.2202,62.2203s62.2202-27.8569,62.2202-62.2203-27.8569-62.2202-62.2202-62.2202Z" style="fill:#fff8ed;"/><path d="M.8237,398.4646v-35.4951c0-20.3141,4.2522-35.352,22.0692-47.6365,36.5575-25.2057,85.5886-23.1045,121.7998,1.2982,15.2997,10.3104,27.3873,24.1182,42.2564,34.8332,23.1072,16.6515,57.3862,23.2823,84.6677,29.8885,49.3902,11.9599,100.3935,15.0923,151.0564,15.4343,25.4858.172,50.9688-.3675,76.4483-.8632,23.0781-.449,47.405,1.6597,70.0495-3.2464,28.4838-6.1712,52.927-20.7079,72.3011-42.2529,17.9433-19.9539,32.9143-43.4416,55.7126-58.4148,26.6497-17.5027,62.336-24.0735,93.4379-15.8179,2.7639.7336,5.6037,1.722,7.5574,3.8126,6.5974,7.0623,2.4863,29.3172,2.5115,38.3011.0235,8.3746.1321,16.752.1321,25.1256,0,67.5882-.0011,135.1763-.0052,202.7645-73.6547-.1306-147.3091-.2306-220.9637-.3291-67.9054-.0908-135.8107-.1816-203.7161-.2723-65.8963-.0881-131.7926-.1762-197.6889-.2643-46.8396-.0626-93.6792-.1252-140.5188-.1878-12.3691-.0165-24.7382-.0338-37.1073-.0496v-146.628Z" style="fill:#94a852;"/><path d="M1.4158,480.4445c.1789-.3931.3782-.7566.5999-1.0867,1.7578-2.6169,4.4333-4.4505,7.0429-6.219,36.095-24.461,90.5808-69.0243,137.0822-49.484,14.2144,5.973,25.8535,15.8889,38.367,24.6213,12.7841,8.9213,26.5005,16.3403,40.7198,22.7025,32.4917,14.5378,67.0916,23.7872,100.115,36.7401,64.3998,25.2598,134.014,15.4068,201.5202,15.4068h40.5204c.0284,0,.0567.0009.0881.0028,46.8121,2.8475,91.5513-18.3735,119.9052-55.7304,13.4974-17.7831,32.8218-34.859,60.1078-43.9834.0262-.0087.0498-.0161.0764-.0236,1.5941-.451,53.263-14.9662,53.263-1.6757,0,15.4285,0,75.2141,0,75.2141v146.5037c0,.7537-.5963,1.3723-1.3495,1.3998L2.2757,674.0175c-.7932.029-1.452-.6061-1.452-1.3998v-166.1445c0-6.5197-2.2006-19.8904.5922-26.0286Z" style="fill:#71903b;"/><path d="M167.8165,605.5262l5.3098-11.1376c.4888-1.0253-.157-2.2587-1.2456-2.361-8.5748-.8056-20.1155,13.4986-20.1155,13.4986,11.1655-20.0744,14.0887-34.7461,14.7588-42.6191.3036-3.5648-2.8776-6.3905-6.1542-5.39-24.4759,7.4743-30.8296,44.1243-30.8296,44.1243-9.8778-3.8849-12.3472,2.5899-12.3472,2.5899,2.4693-12.9494,0-18.7766,0-18.7766-11.2915-.5921-19.4804,24.2507-20.7992,28.5062h-.0819c3.149-17.1284,1.317-32.8635-.2521-41.4199-.5128-2.796-3.9669-3.5625-5.5329-1.2366-11.4919,17.0681-12.8451,32.9269-12.8451,32.9269-3.677-25.0661-22.5231-39.3657-31.9136-45.0369-3.2603-1.969-7.485-.3189-8.5485,3.4659-4.933,17.5556,11.4937,46.732,14.161,51.3006h-.4366l-37.2918-29.054c-1.3463-1.0489-3.2554.2146-2.8771,1.9282,2.5457,11.5297,12.6886,22.0928,16.9007,26.0757-12.1407-9.797-21.6944-5.3115-26.9576-2.8492l.1053,6.5461v187.6947h800v-195.5161c-53.0931-23.3089-633.0072-3.2601-633.0072-3.2601Z" style="fill:#a8a956;"/><rect x=".8236" y=".1183" width="800" height="803.0197" style="fill:none;"/><path d="M462.8663,476.9482h44.3484l.1404,133.0193s-29.7122-.471-35.0188-6.839l-9.47-126.1803Z" style="fill:#664532;"/><path d="M508.5656,611.1946l-1.2297-.0182c-3.097-.049-30.4255-.6703-35.9276-7.2749l-.2489-.2979-9.5981-127.8653h46.8608l.1435,135.4563ZM473.5118,602.6228c4.4067,4.4321,23.9081,5.8708,32.6343,6.1087l-.1399-130.5737h-41.8365l9.342,124.4649Z" style="Line truncated

After

Width:  |  Height:  |  Size: 161 KiB

@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 801.9341 804.3024"><defs><clipPath id="clippath"><circle cx="537.39" cy="582.0518" r="20.6082" style="fill:none;"/></clipPath><clipPath id="clippath-1"><circle cx="305.3055" cy="525.2927" r="36.9511" style="fill:none;"/></clipPath></defs><g id="Components"><g id="_313c3f54-f0fe-4200-907c-e1cdd787c827_6"><rect x=".8237" y="4.3024" width="800" height="594.8786" style="fill:#f1f2f2;"/><path d="M761.3942,233.0792c-.7254-.0491-1.447.0301-2.168.0548-7.1602-26.4612-31.3262-45.9337-60.0522-45.9337-30.4792,0-55.8223,21.9217-61.1658,50.8544-.3521-.0059-.7007-.0267-1.0544-.0267-34.3633,0-62.2202,27.857-62.2202,62.2203,0,6.6791,1.0642,13.107,3.0122,19.1377-1.8926-.1733-3.8064-.2743-5.7441-.2743-34.3633,0-62.2205,27.8569-62.2205,62.2202s27.8572,62.2203,62.2205,62.2203,62.2202-27.8569,62.2202-62.2203c0-6.6791-1.0642-13.107-3.0125-19.1377,1.8928.1733,3.8066.2743,5.7444.2743,30.4792,0,55.8223-21.9217,61.1658-50.8544.3523.0059.7009.0267,1.0544.0267.7273,0,1.447-.0301,2.1682-.0548,7.1602,26.4612,31.3262,45.9337,60.052,45.9337,34.3633,0,39.4294-25.8788,39.4294-60.2421s0-61.5295-39.4294-64.1983Z" style="fill:#f8f8f8;"/><path d="M251.0434,337.1133c-1.938,0-3.8516.101-5.7444.2743,1.948-6.0307,3.0122-12.4586,3.0122-19.1377,0-34.3633-27.8569-62.2202-62.2202-62.2202-.3538,0-.7024.0208-1.0544.0267-5.3438-28.9327-30.6865-50.8545-61.1658-50.8545-28.7261,0-52.8921,19.4724-60.0522,45.9337-.7209-.0247-1.4409-.0548-2.168-.0548-34.3633,0-60.8269,28.9142-60.8269,63.2775s26.4636,61.163,60.8269,61.163c28.7261,0,52.8921-19.4724,60.052-45.9337.7212.0247,1.4409.0548,2.1682.0548.3538,0,.7024-.0208,1.0544-.0267,5.3435,28.9327,30.6865,50.8544,61.1658,50.8544,1.938,0,3.8516-.101,5.7444-.2743-1.948,6.0307-3.0122,12.4586-3.0122,19.1377,0,34.3633,27.8569,62.2203,62.2202,62.2203s62.2202-27.8569,62.2202-62.2203-27.8569-62.2202-62.2202-62.2202Z" style="fill:#f8f8f8;"/><path d="M.8237,398.4646v-35.4951c0-20.3141,4.2522-35.352,22.0692-47.6365,36.5575-25.2057,85.5886-23.1045,121.7998,1.2982,15.2997,10.3104,27.3873,24.1182,42.2564,34.8332,23.1072,16.6515,57.3862,23.2823,84.6677,29.8885,49.3902,11.9599,100.3935,15.0923,151.0564,15.4343,25.4858.172,50.9688-.3675,76.4483-.8632,23.0781-.449,47.405,1.6597,70.0495-3.2464,28.4838-6.1712,52.927-20.7079,72.3011-42.2529,17.9433-19.9539,32.9143-43.4416,55.7126-58.4148,26.6497-17.5027,62.336-24.0735,93.4379-15.8179,2.7639.7336,5.6037,1.722,7.5574,3.8126,6.5974,7.0623,2.4863,29.3172,2.5115,38.3011.0235,8.3746.1321,16.752.1321,25.1256,0,67.5882-.0011,135.1763-.0052,202.7645-73.6547-.1306-147.3091-.2306-220.9637-.3291-67.9054-.0908-135.8107-.1816-203.7161-.2723-65.8963-.0881-131.7926-.1762-197.6889-.2643-46.8396-.0626-93.6792-.1252-140.5188-.1878-12.3691-.0165-24.7382-.0338-37.1073-.0496v-146.628Z" style="fill:#adafb2;"/><path d="M1.4158,480.4445c.1789-.3931.3782-.7566.5999-1.0867,1.7578-2.6169,4.4333-4.4505,7.0429-6.219,36.095-24.461,90.5808-69.0243,137.0822-49.484,14.2144,5.973,25.8535,15.8889,38.367,24.6213,12.7841,8.9213,26.5005,16.3403,40.7198,22.7025,32.4917,14.5378,67.0916,23.7872,100.115,36.7401,64.3998,25.2598,134.014,15.4068,201.5202,15.4068h40.5204c.0284,0,.0567.0009.0881.0028,46.8121,2.8475,91.5513-18.3735,119.9052-55.7304,13.4974-17.7831,32.8218-34.859,60.1078-43.9834.0262-.0087.0498-.0161.0764-.0236,1.5941-.451,53.263-14.9662,53.263-1.6757,0,15.4285,0,75.2141,0,75.2141v146.5037c0,.7537-.5963,1.3723-1.3495,1.3998L2.2757,674.0175c-.7932.029-1.452-.6061-1.452-1.3998v-166.1445c0-6.5197-2.2006-19.8904.5922-26.0286Z" style="fill:#8f9194;"/><path d="M167.8165,605.5262l5.3098-11.1376c.4888-1.0253-.157-2.2587-1.2456-2.361-8.5748-.8056-20.1155,13.4986-20.1155,13.4986,11.1655-20.0744,14.0887-34.7461,14.7588-42.6191.3036-3.5648-2.8776-6.3905-6.1542-5.39-24.4759,7.4743-30.8296,44.1243-30.8296,44.1243-9.8778-3.8849-12.3472,2.5899-12.3472,2.5899,2.4693-12.9494,0-18.7766,0-18.7766-11.2915-.5921-19.4804,24.2507-20.7992,28.5062h-.0819c3.149-17.1284,1.317-32.8635-.2521-41.4199-.5128-2.796-3.9669-3.5625-5.5329-1.2366-11.4919,17.0681-12.8451,32.9269-12.8451,32.9269-3.677-25.0661-22.5231-39.3657-31.9136-45.0369-3.2603-1.969-7.485-.3189-8.5485,3.4659-4.933,17.5556,11.4937,46.732,14.161,51.3006h-.4366l-37.2918-29.054c-1.3463-1.0489-3.2554.2146-2.8771,1.9282,2.5457,11.5297,12.6886,22.0928,16.9007,26.0757-12.1407-9.797-21.6944-5.3115-26.9576-2.8492l.1053,6.5461v187.6947h800v-195.5161c-53.0931-23.3089-633.0072-3.2601-633.0072-3.2601Z" style="fill:#afb1b4;"/><rect x=".8236" y=".1183" width="800" height="803.0197" style="fill:none;"/><path d="M462.8663,476.9482h44.3484l.1404,133.0193s-29.7122-.471-35.0188-6.839l-9.47-126.1803Z"/><path d="M508.5656,611.1946l-1.2297-.0182c-3.097-.049-30.4255-.6703-35.9276-7.2749l-.2489-.2979-9.5981-127.8653h46.8608l.1435,135.4563ZM473.5118,602.6228c4.4067,4.4321,23.9081,5.8708,32.6343,6.1087l-.1399-130.5737h-41.8365l9.342,124.4649Z"/><path d="M543.0514,437.8476sLine truncated

After

Width:  |  Height:  |  Size: 159 KiB

@@ -0,0 +1,116 @@
#!/bin/sh
set -e
# Common functions for Pixelfed containers
# Setup directories and create necessary structure
setup_directories() {
echo "Setting up directories..."
mkdir -p /var/www/pixelfed/storage
mkdir -p /var/www/pixelfed/bootstrap/cache
# CRITICAL FIX: Remove stale package discovery cache files
echo "Removing stale package discovery cache files..."
rm -f /var/www/pixelfed/bootstrap/cache/packages.php || true
rm -f /var/www/pixelfed/bootstrap/cache/services.php || true
}
# Wait for database to be ready
wait_for_database() {
echo "Waiting for database connection..."
cd /var/www/pixelfed
# Try for up to 60 seconds
for i in $(seq 1 12); do
if su-exec pixelfed php artisan migrate:status >/dev/null 2>&1; then
echo "Database is ready!"
return 0
fi
echo "Database not ready yet, waiting... (attempt $i/12)"
sleep 5
done
echo "ERROR: Database connection failed after 60 seconds"
exit 1
}
# Run database migrations (only if needed)
setup_database() {
echo "Checking database migrations..."
cd /var/www/pixelfed
# Only run migrations if they haven't been run
if ! su-exec pixelfed php artisan migrate:status | grep -q "Y"; then
echo "Running database migrations..."
su-exec pixelfed php artisan migrate --force
else
echo "Database migrations are up to date"
fi
}
# Generate application key if not set
setup_app_key() {
if [ -z "$APP_KEY" ] || [ "$APP_KEY" = "base64:" ]; then
echo "Generating application key..."
cd /var/www/pixelfed
su-exec pixelfed php artisan key:generate --force
fi
}
# Cache configuration (safe to run multiple times)
cache_config() {
echo "Clearing and caching configuration..."
cd /var/www/pixelfed
# Clear all caches first to avoid stale service provider registrations
su-exec pixelfed php artisan config:clear || true
su-exec pixelfed php artisan route:clear || true
su-exec pixelfed php artisan view:clear || true
su-exec pixelfed php artisan cache:clear || true
# Remove package discovery cache files and regenerate them
rm -f bootstrap/cache/packages.php bootstrap/cache/services.php || true
su-exec pixelfed php artisan package:discover --ansi || true
# Now rebuild caches with fresh configuration
su-exec pixelfed php artisan config:cache
su-exec pixelfed php artisan route:cache
su-exec pixelfed php artisan view:cache
}
# Link storage if not already linked
setup_storage_link() {
if [ ! -L "/var/www/pixelfed/public/storage" ]; then
echo "Linking storage..."
cd /var/www/pixelfed
su-exec pixelfed php artisan storage:link
fi
}
# Import location data (only on first run)
import_location_data() {
if [ ! -f "/var/www/pixelfed/.location-imported" ]; then
echo "Importing location data..."
cd /var/www/pixelfed
su-exec pixelfed php artisan import:cities || true
touch /var/www/pixelfed/.location-imported
fi
}
# Main initialization function
initialize_pixelfed() {
echo "Initializing Pixelfed..."
setup_directories
# Only the first container should run these
if [ "${PIXELFED_INIT_CONTAINER:-false}" = "true" ]; then
setup_database
setup_app_key
import_location_data
fi
cache_config
setup_storage_link
echo "Pixelfed initialization complete!"
}