Skip to content
Open
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
72 changes: 72 additions & 0 deletions .env.docker.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
APP_NAME=Cachet
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=cachet
DB_USERNAME=cachet
DB_PASSWORD=your_secure_db_password

SESSION_DRIVER=redis
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis

CACHE_STORE=redis
CACHE_PREFIX=

REDIS_CLIENT=predis
REDIS_HOST=redis
REDIS_PASSWORD=your_secure_redis_password
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"

CACHET_BEACON=false
CACHET_EMOJI=false
CACHET_AUTO_TWITTER=true
CACHET_PATH=/
CACHET_TRUSTED_PROXIES=""

NIGHTWATCH_ENABLED=false

# Docker environment variables
MYSQL_ROOT_PASSWORD=your_mysql_root_password
181 changes: 181 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Cachet Docker Setup

This guide explains how to run Cachet using Docker with a complete setup including MySQL database and Redis cache.

## Quick Start

1. **Clone the repository**
```bash
git clone https://github.com/cachethq/cachet.git
cd cachet
```

2. **Create environment file**
```bash
cp .env.docker.example .env
```

3. **Update environment variables**
Edit `.env` file and update the following variables:
- `APP_KEY`: Generate using `docker-compose exec app php artisan key:generate --show` after starting containers
- `DB_PASSWORD`: Set a secure database password
- `REDIS_PASSWORD`: Set a secure Redis password
- `MYSQL_ROOT_PASSWORD`: Set a secure MySQL root password
- `APP_URL`: Set to your domain (e.g., `https://status.yourdomain.com`)

4. **Build and start services**
```bash
docker-compose up -d --build
```

5. **Generate application key**
```bash
# Generate and set the APP_KEY
docker-compose exec app php artisan key:generate
```

6. **Access Cachet**
Open your browser and navigate to `http://localhost` (or your configured domain)

## Architecture

The Docker setup includes three services:

- **app**: Cachet application with Nginx + PHP-FPM
- **db**: MySQL 8.0 database
- **redis**: Redis 7 for caching and sessions

## Configuration Files

### Docker Configuration
- `Dockerfile`: Multi-stage build for production deployment
- `docker-compose.yml`: Service orchestration
- `docker/nginx/nginx.conf`: Nginx configuration for Laravel
- `docker/php/cachet.ini`: PHP configuration optimizations
- `docker/supervisor/supervisord.conf`: Process manager configuration
- `docker/entrypoint.sh`: Startup script with database migrations

### Environment Configuration
- `.env.docker.example`: Template environment file for Docker
- Copy to `.env` and customize for your deployment

## Production Deployment

### Docker Hub Image (Recommended)

You can use the pre-built image from Docker Hub:

```yaml
services:
app:
image: cachet/cachet:latest
# ... rest of configuration
```

### Building Your Own Image

1. **Build the image**
```bash
docker build -t your-registry/cachet:latest .
```

2. **Push to registry**
```bash
docker push your-registry/cachet:latest
```

3. **Update docker-compose.yml**
```yaml
services:
app:
image: your-registry/cachet:latest
```

## Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `APP_KEY` | Laravel application key | *Required* |
| `APP_URL` | Application URL | `http://localhost` |
| `DB_PASSWORD` | Database password | *Required* |
| `REDIS_PASSWORD` | Redis password | *Required* |
| `MYSQL_ROOT_PASSWORD` | MySQL root password | *Required* |

## Data Persistence

The setup includes persistent volumes for:
- MySQL data: `mysql_data`
- Redis data: `redis_data`
- Application storage: `storage_data`

## Health Checks

Both MySQL and Redis services include health checks to ensure the application starts only when dependencies are ready.

## Scaling

To scale the application:

```bash
docker-compose up -d --scale app=3
```

Add a load balancer like Nginx or Traefik in front of the application containers.

## Troubleshooting

### Database Connection Issues
```bash
# Check database logs
docker-compose logs db

# Test database connection
docker-compose exec app php artisan tinker --execute="DB::connection()->getPdo();"
```

### Redis Connection Issues
```bash
# Check Redis logs
docker-compose logs redis

# Test Redis connection
docker-compose exec redis redis-cli auth your_redis_password ping
```

### Application Logs
```bash
# View application logs
docker-compose logs app

# Follow logs in real-time
docker-compose logs -f app
```

### Reset Everything
```bash
# Stop and remove all containers and volumes
docker-compose down -v

# Rebuild and start
docker-compose up -d --build
```

## Security Considerations

1. **Change default passwords**: Always update database and Redis passwords
2. **Use HTTPS**: Configure SSL/TLS certificates for production
3. **Firewall**: Restrict access to database and Redis ports
4. **Updates**: Regularly update Docker images and dependencies

## Development

For development with live code reloading:

```bash
# Mount source code as volume
docker-compose -f docker-compose.dev.yml up -d
```

## Support

For issues related to Docker setup, please open an issue on the [Cachet repository](https://github.com/cachethq/cachet/issues).
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM php:8.3-fpm

# Install system dependencies
RUN apt-get update && apt-get install -y \
nginx \
curl \
zip \
unzip \
git \
supervisor \
libicu-dev \
libzip-dev \
&& docker-php-ext-install \
pdo \
pdo_mysql \
zip \
intl \
opcache \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install Composer
COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer

# Copy configuration files
COPY docker/php/cachet.ini /usr/local/etc/php/conf.d/cachet.ini
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
COPY docker/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY docker/entrypoint.sh /entrypoint.sh

# Set working directory
WORKDIR /var/www/html

# Copy application code
COPY . .

# Install PHP dependencies including Redis client
RUN COMPOSER_ALLOW_SUPERUSER=1 composer require predis/predis --no-scripts \
&& composer install --no-dev --optimize-autoloader --no-scripts

# Set permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 storage bootstrap/cache \
&& chmod +x artisan /entrypoint.sh

EXPOSE 80

CMD ["/entrypoint.sh"]
72 changes: 72 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
services:
app:
build: .
ports:
- "80:80"
environment:
- APP_ENV=production
- APP_KEY=${APP_KEY}
- APP_DEBUG=false
- APP_URL=http://localhost
- DB_CONNECTION=mysql
- DB_HOST=db
- DB_PORT=3306
- DB_DATABASE=cachet
- DB_USERNAME=cachet
- DB_PASSWORD=${DB_PASSWORD}
- CACHE_STORE=redis
- SESSION_DRIVER=redis
- QUEUE_CONNECTION=redis
- REDIS_CLIENT=predis
- REDIS_HOST=redis
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_PORT=6379
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- storage_data:/var/www/html/storage
restart: unless-stopped
networks:
- cachet

db:
image: mysql:8.0
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=cachet
- MYSQL_USER=cachet
- MYSQL_PASSWORD=${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 20s
retries: 10
restart: unless-stopped
networks:
- cachet

redis:
image: redis:7-alpine
command: redis-server --requirepass ${REDIS_PASSWORD}
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "auth", "${REDIS_PASSWORD}", "ping"]
timeout: 3s
retries: 5
restart: unless-stopped
networks:
- cachet

volumes:
mysql_data:
redis_data:
storage_data:

networks:
cachet:
driver: bridge
Loading