Skip to content

Commit 4dcab15

Browse files
committed
refactor: custom init
1 parent b29025c commit 4dcab15

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

Dockerfile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# includes redis
2-
31
FROM php:8.4-fpm-alpine AS base
42

3+
ENV DIRBROWSER_VERSION=3.9.0
4+
55
RUN apk update && apk upgrade
66

77
RUN docker-php-ext-install opcache
@@ -20,7 +20,7 @@ RUN apk add --no-cache redis
2020

2121
RUN apk add --no-cache nginx
2222

23-
RUN apk add --no-cache supervisor
23+
RUN apk add --no-cache bash
2424

2525
RUN apk add --no-cache curl \
2626
&& curl -fSsL https://github.com/adrianschubek/utpp/releases/download/0.5.0/utpp-alpine -o /usr/local/bin/utpp && chmod +x /usr/local/bin/utpp\
@@ -40,16 +40,19 @@ COPY server/nginx/nginx.conf /etc/nginx/nginx.conf
4040

4141
COPY server/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
4242

43-
COPY server/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
44-
4543
COPY server/php/fpm-pool.conf /usr/local/etc/php-fpm.d/www.conf
4644

4745
COPY server/php/php.ini /usr/local/etc/php/conf.d/custom.ini
4846

4947
COPY src/index.php /var/www/html
5048

49+
# skipped in v3.9
50+
# COPY src/worker.php /var/www/html
51+
5152
COPY src/init.sh /init.sh
5253

54+
RUN chmod +x /init.sh
55+
5356
ENV THEME=default
5457

5558
ENV DATE_FORMAT=relative
@@ -109,12 +112,13 @@ ENV BATCH_MAX_TOTAL_SIZE=500
109112
ENV BATCH_MAX_FILE_SIZE=100
110113
# MB, how much system disk space to keep free at all times
111114
ENV BATCH_MIN_SYSTEM_FREE_DISK=500
115+
# watch filesystem
116+
ENV WORKER_WATCH=true
117+
# seconds re-scan
118+
ENV WORKER_SCAN_INTERVAL=60
112119

113-
# TODO Ratelimiting?
114-
115-
RUN chmod +x /init.sh
120+
ENV WORKER_FORCE_RESCAN=
116121

117122
EXPOSE 8080
118123

119-
# Let supervisord start nginx & php-fpm
120124
CMD ["/init.sh"]

src/init.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,30 @@ YELLOW='\033[0;33m'
66
RED='\033[0;31m'
77
GREEN_BG_BLACK_TEXT='\033[42;30m'
88
NC='\033[0m' # reset
9+
MAX_STEPS=5
910

1011
dbv=$DIRBROWSER_VERSION
1112
echo -e "${GREEN_BG_BLACK_TEXT} dir-browser v${dbv} by Adrian Schubek${NC}"
1213
echo -e "${CYAN} -> https://dir.adriansoftware.de <- ${NC}"
1314

14-
echo -e "${YELLOW}[ 1/6 ] Pre-processing configs using utpp... ${NC}"
15+
echo -e "${YELLOW}[ 1/$MAX_STEPS ] Pre-processing configs using utpp... ${NC}"
1516
utpp "/etc/nginx/**;/usr/local/etc/php*/**;/var/www/html/*.php"
1617

17-
echo -e "${YELLOW}[ 2/6 ] Starting php-fpm... ${NC}"
18+
echo -e "${YELLOW}[ 2/$MAX_STEPS ] Starting php-fpm... ${NC}"
1819
php-fpm -RF &
1920

20-
echo -e "${YELLOW}[ 3/6 ] Starting worker... ${NC}"
21-
php /var/www/html/worker.php &
21+
# skipped in v3.9
22+
# echo -e "${YELLOW}[ 3/$MAX_STEPS ] Starting worker... ${NC}"
23+
# php /var/www/html/worker.php &
2224

23-
echo -e "${YELLOW}[ 4/6 ] Starting nginx... ${NC}"
25+
echo -e "${YELLOW}[ 3/$MAX_STEPS ] Starting nginx... ${NC}"
2426
nginx -g 'daemon off;' &
2527

26-
echo -e "${YELLOW}[ 5/6 ] Starting redis... ${NC}"
28+
echo -e "${YELLOW}[ 4/$MAX_STEPS ] Starting redis... ${NC}"
2729
redis-server /etc/redis.conf --save 60 1 &
2830

29-
echo -e "${GREEN}[ 6/6 ] All services running!${NC}"
31+
echo -e "${GREEN}[ 5/$MAX_STEPS ] All services running!${NC}"
3032
wait -n
3133

32-
echo -e "${RED}Error: Terminating due to a service exiting...${NC}"
34+
echo -e "${RED}[ Error ] Terminating due to a service exiting...${NC}"
3335
exit $?

0 commit comments

Comments
 (0)