Skip to content

Commit f4c82d3

Browse files
authored
Better logging & image improvement (#31)
* wip * wip * wip * wip * done
1 parent 76d7950 commit f4c82d3

9 files changed

+55
-36
lines changed

.docker/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ RUN docker-php-ext-install pdo mbstring exif pcntl bcmath gd
2121
COPY . .
2222
COPY ./.docker/docking-worker.conf /etc/supervisor/conf.d/
2323
COPY ./.docker/docking-host.conf /etc/nginx/conf.d/default.conf
24+
COPY ./.docker/php-fpm.conf /usr/local/etc/php-fpm.d/
2425

2526
RUN cp .docker/entrypoint.sh /entrypoint
2627
RUN chmod +x /entrypoint
2728

28-
# The bundle already built, no need to keep this to save size
29+
# The bundle already built (outer layer), no need to keep this to save size
2930
RUN rm -rf ./node_modules
3031

3132
RUN php artisan optimize
@@ -48,6 +49,7 @@ ENV APP_ENV="production"
4849
ENV APP_KEY="base64:/UnGygYvVBmIh+VgNhMj6MyI/ieXTtzUJsUL4OUtZGI="
4950
ENV DB_CONNECTION="sqlite"
5051
ENV DATABASE_URL="sqlite:////var/www/html/docking.sqlite"
52+
ENV APP_URL="http://127.0.0.1:8000"
5153

5254
############# Storage ENV
5355

.docker/docking-octane.conf

+9-10
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ stopasgroup=true
77
killasgroup=true
88
numprocs=5
99
redirect_stderr=true
10-
stdout_logfile=/var/log/docking-worker.log
10+
stdout_logfile=/proc/1/fd/1
11+
stdout_logfile_maxbytes=0
1112
stopwaitsecs=3600
1213

1314
[program:docking-octane]
14-
command=php /var/www/html/artisan octane:start --max-requests=500
15+
command=php /var/www/html/artisan octane:start --max-requests=500 --log-level=debug
1516
autostart=true
1617
autorestart=true
17-
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
18-
stdout_logfile_maxbytes=10MB
19-
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
20-
stderr_logfile_maxbytes=10MB
18+
redirect_stderr=true
19+
stdout_logfile=/proc/1/fd/1
20+
stdout_logfile_maxbytes=0
2121
process_name=%(program_name)s_%(process_num)02d
2222

2323
[program:docking-nginx]
@@ -27,8 +27,7 @@ autorestart=true
2727
startretries=5
2828
numprocs=1
2929
startsecs=0
30+
redirect_stderr=true
31+
stdout_logfile=/proc/1/fd/1
32+
stdout_logfile_maxbytes=0
3033
process_name=%(program_name)s_%(process_num)02d
31-
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
32-
stderr_logfile_maxbytes=10MB
33-
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
34-
stdout_logfile_maxbytes=10MB

.docker/docking-worker.conf

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ stopasgroup=true
77
killasgroup=true
88
numprocs=5
99
redirect_stderr=true
10-
stdout_logfile=/var/log/docking-worker.log
10+
stdout_logfile=/proc/1/fd/1
11+
stdout_logfile_maxbytes=0
1112
stopwaitsecs=3600
1213

1314
[program:docking-php-fpm]
1415
command=php-fpm -F -R
1516
autostart=true
1617
autorestart=true
17-
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
18-
stdout_logfile_maxbytes=10MB
19-
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
20-
stderr_logfile_maxbytes=10MB
18+
stdout_logfile=/proc/1/fd/1
19+
stdout_logfile_maxbytes=0
2120
process_name=%(program_name)s_%(process_num)02d
2221

2322
[program:docking-nginx]
@@ -27,8 +26,6 @@ autorestart=true
2726
startretries=5
2827
numprocs=1
2928
startsecs=0
29+
stdout_logfile=/proc/1/fd/1
30+
stdout_logfile_maxbytes=0
3031
process_name=%(program_name)s_%(process_num)02d
31-
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
32-
stderr_logfile_maxbytes=10MB
33-
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
34-
stdout_logfile_maxbytes=10MB

.docker/entrypoint.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#!/usr/bin/env sh
22
set -e
33

4+
echo "
5+
____ _ ___
6+
| _ \ ___ ___| |/ (_)_ __ __ _
7+
| | | |/ _ \ / __| ' /| | '_ \ / _ |
8+
| |_| | (_) | (__| . \| | | | | (_| |
9+
|____/ \___/ \___|_|\_\_|_| |_|\__, |
10+
|___/
11+
";
12+
413
# Run user scripts, if they exist
514
for f in /var/www/html/.docker/scripts/*.sh; do
615
# Bail out this loop if any script exits with non-zero status code
716
bash "$f" || break
817
done
918

10-
echo "Welcome to DocKing";
19+
if [ "$DB_CONNECTION" = "sqlite" ]; then
20+
echo "For SQLite users, please note down the UID & GID, then run CHOWN on the host machine"
21+
id www-data
22+
fi
23+
1124
echo "Starting the application using supervisor...";
1225
exec /usr/bin/supervisord --nodaemon

.docker/octane.Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
FROM ghcr.io/roadrunner-server/roadrunner:latest AS roadrunner
2-
FROM php:8.2-fpm
3-
4-
COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr
1+
FROM php:8.2-cli
52

63
WORKDIR /var/www/html
74

@@ -33,6 +30,9 @@ RUN rm -rf ./node_modules
3330

3431
RUN php artisan optimize
3532
RUN php artisan storage:link
33+
RUN ./vendor/bin/rr get-binary
34+
RUN chmod +x ./rr
35+
3636

3737
RUN chown -R www-data:www-data storage
3838
RUN chown -R www-data:www-data storage/app
@@ -44,7 +44,7 @@ RUN chown www-data:www-data docking.sqlite
4444
# Nginx remove default site
4545
RUN rm /etc/nginx/sites-enabled/default
4646

47-
EXPOSE 80
47+
EXPOSE 80 8080
4848

4949
############# Default app ENV
5050
ENV APP_ENV="production"

.docker/php-fpm.conf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[global]
2+
error_log = /proc/1/fd/1
3+

composer.lock

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/logging.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
'channels' => [
5555
'stack' => [
5656
'driver' => 'stack',
57-
'channels' => ['single'],
57+
'channels' => ['stderr'],
5858
'ignore_exceptions' => false,
5959
],
6060

docker-compose.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ services:
44
docking:
55
build:
66
context: .
7-
dockerfile: .docker/Dockerfile
7+
dockerfile: .docker/octane.Dockerfile
88
volumes:
9+
- ./docking.sqlite:/var/www/html/database/docking.sqlite
910
- app_storage:/var/www/html/storage/app
11+
environment:
12+
DATABASE_URL: 'sqlite:////var/www/html/database/docking.sqlite'
1013
links:
1114
- gotenberg
1215
ports:
1316
- '8888:80'
17+
- '8080:8080'
1418

1519
gotenberg:
1620
image: gotenberg/gotenberg:7

0 commit comments

Comments
 (0)