feat(docker): 🚀 Update server port to 8025
Some checks failed
CI / Test (1.22) (push) Failing after -24m19s
CI / Test (1.23) (push) Failing after -24m15s
CI / Lint (push) Successful in -26m35s
CI / Build (push) Successful in -26m34s

- Change default server port from 8080 to 8025 across all configurations.
- Update Dockerfile, docker-compose.yml, and related documentation.
- Ensure all CLI commands and API endpoints reflect the new port.
- Adjust example configurations and health check URLs accordingly.
This commit is contained in:
Hein
2026-02-04 13:37:38 +02:00
parent 947761313b
commit c1dbff318d
16 changed files with 270 additions and 125 deletions

View File

@@ -10,6 +10,7 @@ This guide explains how to run WhatsHooked using Docker and Docker Compose.
## Quick Start
1. **Copy the example configuration file:**
```bash
cp config.example.json config.json
```
@@ -21,54 +22,64 @@ This guide explains how to run WhatsHooked using Docker and Docker Compose.
- Server settings (port, authentication)
3. **Create required directories:**
```bash
mkdir -p sessions data/media
```
4. **Build and start the server:**
```bash
docker-compose up -d
```
5. **View logs to scan QR code (first run):**
```bash
docker-compose logs -f whatshooked
```
Scan the QR code with WhatsApp on your phone to authenticate.
6. **Check server health:**
```bash
curl http://localhost:8080/health
curl http://localhost:8025/health
```
## Docker Commands
### Build the image
```bash
docker-compose build
```
### Start the service
```bash
docker-compose up -d
```
### Stop the service
```bash
docker-compose down
```
### View logs
```bash
docker-compose logs -f
```
### Restart the service
```bash
docker-compose restart
```
### Access the container shell
```bash
docker-compose exec whatshooked sh
```
@@ -87,9 +98,10 @@ These volumes ensure your data persists across container restarts.
### Port Mapping
By default, the server runs on port 8080. To change the port:
By default, the server runs on port 8025. To change the port:
**Option 1: Update config.json**
```json
{
"server": {
@@ -97,16 +109,19 @@ By default, the server runs on port 8080. To change the port:
}
}
```
Then update docker-compose.yml:
```yaml
ports:
- "9090:9090"
```
**Option 2: Map to different host port**
```yaml
ports:
- "3000:8080" # Access via localhost:3000, server still runs on 8080 internally
- "3000:8025" # Access via localhost:3000, server still runs on 8025 internally
```
### Authentication
@@ -114,6 +129,7 @@ ports:
Set authentication in config.json:
**Option 1: API Key**
```json
{
"server": {
@@ -123,6 +139,7 @@ Set authentication in config.json:
```
**Option 2: Username/Password**
```json
{
"server": {
@@ -140,10 +157,10 @@ Uncomment the deploy section in docker-compose.yml to set resource limits:
deploy:
resources:
limits:
cpus: '1.0'
cpus: "1.0"
memory: 512M
reservations:
cpus: '0.25'
cpus: "0.25"
memory: 128M
```
@@ -152,6 +169,7 @@ deploy:
When you first start the server, you'll need to scan a QR code to authenticate with WhatsApp.
### View QR Code in Logs
```bash
docker-compose logs -f whatshooked
```
@@ -159,19 +177,22 @@ docker-compose logs -f whatshooked
The QR code will be displayed in ASCII art in the terminal along with a browser link. You have two options:
**Option 1: Scan from Terminal**
1. Open WhatsApp
2. Go to Settings > Linked Devices
3. Tap "Link a Device"
4. Scan the QR code from the terminal
**Option 2: View in Browser**
1. Look for the line: `Or open in browser: http://localhost:8080/api/qr/{account_id}`
1. Look for the line: `Or open in browser: http://localhost:8025/api/qr/{account_id}`
2. Open that URL in your web browser to see a larger PNG image
3. Scan the QR code from your browser
### Alternative: Use CLI Tool
You can also use the CLI tool outside Docker to link accounts, then mount the session:
```bash
./bin/whatshook-cli accounts add
```
@@ -183,33 +204,39 @@ The Docker image includes both the server and CLI binaries in the `/app/bin` dir
### Available CLI Commands
List all hooks:
```bash
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 hooks list
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks list
```
Add a new hook:
```bash
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 hooks add
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks add
```
Remove a hook:
```bash
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 hooks remove <hook_id>
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 hooks remove <hook_id>
```
List WhatsApp accounts:
```bash
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 accounts list
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 accounts list
```
Send a message:
```bash
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 send
docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 send
```
Check server health:
```bash
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080 health
docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025 health
```
### Authentication with CLI
@@ -217,9 +244,10 @@ docker exec whatshooked-server /app/bin/whatshook-cli --server http://localhost:
If your server has authentication enabled, you need to configure it in the CLI:
**Option 1: Using command-line flags**
```bash
docker exec whatshooked-server /app/bin/whatshook-cli \
--server http://localhost:8080 \
--server http://localhost:8025 \
--api-key your-api-key \
hooks list
```
@@ -227,15 +255,17 @@ docker exec whatshooked-server /app/bin/whatshook-cli \
**Option 2: Create a CLI config file**
1. Access the container:
```bash
docker exec -it whatshooked-server sh
```
2. Create the CLI config:
```bash
cat > /app/.whatshooked-cli.json <<EOF
{
"server_url": "http://localhost:8080",
"server_url": "http://localhost:8025",
"api_key": "your-api-key"
}
EOF
@@ -251,10 +281,11 @@ docker exec whatshooked-server /app/bin/whatshook-cli \
Create an alias on your host machine for easier CLI access:
```bash
alias whatshook-cli='docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8080'
alias whatshook-cli='docker exec -it whatshooked-server /app/bin/whatshook-cli --server http://localhost:8025'
```
Then use it like:
```bash
whatshook-cli hooks list
whatshook-cli send
@@ -265,25 +296,33 @@ Add this to your `~/.bashrc` or `~/.zshrc` to make it permanent.
## Troubleshooting
### Container won't start
Check logs for errors:
```bash
docker-compose logs
```
### Config file not found
Ensure config.json exists in the project root:
```bash
ls -la config.json
```
### Permission issues with volumes
Fix ownership of mounted directories:
```bash
sudo chown -R $(id -u):$(id -g) sessions data
```
### QR code not displaying
Ensure `show_qr: true` is set in config.json:
```json
{
"whatsapp": [
@@ -295,12 +334,15 @@ Ensure `show_qr: true` is set in config.json:
```
### Cannot connect to server
Check if the container is running:
```bash
docker-compose ps
```
Check health status:
```bash
docker inspect whatshooked-server | grep -A 10 Health
```
@@ -332,11 +374,13 @@ docker inspect whatshooked-server | grep -A 10 Health
### Example with Reverse Proxy (nginx)
Create a network:
```bash
docker network create whatshooked-net
```
Update docker-compose.yml:
```yaml
services:
whatshooked:
@@ -344,7 +388,7 @@ services:
- whatshooked-net
# Don't expose ports to host, only to network
# ports:
# - "8080:8080"
# - "8025:8025"
networks:
whatshooked-net:
@@ -352,6 +396,7 @@ networks:
```
Configure nginx to proxy to the container:
```nginx
server {
listen 443 ssl;
@@ -361,7 +406,7 @@ server {
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://whatshooked:8080;
proxy_pass http://whatshooked:8025;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
@@ -373,6 +418,7 @@ server {
### Health Checks
The compose file includes a health check that runs every 30 seconds:
```bash
docker inspect --format='{{.State.Health.Status}}' whatshooked-server
```
@@ -380,6 +426,7 @@ docker inspect --format='{{.State.Health.Status}}' whatshooked-server
### Log Management
Limit log size to prevent disk space issues:
```yaml
services:
whatshooked:
@@ -395,11 +442,13 @@ services:
To update to the latest version:
1. Pull latest code:
```bash
git pull
```
2. Rebuild the image:
```bash
docker-compose build --no-cache
```