Skip to content

Commit 2b0059c

Browse files
Copilotpirus99
andcommitted
Add Docker quick reference guide and update README
Co-authored-by: pirus99 <206077632+pirus99@users.noreply.github.com>
1 parent af7f223 commit 2b0059c

File tree

2 files changed

+217
-3
lines changed

2 files changed

+217
-3
lines changed

DOCKER_QUICK_REFERENCE.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# Docker Production Deployment - Quick Reference
2+
3+
## 🚀 Quick Start Commands
4+
5+
### Initial Deployment
6+
```bash
7+
# 1. Copy and configure environment
8+
cp .env.example .env
9+
# Edit .env with your settings
10+
11+
# 2. Deploy
12+
docker compose up -d --build
13+
14+
# 3. Initialize database and create admin user
15+
docker exec -it join-backend python manage.py migrate
16+
docker exec -it join-backend python manage.py createsuperuser
17+
```
18+
19+
### Using the Helper Script
20+
```bash
21+
./deploy.sh
22+
# Choose option 1 for initial deployment
23+
# Choose option 5 to create superuser
24+
```
25+
26+
## 📍 Access Points
27+
28+
After deployment, access:
29+
- **Frontend**: http://localhost
30+
- **Backend API**: http://localhost/api/
31+
- **Django Admin**: http://localhost/admin/
32+
- **Traefik Dashboard**: http://localhost:8080 (if enabled)
33+
34+
## 🔄 Update Deployment
35+
36+
To update with latest code changes:
37+
38+
```bash
39+
# Method 1: Using helper script
40+
./deploy.sh
41+
# Choose option 2
42+
43+
# Method 2: Manual commands
44+
git pull
45+
docker compose down
46+
docker compose build --no-cache
47+
docker compose up -d
48+
```
49+
50+
## 🔧 Common Operations
51+
52+
### View Logs
53+
```bash
54+
docker compose logs -f # All services
55+
docker compose logs -f backend # Backend only
56+
docker compose logs -f frontend # Frontend only
57+
```
58+
59+
### Stop/Start Services
60+
```bash
61+
docker compose down # Stop all
62+
docker compose up -d # Start all
63+
docker compose restart backend # Restart backend
64+
```
65+
66+
### Database Operations
67+
```bash
68+
# Run migrations
69+
docker exec -it join-backend python manage.py migrate
70+
71+
# Create superuser
72+
docker exec -it join-backend python manage.py createsuperuser
73+
74+
# Access Django shell
75+
docker exec -it join-backend python manage.py shell
76+
77+
# Backup database (SQLite)
78+
docker cp join-backend:/app/data/db.sqlite3 ./backup.sqlite3
79+
```
80+
81+
## 🌐 Production Deployment
82+
83+
### Prerequisites
84+
1. Domain name pointing to your server
85+
2. Open ports 80 and 443 on your firewall
86+
3. Valid email for Let's Encrypt
87+
88+
### Configuration Steps
89+
90+
1. **Update .env file:**
91+
```bash
92+
DOMAIN=yourdomain.com
93+
API_URL=https://yourdomain.com/
94+
DJANGO_SECRET_KEY=<generate-strong-key>
95+
DJANGO_DEBUG=False
96+
DJANGO_ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
97+
DJANGO_CSRF_TRUSTED_ORIGINS=https://yourdomain.com
98+
DJANGO_CORS_ALLOWED_ORIGINS=https://yourdomain.com
99+
ACME_EMAIL=admin@yourdomain.com
100+
```
101+
102+
2. **Enable SSL in docker-compose.yml:**
103+
- Uncomment Let's Encrypt configuration in Traefik section
104+
- Uncomment HTTPS routers for backend and frontend
105+
106+
3. **Deploy:**
107+
```bash
108+
docker compose up -d --build
109+
```
110+
111+
## 🔒 Security Checklist
112+
113+
- [ ] Changed DJANGO_SECRET_KEY to a strong random value
114+
- [ ] Set DJANGO_DEBUG=False in production
115+
- [ ] Configured proper DOMAIN and allowed hosts
116+
- [ ] Enabled SSL/TLS with Let's Encrypt
117+
- [ ] Secured or disabled Traefik dashboard
118+
- [ ] Created strong admin password
119+
- [ ] Configured firewall (allow 80, 443)
120+
- [ ] Set up regular database backups
121+
- [ ] Review and update CORS settings
122+
123+
## 🐛 Troubleshooting
124+
125+
### Container won't start
126+
```bash
127+
docker compose ps # Check status
128+
docker compose logs backend # Check logs
129+
```
130+
131+
### Database issues
132+
```bash
133+
docker exec -it join-backend ls -la /app/data/
134+
docker exec -it join-backend python manage.py showmigrations
135+
```
136+
137+
### Frontend can't reach backend
138+
1. Check API_URL in .env matches your setup
139+
2. Verify CORS settings in Django allow your frontend domain
140+
3. Check Traefik routing in docker compose logs
141+
142+
### SSL certificate issues
143+
```bash
144+
docker compose logs traefik
145+
# Check ACME email is correct
146+
# Verify DNS points to your server
147+
# Ensure ports 80 and 443 are open
148+
```
149+
150+
## 📊 Monitoring
151+
152+
### Check service health
153+
```bash
154+
docker compose ps
155+
docker inspect join-backend --format='{{.State.Health.Status}}'
156+
docker inspect join-frontend --format='{{.State.Health.Status}}'
157+
```
158+
159+
### Resource usage
160+
```bash
161+
docker stats
162+
```
163+
164+
## 🔄 Backup and Restore
165+
166+
### Backup
167+
```bash
168+
# Database
169+
docker cp join-backend:/app/data/db.sqlite3 ./backups/db-$(date +%Y%m%d).sqlite3
170+
171+
# All persistent data
172+
docker run --rm -v join_backend-data:/data -v $(pwd)/backups:/backup alpine tar czf /backup/backend-data-$(date +%Y%m%d).tar.gz -C /data .
173+
```
174+
175+
### Restore
176+
```bash
177+
# Database
178+
docker cp ./backups/db-backup.sqlite3 join-backend:/app/data/db.sqlite3
179+
docker compose restart backend
180+
```
181+
182+
## 📚 Additional Resources
183+
184+
- Full deployment guide: [DOCKER_DEPLOYMENT.md](./DOCKER_DEPLOYMENT.md)
185+
- Development setup: [README.md](./README.md)
186+
- Django documentation: https://docs.djangoproject.com/
187+
- Traefik documentation: https://doc.traefik.io/traefik/
188+
- Docker documentation: https://docs.docker.com/
189+
190+
## 💡 Tips
191+
192+
1. **Use PostgreSQL in Production**: SQLite is fine for development but use PostgreSQL for production
193+
2. **Regular Backups**: Set up automated daily backups
194+
3. **Monitor Logs**: Regularly check logs for errors or suspicious activity
195+
4. **Update Images**: Periodically rebuild with latest base images for security patches
196+
5. **Test Before Deploy**: Test changes in a staging environment first
197+
198+
## 🆘 Getting Help
199+
200+
If you encounter issues:
201+
1. Check logs: `docker compose logs`
202+
2. Verify configuration: `docker compose config`
203+
3. Review health status: `docker compose ps`
204+
4. Check environment variables: `docker compose config | grep -A 20 environment`
205+
5. Open an issue on GitHub with logs and configuration details
206+
207+
---
208+
209+
For detailed information, see [DOCKER_DEPLOYMENT.md](./DOCKER_DEPLOYMENT.md)

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ A modern task management application built with Angular frontend and Django REST
1616

1717
For production deployment with Docker and Traefik reverse proxy:
1818

19-
**📖 [See Docker Deployment Guide](./DOCKER_DEPLOYMENT.md)**
19+
**📖 Documentation:**
20+
- [Quick Reference Guide](./DOCKER_QUICK_REFERENCE.md) - Commands and common operations
21+
- [Full Deployment Guide](./DOCKER_DEPLOYMENT.md) - Complete setup and configuration
2022

21-
Quick start:
23+
**🚀 Quick start:**
2224
```bash
2325
cp .env.example .env
2426
# Edit .env with your configuration
25-
docker-compose up -d
27+
docker compose up -d --build
28+
29+
# Or use the helper script
30+
./deploy.sh
2631
```
2732

2833
### Development Setup 💻

0 commit comments

Comments
 (0)