Skip to content

Commit 0175e13

Browse files
authored
Docker from Debian base image (RSS-Bridge#3500)
* Docker from Debian base image * Fix expose RSS-Bridge#3234 * Re-fix better logs RSS-Bridge#3333 * Update to Debian 12 Bookworm instead of Debian 10 Buster * Use Debian packaging instead of having to keep track of and manually install -dev libraries, and with LTS support * Update to PHP 8.2 instead of PHP 8.0 * Fix php.ini location * Minor order changes To optimise caching
1 parent 4323a11 commit 0175e13

File tree

7 files changed

+60
-24
lines changed

7 files changed

+60
-24
lines changed

.devcontainer/nginx.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ server {
1212

1313
location ~ \.php$ {
1414
include snippets/fastcgi-php.conf;
15-
fastcgi_pass 127.0.0.1:9000;
15+
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
1616
}
17-
}
17+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ pip-log.txt
230230
DEBUG
231231
config.ini.php
232232
config/*
233+
!config/nginx.conf
234+
!config/php-fpm.conf
235+
!config/php.ini
233236

234237
######################
235238
## VisualStudioCode ##

Dockerfile

+28-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
11
FROM lwthiker/curl-impersonate:0.5-ff-slim-buster AS curlimpersonate
22

3-
FROM php:8.0.27-fpm-buster AS rssbridge
3+
FROM debian:12-slim AS rssbridge
44

55
LABEL description="RSS-Bridge is a PHP project capable of generating RSS and Atom feeds for websites that don't have one."
66
LABEL repository="https://github.com/RSS-Bridge/rss-bridge"
77
LABEL website="https://github.com/RSS-Bridge/rss-bridge"
88

9+
ARG DEBIAN_FRONTEND=noninteractive
910
RUN apt-get update && \
1011
apt-get install --yes --no-install-recommends \
12+
ca-certificates \
1113
nginx \
12-
zlib1g-dev \
13-
libzip-dev \
14-
libmemcached-dev \
1514
nss-plugin-pem \
16-
libicu-dev && \
17-
docker-php-ext-install zip && \
18-
docker-php-ext-install intl && \
19-
pecl install memcached && \
20-
docker-php-ext-enable memcached && \
21-
docker-php-ext-enable opcache && \
22-
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
23-
24-
COPY ./config/nginx.conf /etc/nginx/sites-enabled/default
25-
26-
COPY --chown=www-data:www-data ./ /app/
15+
php-curl \
16+
php-fpm \
17+
php-intl \
18+
# php-json is enabled by default with PHP 8.2 in Debian 12
19+
php-mbstring \
20+
php-memcached \
21+
# php-opcache is enabled by default with PHP 8.2 in Debian 12
22+
# php-openssl is enabled by default with PHP 8.2 in Debian 12
23+
php-sqlite3 \
24+
php-xml \
25+
php-zip \
26+
# php-zlib is enabled by default with PHP 8.2 in Debian 12
27+
&& \
28+
rm -rf /var/lib/apt/lists/*
29+
30+
# logs should go to stdout / stderr
31+
RUN ln -sfT /dev/stderr /var/log/nginx/error.log; \
32+
ln -sfT /dev/stdout /var/log/nginx/access.log; \
33+
chown -R --no-dereference www-data:adm /var/log/nginx/
2734

2835
COPY --from=curlimpersonate /usr/local/lib/libcurl-impersonate-ff.so /usr/local/lib/curl-impersonate/
29-
3036
ENV LD_PRELOAD /usr/local/lib/curl-impersonate/libcurl-impersonate-ff.so
31-
3237
ENV CURL_IMPERSONATE ff91esr
3338

39+
COPY ./config/nginx.conf /etc/nginx/sites-available/default
40+
COPY ./config/php-fpm.conf /etc/php/8.2/fpm/pool.d/rss-bridge.conf
41+
COPY ./config/php.ini /etc/php/8.2/fpm/conf.d/90-rss-bridge.conf
42+
43+
COPY --chown=www-data:www-data ./ /app/
44+
3445
EXPOSE 80
3546

3647
ENTRYPOINT ["/app/docker-entrypoint.sh"]

config/nginx.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ server {
22
listen 80 default_server;
33
listen [::]:80 default_server;
44
root /app;
5-
access_log /dev/stdout;
6-
error_log /dev/stderr;
5+
access_log /var/log/nginx/access.log;
6+
error_log /var/log/nginx/error.log;
77
index index.php;
88

99
location ~ /(\.|vendor|tests) {
@@ -13,6 +13,6 @@ server {
1313

1414
location ~ \.php$ {
1515
include snippets/fastcgi-php.conf;
16-
fastcgi_pass 127.0.0.1:9000;
16+
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
1717
}
1818
}

config/php-fpm.conf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; Inspired by https://github.com/docker-library/php/blob/master/8.2/bookworm/fpm/Dockerfile
2+
3+
[global]
4+
error_log = /proc/self/fd/2
5+
6+
; https://github.com/docker-library/php/pull/725#issuecomment-443540114
7+
log_limit = 8192
8+
9+
[www]
10+
; php-fpm closes STDOUT on startup, so sending logs to /proc/self/fd/1 does not work.
11+
; https://bugs.php.net/bug.php?id=73886
12+
access.log = /proc/self/fd/2
13+
14+
clear_env = no
15+
16+
; Ensure worker stdout and stderr are sent to the main error log.
17+
catch_workers_output = yes
18+
decorate_workers_output = no

config/php.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; Inspired by https://github.com/docker-library/php/blob/master/8.2/bookworm/fpm/Dockerfile
2+
3+
; https://github.com/docker-library/php/issues/878#issuecomment-938595965'
4+
fastcgi.logging = Off

docker-entrypoint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ fi
4141
# nginx will daemonize
4242
nginx
4343

44-
# php-fpm will not
45-
php-fpm
44+
# php-fpm should not daemonize
45+
php-fpm8.2 --nodaemonize

0 commit comments

Comments
 (0)