Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/content/docs/3.framework-guides/1.laravel/5.nightwatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
head.title: 'Laravel Nightwatch with Docker - Docker PHP - Server Side Up'
description: 'Learn how to configure Laravel Nightwatch with Docker.'
layout: docs
title: Nightwatch
---

## Laravel Nightwatch with Docker
Run Laravel Nightwatch by passing the Artisan command as the container's command. Nightwatch is Laravel's observability platform for monitoring application performance, errors, and queries in real-time.

::note
Before using Nightwatch with Docker, follow the [Laravel Nightwatch setup instructions](https://nightwatch.laravel.com/docs/start-guide) to install and configure the Nightwatch package in your Laravel application.
::

## Docker Compose example

This example runs Nightwatch as a separate container using the same image as your web service.

**Key points:**
- Use the same image for both your web and Nightwatch services
- Set `SIGTERM` as the stop signal for graceful shutdown (especially for `fpm-apache` and `fpm-nginx`)
- Include a health check to monitor Nightwatch status

```yml [compose.yml]
services:
php:
image: my/laravel-app

nightwatch:
image: my/laravel-app
command: ["php", "/var/www/html/artisan", "nightwatch:agent"]
stop_signal: SIGTERM
healthcheck:
test: ["CMD", "healthcheck-nightwatch"]
start_period: 10s
```

## How the health check works

The `healthcheck-nightwatch` command runs `php artisan nightwatch:status` to verify that the Nightwatch agent is running and connected. Docker uses this to determine container health and can automatically restart unhealthy containers.

## Advanced configuration

**Graceful shutdown:** The `SIGTERM` signal ensures the Nightwatch agent finishes processing current events before stopping. This is especially important for `fpm-apache` and `fpm-nginx` images.

::tip
**Multiple processes in one container:** If you're running `fpm-nginx` or `fpm-apache` and you'd like to have everything in a single container, you can [write your own S6 Overlay service script](https://github.com/just-containers/s6-overlay/tree/master#writing-a-service-script){target="_blank"} to properly manage multiple processes in a single container. Learn more about about this in our [Using S6 Overlay guide](/docs/guide/using-s6-overlay).
::

## Learn More
- [Laravel Nightwatch Documentation](https://nightwatch.laravel.com/docs/start-guide)
2 changes: 2 additions & 0 deletions src/common/usr/local/bin/healthcheck-nightwatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
php "${APP_BASE_DIR}/artisan" nightwatch:status
Loading