3.2 KiB
3.2 KiB
Jobs App - Docker Deployment
This application is a Craigslist job scraper with a Flask web interface.
Quick Start with Docker
Prerequisites
- Docker
- Docker Compose
Deployment
-
Clone the repository and navigate to the project directory
cd /path/to/jobs-app/jobs -
Start the application
docker-compose up --build -d -
Wait for services to be ready (about 30 seconds)
# Check if the app is running curl http://localhost:8000 -
Access the application
- Main app: http://localhost:8000
- Admin interface: http://localhost:8000/admin/users
- Username:
admin - Password:
M11ffpgm.
- Username:
- Scraper interface: http://localhost:8000/scrape-page
Docker Architecture
Services
- jobs-app: Flask application with Gunicorn WSGI server
- mysql: MySQL 8.0 database
Ports
- 8000: Flask application
- 3306: MySQL database (exposed for external access if needed)
Volumes
mysql_data: Persistent MySQL data storage
Configuration
Environment Variables
FLASK_ENV: Set toproductionFLASK_SECRET: Secret key for Flask sessions
Database Configuration
The database configuration is in config/settings.json:
{
"database": {
"mysql": {
"host": "mysql",
"user": "jobs",
"password": "jobdb",
"database": "jobs",
"port": 3306
}
}
}
Useful Commands
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Restart services
docker-compose restart
# Rebuild and restart
docker-compose up --build
# View running containers
docker-compose ps
# Execute commands in the app container
docker-compose exec jobs-app bash
# Check database
docker-compose exec mysql mysql -u jobs -p jobs
Production Considerations
-
Security:
- Change default passwords in
docker-compose.yml - Use environment variables for secrets
- Configure proper firewall rules
- Change default passwords in
-
Scaling:
- Adjust Gunicorn workers in
gunicorn.conf.py - Consider using a reverse proxy (nginx)
- Implement proper logging and monitoring
- Adjust Gunicorn workers in
-
Database:
- Use external MySQL for production
- Configure backups
- Set up connection pooling
-
Networking:
- Use proper domain names
- Configure SSL/TLS
- Set up load balancing if needed
Troubleshooting
Common Issues
- Port conflicts: Change ports in
docker-compose.yml - Database connection: Ensure MySQL container is healthy
- Memory issues: Increase Docker memory limits
- Permission issues: Check file permissions in mounted volumes
Logs
# Application logs
docker-compose logs jobs-app
# Database logs
docker-compose logs mysql
# All logs
docker-compose logs
Development
For development with hot reload:
# Run in development mode
docker-compose -f docker-compose.dev.yml up --build
Create docker-compose.dev.yml:
version: "3.8"
services:
jobs-app:
build: .
ports:
- "8000:8000"
environment:
- FLASK_ENV=development
volumes:
- .:/app
command: ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]