FROM dunglas/frankenphp:1-php8.5-alpine
LABEL maintainer="Julien Cabillot <dockerimages@cabillot.eu>"

WORKDIR /app

# Install required PHP extensions for RSS-Bridge
RUN install-php-extensions mbstring simplexml curl json iconv

COPY Caddyfile /etc/frankenphp/Caddyfile

# Download RSS-Bridge (two-step to avoid pipefail dependency)
RUN curl -s -L "https://github.com/RSS-Bridge/rss-bridge/tarball/master/" -o /tmp/rssbridge.tar && \
    tar -zx --strip=1 -C /app/public -f /tmp/rssbridge.tar && \
    rm /tmp/rssbridge.tar

# Configure RSS-Bridge
RUN echo "*" > "/app/public/whitelist.txt" && \
    mkdir -p /app/public/cache && \
    chown -R www-data:www-data /app/public && \
    chmod -R 775 /app/public/cache

USER www-data
