Docker Implementation
This commit is contained in:
157
domain-monitor-docker/README.md
Normal file
157
domain-monitor-docker/README.md
Normal file
@@ -0,0 +1,157 @@
|
||||
# Domain Monitor Docker Setup
|
||||
|
||||
This directory contains Docker configuration for running Domain Monitor in a containerized environment.
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. **Configure your environment:**
|
||||
- Copy `env.docker.example` to `.env.docker`
|
||||
- Edit `.env.docker` and change the default passwords:
|
||||
```bash
|
||||
cp env.docker.example .env.docker
|
||||
# Edit .env.docker with your real passwords
|
||||
```
|
||||
|
||||
2. **Run the bootstrap script:**
|
||||
```bash
|
||||
chmod +x bootstrap.sh
|
||||
./bootstrap.sh
|
||||
```
|
||||
|
||||
## What the bootstrap script does
|
||||
|
||||
The `bootstrap.sh` script will:
|
||||
|
||||
- **Clone the Domain Monitor repository** from GitHub into the `app/` folder (only if `app/` doesn't exist or is empty)
|
||||
- **Set up the application environment** by creating `.env` file with database configuration
|
||||
- **Install PHP dependencies** using Composer
|
||||
- **Configure proper file permissions** for the web server
|
||||
- **Load environment variables** from `.env.docker` into the shell
|
||||
- **Start the Docker stack** (web server, database, and phpMyAdmin)
|
||||
|
||||
### Running bootstrap multiple times
|
||||
|
||||
The bootstrap script is **safe to run multiple times**:
|
||||
- If `app/` folder exists and has content, it skips the git clone
|
||||
- It will reinstall Composer dependencies (ensures they're up to date)
|
||||
- It will restart the Docker containers with `--build` flag
|
||||
- Your database data is preserved (stored in Docker volumes)
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
The bootstrap script loads environment variables from `.env.docker` into the shell environment, which Docker Compose then uses for variable substitution. This approach ensures that all services get the correct database credentials.
|
||||
|
||||
## Services
|
||||
|
||||
After running the bootstrap script, you'll have:
|
||||
|
||||
- **Domain Monitor App**: http://localhost:8080
|
||||
- **phpMyAdmin**: http://localhost:8081 (Server: `domain-monitor-mariadb`)
|
||||
|
||||
## Managing the Docker Stack
|
||||
|
||||
### Starting the stack
|
||||
```bash
|
||||
# First time setup (clones repo, installs dependencies, starts containers)
|
||||
./bootstrap.sh
|
||||
|
||||
# Or if you just want to start existing containers
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### Stopping the stack
|
||||
```bash
|
||||
# Stop all containers
|
||||
docker compose down
|
||||
|
||||
# Stop and remove volumes (WARNING: This will delete your database data!)
|
||||
docker compose down -v
|
||||
```
|
||||
|
||||
### Restarting the stack
|
||||
```bash
|
||||
# Restart containers (keeps data)
|
||||
docker compose restart
|
||||
|
||||
# Rebuild and restart (if you made changes to Docker config)
|
||||
docker compose up -d --build
|
||||
|
||||
# Full restart (stops, rebuilds, starts)
|
||||
docker compose down && docker compose up -d --build
|
||||
```
|
||||
|
||||
### Viewing logs
|
||||
```bash
|
||||
# View logs for all services
|
||||
docker compose logs
|
||||
|
||||
# View logs for specific service
|
||||
docker compose logs web
|
||||
docker compose logs db
|
||||
docker compose logs pma
|
||||
|
||||
# Follow logs in real-time
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
You need to create a `.env.docker` file with your database credentials. The script will copy `env.docker.example` to `.env.docker` if it doesn't exist, but you **must edit it** with real passwords before the script will work.
|
||||
|
||||
Required variables in `.env.docker`:
|
||||
- `DB_DATABASE` - Database name
|
||||
- `DB_USERNAME` - Database user
|
||||
- `DB_PASSWORD` - Database password
|
||||
- `DB_ROOT_PASSWORD` - Database root password
|
||||
- `TZ` - Timezone (optional, defaults to UTC)
|
||||
|
||||
## Requirements
|
||||
|
||||
- Docker and Docker Compose
|
||||
- Git
|
||||
- Internet connection (to clone the repository)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- Make sure you're running the script from the `domain-monitor-docker` directory
|
||||
- Ensure Docker is running and you have permission to use it
|
||||
- Check that you've edited `.env.docker` with real passwords (not the example values)
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Common scenarios
|
||||
|
||||
**First time setup:**
|
||||
```bash
|
||||
cp env.docker.example .env.docker
|
||||
# Edit .env.docker with real passwords
|
||||
./bootstrap.sh
|
||||
```
|
||||
|
||||
**Daily usage:**
|
||||
```bash
|
||||
# Start (if stopped)
|
||||
docker compose up -d
|
||||
|
||||
# Stop
|
||||
docker compose down
|
||||
```
|
||||
|
||||
**After making changes to the app:**
|
||||
```bash
|
||||
# Restart to pick up changes
|
||||
docker compose restart web
|
||||
```
|
||||
|
||||
**After making changes to Docker config:**
|
||||
```bash
|
||||
# Rebuild containers
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
**Complete reset (WARNING: deletes all data):**
|
||||
```bash
|
||||
docker compose down -v
|
||||
rm -rf app/
|
||||
./bootstrap.sh
|
||||
```
|
||||
Reference in New Issue
Block a user