How to deploy nightwatch on docker-compose Setup Hello,
I have Laravel running in a docker compose setup.
I was wondering if this implementation with an extra nightwatch container can work.
I think it cannot watch on errors of the original application?
Can anyone please provide me a hint how to set up it IN MY SETUP best.
(running the agent so that application/queue errors and so stuff can be watched)
Thank you very much :)
This is my compose file:
services:
nginx:
image: registry(lvckyworld)/marinaapi-laravel/nginx:latest-${APP_ENV}
container_name: "${PROJECT_NAME}_nginx"
restart: unless-stopped
depends_on:
- php
volumes:
- $STORAGE_DIR:/var/www/html/storage
labels:
- "traefik.enable=true"
- "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)"
- "traefik.http.routers.${PROJECT_NAME}_nginx.entrypoints=https"
- "traefik.http.routers.${PROJECT_NAME}_nginx.tls=true"
- "traefik.http.routers.${PROJECT_NAME}_nginx.tls.certresolver=letsencrypt"
networks:
- lvckyworld_proxy
- internal
postgres:
image: wodby/postgres:15
container_name: "${PROJECT_NAME}_postgres"
restart: unless-stopped
ports:
- "${EXPOSE_DB_PORT}:5432"
environment:
POSTGRES_USER: $DB_USER
POSTGRES_DB: $DB_NAME
POSTGRES_PASSWORD: $DB_PASSWORD
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- internal
# command: ["postgres", "-c", "log_statement=all"] # log everything to check why postgres is dying
php:
image: registry(lvckyworld)/marinaapi-laravel/php:latest-${APP_ENV}
container_name: "${PROJECT_NAME}_php" # (original image: wodby/php:8.4)
restart: unless-stopped
environment:
DB_HOST: $DB_HOST
DB_USER: $DB_USER
DB_PASSWORD: $DB_PASSWORD
DB_NAME: $DB_NAME
PHP_FPM_USER: wodby
PHP_FPM_GROUP: wodby
PHP_FPM_PM_MAX_CHILDREN: 64
PHP_FPM_PM_MIN_SPARE_SERVERS: 16
PHP_FPM_PM_MAX_SPARE_SERVERS: 32
PHP_FPM_PM_START_SERVERS: 16
APP_ENV: $APP_ENV
depends_on:
- postgres
volumes:
- $STORAGE_DIR:/var/www/html/storage
- $LARAVEL_ENV_FILE:/var/www/html/.env
networks:
- internal
queue:
image: registry(lvckyworld.dev)/lvckyworld/marinaapi-laravel/php:latest-${APP_ENV} # (original image: wodby/php:8.4)
restart: unless-stopped
environment:
DB_HOST: $DB_HOST
DB_USER: $DB_USER
DB_PASSWORD: $DB_PASSWORD
DB_NAME: $DB_NAME
PHP_FPM_USER: wodby
PHP_FPM_GROUP: wodby
APP_ENV: $APP_ENV
depends_on:
- postgres
volumes:
- $STORAGE_DIR:/var/www/html/storage
- $LARAVEL_ENV_FILE:/var/www/html/.env
# Laravel queue timeout info (see laravel.com/docs/11.x/queues#timeout)
command: php artisan queue:work --queue=high,default,low --max-time=3600 --timeout=60
networks:
- internal
nightwatch:
image: registry(lvckyworld)/marinaapi-laravel/php:latest-${APP_ENV} # (original image: wodby/php:8.4)
restart: unless-stopped
environment:
DB_HOST: $DB_HOST
DB_USER: $DB_USER
DB_PASSWORD: $DB_PASSWORD
DB_NAME: $DB_NAME
PHP_FPM_USER: wodby
PHP_FPM_GROUP: wodby
APP_ENV: $APP_ENV
depends_on:
- postgres
volumes:
- $STORAGE_DIR:/var/www/html/storage
- $LARAVEL_ENV_FILE:/var/www/html/.env
command: php artisan nightwatch:agent
networks:
- internal
cron:
image: registry(lvckyworld)/marinaapi-laravel/php-crontab:latest-${APP_ENV} # (original image: wodby/php:8.4)
restart: unless-stopped
environment:
DB_HOST: $DB_HOST
DB_USER: $DB_USER
DB_PASSWORD: $DB_PASSWORD
DB_NAME: $DB_NAME
PHP_FPM_USER: wodby
PHP_FPM_GROUP: wodby
APP_ENV: $APP_ENV
depends_on:
- postgres
volumes:
- $STORAGE_DIR:/var/www/html/storage
- $LARAVEL_ENV_FILE:/var/www/html/.env
command: sudo -E crond -f -d 0
networks:
- internal
volumes:
postgres-data:
networks:
lvckyworld_proxy:
external: true
internal:
external: false
Hello! I spent the afternoon trying to get this to work and I succeeded. Launch your nightwatch container with the following command:
php artisan artisan nightwatch:agent --listen-on=0.0.0.0:2407
Add these environment variables to all laravel containers (php, queue, cron):
NIGHTWATCH_INGEST_URI=nightwatch:2407
I had to delete the NIGHTWATCH_REQUEST_SAMPLE_RATE variable otherwise I didn't see anything.
HI @fouteox - great tip! works like a charm! Thanks
Please sign in or create an account to participate in this conversation.