refactor: Use external Docker named volume for data persistence
Changes: - Replace bind mount (./data) with external named volume (nlcc-data) - Volume must be created before first run: docker volume create nlcc-data - Improves portability and follows Docker best practices - Better separation between code and data Benefits: - Data persists across container rebuilds and updates - Easier backup and restore operations - Platform-agnostic (works same on Linux/Windows/macOS) - Managed by Docker's volume system - No permission issues with bind mounts README Updates: - Added volume creation step to installation instructions - Documented volume management commands (create, inspect, backup, restore) - Added backup/restore examples using alpine container - Clarified data persistence behavior Note: Existing deployments using ./data bind mount will need to: 1. Backup existing data: cp -r ./data ./data-backup 2. Create volume: docker volume create nlcc-data 3. Restart container: docker-compose up -d 4. Copy data to volume if needed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
31
README.md
31
README.md
@@ -87,7 +87,12 @@ cd nlcc-itinerary
|
|||||||
- Configure email settings (required for password resets)
|
- Configure email settings (required for password resets)
|
||||||
- Optionally set `ADMIN_USERNAME` and `ADMIN_PASSWORD` (otherwise auto-generated)
|
- Optionally set `ADMIN_USERNAME` and `ADMIN_PASSWORD` (otherwise auto-generated)
|
||||||
|
|
||||||
3. Build and run with Docker Compose:
|
3. Create the external Docker volume for data persistence:
|
||||||
|
```bash
|
||||||
|
docker volume create nlcc-data
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Build and run with Docker Compose:
|
||||||
```bash
|
```bash
|
||||||
docker-compose up -d --build
|
docker-compose up -d --build
|
||||||
```
|
```
|
||||||
@@ -310,7 +315,29 @@ docker exec -it nlcc-itinerary sh
|
|||||||
|
|
||||||
## Data Persistence
|
## Data Persistence
|
||||||
|
|
||||||
The SQLite database is stored in the `./data` directory, which is mounted as a volume in Docker. This ensures sermon data persists across container restarts.
|
The SQLite database is stored in a Docker named volume (`nlcc-data`) which is mounted to `/app/data` in the container. This ensures:
|
||||||
|
- Data persists across container restarts and rebuilds
|
||||||
|
- Better portability across different environments
|
||||||
|
- Easier backup and restore operations
|
||||||
|
- Managed by Docker volume system
|
||||||
|
|
||||||
|
**Volume Management Commands**:
|
||||||
|
```bash
|
||||||
|
# Create the volume (required before first run)
|
||||||
|
docker volume create nlcc-data
|
||||||
|
|
||||||
|
# Inspect volume location and details
|
||||||
|
docker volume inspect nlcc-data
|
||||||
|
|
||||||
|
# Backup the database
|
||||||
|
docker run --rm -v nlcc-data:/data -v $(pwd):/backup alpine tar czf /backup/nlcc-backup.tar.gz -C /data .
|
||||||
|
|
||||||
|
# Restore from backup
|
||||||
|
docker run --rm -v nlcc-data:/data -v $(pwd):/backup alpine tar xzf /backup/nlcc-backup.tar.gz -C /data
|
||||||
|
|
||||||
|
# Remove volume (WARNING: deletes all data!)
|
||||||
|
docker volume rm nlcc-data
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "3002:3000"
|
- "3002:3000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- nlcc-data:/app/data
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- SITE_URL=https://nlcc.rydertech.us
|
- SITE_URL=https://nlcc.rydertech.us
|
||||||
@@ -20,3 +20,7 @@ services:
|
|||||||
- EMAIL_PASSWORD=your-email-password
|
- EMAIL_PASSWORD=your-email-password
|
||||||
- EMAIL_FROM=New Life Christian Church <noreply@example.com>
|
- EMAIL_FROM=New Life Christian Church <noreply@example.com>
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
nlcc-data:
|
||||||
|
external: true
|
||||||
|
|||||||
Reference in New Issue
Block a user