183 lines
3.6 KiB
Markdown
183 lines
3.6 KiB
Markdown
# Martinhal Contact Management System - Docker Setup
|
|||
|
|
|
||
|
|
## 🐳 Docker Installation (Recommended)
|
||
|
|
|
||
|
|
### Prerequisites
|
||
|
|
- Docker installed: https://docs.docker.com/get-docker/
|
||
|
|
- Docker Compose installed (usually comes with Docker Desktop)
|
||
|
|
|
||
|
|
### Quick Start with Docker
|
||
|
|
|
||
|
|
1. **Make sure you have all files in the same directory:**
|
||
|
|
```
|
||
|
|
martinhal-contacts/
|
||
|
|
├── Dockerfile
|
||
|
|
├── docker-compose.yml
|
||
|
|
├── .dockerignore
|
||
|
|
├── index.html
|
||
|
|
├── credentials.json
|
||
|
|
├── server.js
|
||
|
|
├── package.json
|
||
|
|
└── contacts_data.json (will be created automatically)
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **Build and start the container:**
|
||
|
|
```bash
|
||
|
|
docker-compose up -d
|
||
|
|
```
|
||
|
|
|
||
|
|
3. **Access the application:**
|
||
|
|
Open your browser and go to: `http://localhost:8000`
|
||
|
|
|
||
|
|
4. **Stop the application:**
|
||
|
|
```bash
|
||
|
|
docker-compose down
|
||
|
|
```
|
||
|
|
|
||
|
|
5. **View logs:**
|
||
|
|
```bash
|
||
|
|
docker-compose logs -f
|
||
|
|
```
|
||
|
|
|
||
|
|
### Docker Commands Reference
|
||
|
|
|
||
|
|
**Start the application:**
|
||
|
|
```bash
|
||
|
|
docker-compose up -d
|
||
|
|
```
|
||
|
|
|
||
|
|
**Stop the application:**
|
||
|
|
```bash
|
||
|
|
docker-compose down
|
||
|
|
```
|
||
|
|
|
||
|
|
**Restart the application:**
|
||
|
|
```bash
|
||
|
|
docker-compose restart
|
||
|
|
```
|
||
|
|
|
||
|
|
**View logs:**
|
||
|
|
```bash
|
||
|
|
docker-compose logs -f martinhal-contacts
|
||
|
|
```
|
||
|
|
|
||
|
|
**Rebuild after code changes:**
|
||
|
|
```bash
|
||
|
|
docker-compose down
|
||
|
|
docker-compose build
|
||
|
|
docker-compose up -d
|
||
|
|
```
|
||
|
|
|
||
|
|
**Access container shell:**
|
||
|
|
```bash
|
||
|
|
docker exec -it martinhal-contacts sh
|
||
|
|
```
|
||
|
|
|
||
|
|
## 📦 Data Persistence
|
||
|
|
|
||
|
|
Docker volumes ensure your data persists:
|
||
|
|
- **contacts_data.json** - Your contact database (automatically backed up)
|
||
|
|
- **backups/** - Directory for backup files
|
||
|
|
|
||
|
|
Even if you delete and recreate containers, your data remains safe!
|
||
|
|
|
||
|
|
## 🔄 Updating the Application
|
||
|
|
|
||
|
|
1. Update your files (index.html, server.js, etc.)
|
||
|
|
2. Rebuild and restart:
|
||
|
|
```bash
|
||
|
|
docker-compose down
|
||
|
|
docker-compose build
|
||
|
|
docker-compose up -d
|
||
|
|
```
|
||
|
|
|
||
|
|
## 🔐 Current Passwords
|
||
|
|
|
||
|
|
- **Frontend Password**: `ZaAhdf4h8k79598pHD5H3`
|
||
|
|
- **Backend Username**: `admin`
|
||
|
|
- **Backend Password**: `yt33PdH9WgAGR5z4SFDf6`
|
||
|
|
|
||
|
|
## 🛠 Troubleshooting
|
||
|
|
|
||
|
|
**Port 8000 already in use:**
|
||
|
|
Edit `docker-compose.yml` and change the port mapping:
|
||
|
|
```yaml
|
||
|
|
ports:
|
||
|
|
- "3000:8000" # Access via http://localhost:3000
|
||
|
|
```
|
||
|
|
|
||
|
|
**Container won't start:**
|
||
|
|
```bash
|
||
|
|
docker-compose logs martinhal-contacts
|
||
|
|
```
|
||
|
|
|
||
|
|
**Remove everything and start fresh:**
|
||
|
|
```bash
|
||
|
|
docker-compose down
|
||
|
|
docker system prune -a
|
||
|
|
docker-compose up -d
|
||
|
|
```
|
||
|
|
|
||
|
|
## 📋 Alternative: Manual Setup (No Docker)
|
||
|
|
|
||
|
|
If you don't want to use Docker:
|
||
|
|
|
||
|
|
### Step 1: Install Node.js
|
||
|
|
Download from: https://nodejs.org/
|
||
|
|
|
||
|
|
### Step 2: Install Dependencies
|
||
|
|
```bash
|
||
|
|
npm install
|
||
|
|
```
|
||
|
|
|
||
|
|
### Step 3: Start Server
|
||
|
|
```bash
|
||
|
|
npm start
|
||
|
|
```
|
||
|
|
|
||
|
|
### Step 4: Open Browser
|
||
|
|
```
|
||
|
|
http://localhost:8000
|
||
|
|
```
|
||
|
|
|
||
|
|
## 🎯 Production Deployment
|
||
|
|
|
||
|
|
For production deployment with Docker:
|
||
|
|
|
||
|
|
1. **Use environment variables for sensitive data**
|
||
|
|
2. **Set up HTTPS with reverse proxy (nginx)**
|
||
|
|
3. **Configure automated backups**
|
||
|
|
4. **Set resource limits in docker-compose.yml**
|
||
|
|
|
||
|
|
Example production docker-compose.yml:
|
||
|
|
```yaml
|
||
|
|
version: '3.8'
|
||
|
|
services:
|
||
|
|
martinhal-contacts:
|
||
|
|
build: .
|
||
|
|
container_name: martinhal-contacts
|
||
|
|
ports:
|
||
|
|
- "8000:8000"
|
||
|
|
volumes:
|
||
|
|
- ./contacts_data.json:/app/contacts_data.json
|
||
|
|
- ./backups:/app/backups
|
||
|
|
restart: always
|
||
|
|
environment:
|
||
|
|
- NODE_ENV=production
|
||
|
|
deploy:
|
||
|
|
resources:
|
||
|
|
limits:
|
||
|
|
cpus: '0.5'
|
||
|
|
memory: 512M
|
||
|
|
```
|
||
|
|
|
||
|
|
## ✅ Benefits of Docker
|
||
|
|
|
||
|
|
- ✅ **Consistent environment** - Works the same everywhere
|
||
|
|
- ✅ **Easy deployment** - One command to start
|
||
|
|
- ✅ **Isolated** - Doesn't interfere with other apps
|
||
|
|
- ✅ **Easy updates** - Rebuild and restart
|
||
|
|
- ✅ **Data persistence** - Your data is safe
|
||
|
|
- ✅ **Easy backups** - Just copy the volume
|
||
|
|
|
||
|
|
That's it! Your Martinhal Contact Management System is now running in Docker! 🎉
|