Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust logging for docker setups #379

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions config/packages/monolog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ when@dev:
include_stacktraces: true
max_files: 10
channels: ['!event']
stderr:
type: stream
path: 'php://stderr'
level: info
channels: ['!event']
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
Expand Down Expand Up @@ -57,11 +62,19 @@ when@prod:
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: group
members: [nested_file, nested_stderr]
nested_file:
type: rotating_file
max_files: 7
path: '%kernel.logs_dir%/%kernel.environment%.log'
level: debug
formatter: monolog.formatter.json
nested_stderr:
type: stream
path: 'php://stderr'
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ COPY --from=builder-nodejs --chown=$USER:$GROUP $MBIN_HOME/public $MBIN_HOME/pub
COPY --link docker/caddy/Caddyfile /etc/caddy/Caddyfile
COPY --chmod=755 --link docker/docker-entrypoint ./

RUN mkdir -p public/media /data /config && \
chown -R $USER:$GROUP public/media /data /config .env && \
chmod 777 public/media
RUN mkdir -p public/media var/log /data /config && \
chown -R $USER:$GROUP public/media var /data /config .env && \
chmod 777 public/media var

# Switch user
USER $USER:$GROUP
Expand Down
3 changes: 3 additions & 0 deletions docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ services:
]
volumes:
- ./storage/media:/var/www/mbin/public/media
- ./storage/logs:/var/www/mbin/var/log
# If you want to change configs locally, without rebuilding the image use:
# - ../config:/var/www/mbin/config
env_file:
Expand Down Expand Up @@ -80,6 +81,7 @@ services:
test: ["CMD-SHELL", "ps aux | grep 'messenger[:]consume' || exit 1"]
volumes:
- ./storage/media:/var/www/mbin/public/media
- ./storage/logs:/var/www/mbin/var/log
# If you want to change configs locally, without rebuilding the image use:
# - ../config:/var/www/mbin/config
env_file:
Expand Down Expand Up @@ -107,6 +109,7 @@ services:
test: ["CMD-SHELL", "ps aux | grep 'messenger[:]consume' || exit 1"]
volumes:
- ./storage/media:/var/www/mbin/public/media
- ./storage/logs:/var/www/mbin/var/log
# If you want to change configs locally, without rebuilding the image use:
# - ../config:/var/www/mbin/config
env_file:
Expand Down
11 changes: 7 additions & 4 deletions docs/docker_deployment_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ image: "ghcr.io/mbinorg/mbin:latest"
```bash
cp ../.env.example_docker .env
cp compose.prod.yml compose.override.yml
mkdir -p storage/media storage/caddy_config storage/caddy_data
sudo chown $USER:$USER storage/media storage/caddy_config storage/caddy_data
mkdir -p storage/media storage/caddy_config storage/caddy_data storage/logs
sudo chown $USER:$USER storage/media storage/caddy_config storage/caddy_data storage/logs
```

### Configure `.env` and `compose.override.yml`
Expand Down Expand Up @@ -172,8 +172,11 @@ Next, log in and create a magazine named "random" to which unclassified content

### Debugging / Logging

1. See the running container IDs: `docker ps`
2. You can see the logs via (use `-f` to follow the output): `docker logs -f <container_id>`
1. List the running service containers with `docker compose ps`
2. You can see the logs with `docker compose logs -f <service>` (use `-f` to follow the output)
3. for `php`, `messenger` and `messenger_ap` services, the application log is also available at
`storage/logs` directory on the host, named after the running environment and date
(e.g. `storage/logs/prod-2023-12-01.log`)

### Add auxiliary containers to `compose.yml`

Expand Down