Skip to content

Commit

Permalink
Better logging & image improvement (#31)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* done
  • Loading branch information
sethsandaru committed Feb 16, 2024
1 parent 76d7950 commit f4c82d3
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 36 deletions.
4 changes: 3 additions & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ RUN docker-php-ext-install pdo mbstring exif pcntl bcmath gd
COPY . .
COPY ./.docker/docking-worker.conf /etc/supervisor/conf.d/
COPY ./.docker/docking-host.conf /etc/nginx/conf.d/default.conf
COPY ./.docker/php-fpm.conf /usr/local/etc/php-fpm.d/

RUN cp .docker/entrypoint.sh /entrypoint
RUN chmod +x /entrypoint

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

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

############# Storage ENV

Expand Down
19 changes: 9 additions & 10 deletions .docker/docking-octane.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ stopasgroup=true
killasgroup=true
numprocs=5
redirect_stderr=true
stdout_logfile=/var/log/docking-worker.log
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stopwaitsecs=3600

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

[program:docking-nginx]
Expand All @@ -27,8 +27,7 @@ autorestart=true
startretries=5
numprocs=1
startsecs=0
redirect_stderr=true
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
stdout_logfile_maxbytes=10MB
15 changes: 6 additions & 9 deletions .docker/docking-worker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ stopasgroup=true
killasgroup=true
numprocs=5
redirect_stderr=true
stdout_logfile=/var/log/docking-worker.log
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stopwaitsecs=3600

[program:docking-php-fpm]
command=php-fpm -F -R
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
stdout_logfile_maxbytes=10MB
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
process_name=%(program_name)s_%(process_num)02d

[program:docking-nginx]
Expand All @@ -27,8 +26,6 @@ autorestart=true
startretries=5
numprocs=1
startsecs=0
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
stdout_logfile_maxbytes=10MB
15 changes: 14 additions & 1 deletion .docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
#!/usr/bin/env sh
set -e

echo "
____ _ ___
| _ \ ___ ___| |/ (_)_ __ __ _
| | | |/ _ \ / __| ' /| | '_ \ / _ |
| |_| | (_) | (__| . \| | | | | (_| |
|____/ \___/ \___|_|\_\_|_| |_|\__, |
|___/
";

# Run user scripts, if they exist
for f in /var/www/html/.docker/scripts/*.sh; do
# Bail out this loop if any script exits with non-zero status code
bash "$f" || break
done

echo "Welcome to DocKing";
if [ "$DB_CONNECTION" = "sqlite" ]; then
echo "For SQLite users, please note down the UID & GID, then run CHOWN on the host machine"
id www-data
fi

echo "Starting the application using supervisor...";
exec /usr/bin/supervisord --nodaemon
10 changes: 5 additions & 5 deletions .docker/octane.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
FROM ghcr.io/roadrunner-server/roadrunner:latest AS roadrunner
FROM php:8.2-fpm

COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr
FROM php:8.2-cli

WORKDIR /var/www/html

Expand Down Expand Up @@ -33,6 +30,9 @@ RUN rm -rf ./node_modules

RUN php artisan optimize
RUN php artisan storage:link
RUN ./vendor/bin/rr get-binary
RUN chmod +x ./rr


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

EXPOSE 80
EXPOSE 80 8080

############# Default app ENV
ENV APP_ENV="production"
Expand Down
3 changes: 3 additions & 0 deletions .docker/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[global]
error_log = /proc/1/fd/1

17 changes: 9 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'channels' => ['stderr'],
'ignore_exceptions' => false,
],

Expand Down
6 changes: 5 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ services:
docking:
build:
context: .
dockerfile: .docker/Dockerfile
dockerfile: .docker/octane.Dockerfile
volumes:
- ./docking.sqlite:/var/www/html/database/docking.sqlite
- app_storage:/var/www/html/storage/app
environment:
DATABASE_URL: 'sqlite:////var/www/html/database/docking.sqlite'
links:
- gotenberg
ports:
- '8888:80'
- '8080:8080'

gotenberg:
image: gotenberg/gotenberg:7
Expand Down

0 comments on commit f4c82d3

Please sign in to comment.