| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is dockerized version of Live Helper Chat. It includes these images
Checkout the repository
Run cd docker-standalone
Copy .env.default to .env
Edit .env file and change LHC_SECRET_HASH to any random string
Database default settings if you don't change those in .env file.
For version with NodeJS plugin (Recommended)
For standard version without NodeJS plugin run
You will need to install composer dependencies:
docker exec -it --workdir /code docker-standalone-php-1 /bin/bashphp composer.phar update
php composer.phar installEdit docker-standalone/lhc-php-resque/lhcphpresque/settings/settings.ini.php and put proper site_address domain value. php-resque does not know what domain it's running
Make sure the cache, settings and var folders have the correct permissions:
docker exec -it docker-standalone-web-1 chown -R www-data:www-data /code/cache
docker exec -it docker-standalone-web-1 chown -R www-data:www-data /code/settings
docker exec -it docker-standalone-web-1 chown -R www-data:www-data /code/varEdit .env file and set LHC_PUBLIC_PORT and LHC_NODE_JS_PORT port to 80
That's up to you. You can have in host machine runing nginx and just proxy request or tweak images/docker files I provided. You should play around with web service.
E.g to the ones who are too lazy too use google :D
Generate SSL certificate under docker folder for demo.livehelperchat.com domain. Change paths in this command. You have to be pointed domain to your sever
certbot certonly --config-dir /opt/lhc/docker-standalone/conf/nginx/ssl --webroot --webroot-path /opt/lhc/docker-standalone/livehelperchat/lhc_web -d demo.livehelperchat.com
This is how cronjob can look like. Make sure you put your domain and correct docker-standalone-web-1 name.
0 0 * * * certbot certonly --keep-until-expiring --config-dir /opt/lhc/docker-standalone/conf/nginx/ssl --webroot --webroot-path /opt/lhc/docker-standalone/livehelperchat/lhc_web -d demo.livehelperchat.com --post-hook "docker restart docker-standalone-web-1" > /dev/null 2>&1
If you are migrating server and want to setup fresh certbot, you can just use this command
certbot certonly --manual --preferred-challenges http --config-dir /opt/lhc/docker-standalone/conf/nginx/ssl -d demo.livehelperchat.com
web service part will have to look like
web:
image: nginx:latest
env_file: .env
ports:
- "${LHC_PUBLIC_PORT}:80"
- "443:443"
volumes:
- ./livehelperchat/lhc_web:/code
- ./conf/nginx/site-ssl.conf:/etc/nginx/conf.d/default.conf
- ./conf/nginx/mime.types:/etc/nginx/mime.types
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./conf/nginx/ssl/live/demo.livehelperchat.com/fullchain.pem:/etc/nginx/ssl/demo.livehelperchat.com/fullchain.pem
- ./conf/nginx/ssl/live/demo.livehelperchat.com/privkey.pem:/etc/nginx/ssl/demo.livehelperchat.com/privkey.pem
depends_on:
- db
- php
- php-cronjob
networks:
- code-network
restart: alwaysModify /conf/nginx/site-ssl.conf and change where you see demo.livehelperchat.com to your domain.
Re-create docker image after a changes.
cd /opt/lhc/docker-standalone && docker compose -f docker-compose-nodejs.yml up -d --no-deps --force-recreate web
Remember to automated SSL issuing workflow :)
cd /opt/lhc/docker-standalone && docker compose -f docker-compose-nodejs.yml down cd /opt/lhc/docker-standalone && docker compose -f docker-compose-nodejs.yml up -d
Nginx and PHP-FPM status endpoints are available from within the Docker network (e.g. from inside any container) or from the host machine.
The allowed IPs are configured directly in the nginx conf files (conf/nginx/site-nodejs.conf, conf/nginx/site.conf, conf/nginx/site-ssl.conf) under the nginx_status and fpm-status location blocks. By default private network ranges and the Docker host IP are allowed.
To get overview of docker containers
docker statsAlso check server files limits https://gemini.google.com/share/9f106a446951
Open a shell in the nginx container. Get yours name first docker ps:
docker exec -it docker-standalone-web-1 /bin/bashThen run any of the following:
# PHP-FPM status (pool summary: accepted conn, active/idle processes, req/sec since start)
curl http://web/fpm-status
# PHP-FPM status with per-worker details (pid, state, last URI, cpu, memory)
curl 'http://web/fpm-status?full'
# PHP-FPM status as JSON (useful for scripts and monitoring tools)
curl 'http://web/fpm-status?json'
# PHP-FPM status in Prometheus metrics format
curl 'http://web/fpm-status?prometheus'
# Nginx connection/request counts
curl http://web/nginx_statusTo calculate real-time requests per second for php-fpm, poll accepted conn twice and divide by the interval:
A=0; while true; do \
B=$(curl -s 'http://web/fpm-status?json' | grep -o '"accepted conn":[0-9]*' | grep -o '[0-9]*'); \
[ "$A" -gt 0 ] && awk "BEGIN {printf \"req/s: %.2f\n\", $B - $A}"; \
A=$B; sleep 1; \
doneFor nginx calculate real-time requests per second:
A=0; while true; do \
B=$(curl -s 'http://web/nginx_status' | awk '/accepts handled requests/{getline; print $3}'); \
[ "$A" -gt 0 ] && awk "BEGIN {printf \"req/s: %.2f\n\", $B - $A}"; \
A=$B; sleep 1; \
doneTo allow additional IPs, edit the allow lines in the relevant nginx conf file and recreate the web container:
docker compose -f docker-compose-nodejs.yml up -d --no-deps --force-recreate webPHP errors are logged to stderr, which Docker captures automatically. The php service is configured with log rotation via Docker's json-file driver (max-size: 50m, max-file: 5), capping total log storage at ~250MB.
To stream PHP error logs in real time:
docker compose -f docker-compose-nodejs.yml logs phpTo stream nginx errors in real time
docker compose -f docker-compose-nodejs.yml logs webTo find the raw log file path on the host:
docker inspect --format='{{.LogPath}}' $(docker compose -f docker-compose-nodejs.yml ps -q php)The file is located under /var/lib/docker/containers/<container-id>/<container-id>-json.log and rotated files are named ...-json.log.1, ...-json.log.2, etc. Root access is required to read them directly.
To change log rotation limits, edit the logging block in docker-compose-standard.yml (or docker-compose-nodejs.yml) under the php service:
logging:
driver: json-file
options:
max-size: "50m"
max-file: "5"You have to edit back office mail settings and use SMTP.
# Update docker images
cd docker-standalone && git pull origin master
# If there is any changes you can build your containers
docker compose -f docker-compose-nodejs.yml build --no-cache
# Or just pull new ones
docker-compose -f docker-compose-nodejs.yml pull
# I would recommend also just restart composer containers
docker compose -f docker-compose-nodejs.yml down
docker compose -f docker-compose-nodejs.yml up
# OR start docker as service
docker compose -f docker-compose-nodejs.yml up -d
# All these commands are executed from docker-standalone folder
cd livehelperchat && git pull origin master
cd lhc-php-resque && git pull origin master
cd NodeJS-Helper && git pull origin master
# Login to php-fpm container and execute
docker exec -it docker-standalone-php-1 /bin/bash
# Execute in container. You might need to download composer.phar file
cd /code && php composer.phar update
cd /code && php composer.phar install
cd /code && php cron.php -s site_admin -c cron/util/update_database -p local
cd /code && php cron.php -s site_admin -c cron/util/clear_cachearray (
0 => 'lhcphpresque',
1 => 'nodejshelper',
),```
As there is no mysql or mysqldump inside of containers docker mysql can be reached using 127.0.0.1:3307 so you can use master host where all your containers are running and just dump database.
server {
listen *:80; # This line should be gone once SSL is setup
server_name server_name chat.example.com; # Change to your domain
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
# Uncomment below two lines if you are running under https. So LHC will pickup https correctly
# proxy_set_header X-Forwarded-Proto https;
# proxy_set_header X-Forwarded-Ssl on;
proxy_pass http://localhost:8081/; # Change port to your docker public port
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Those will appear automaticlaly once you setup SSL using certbot
# listen 443 ssl; # managed by Certbot
# ssl_certificate /etc/letsencrypt/live/chat.example.com/fullchain.pem; # managed by Certbot
# ssl_certificate_key /etc/letsencrypt/live/chat.example.com/privkey.pem; # managed by Certbot
# include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}| Back | FazBrowse Home | New Git URL |