feat: add Docker migration service
This commit is contained in:
31
README.md
31
README.md
@@ -10,6 +10,7 @@ A web application to manage pet pictures from subscribers. Built with Flask, SQL
|
||||
- Modern, responsive UI using Tailwind CSS
|
||||
- Click to view full-size images
|
||||
- Download original images
|
||||
- Add descriptions to pet pictures
|
||||
|
||||
## Setup
|
||||
|
||||
@@ -29,6 +30,26 @@ python main.py
|
||||
|
||||
The application will be available at `http://localhost:5000`
|
||||
|
||||
### Database Migration
|
||||
|
||||
#### Local Migration
|
||||
|
||||
If you have an existing database and want to add the description field:
|
||||
|
||||
```bash
|
||||
python migrate.py
|
||||
```
|
||||
|
||||
#### Docker Migration
|
||||
|
||||
To run the migration in Docker:
|
||||
|
||||
```bash
|
||||
docker compose --profile migrate up migrate
|
||||
```
|
||||
|
||||
This will safely add the description column to your existing database without affecting existing data.
|
||||
|
||||
### Docker Deployment
|
||||
|
||||
#### Using Docker Compose (Recommended)
|
||||
@@ -73,14 +94,16 @@ The application will be available at `http://localhost:54321`
|
||||
1. Visit the homepage to see all uploaded pet pictures
|
||||
2. Click "Upload New" to add a new pet picture
|
||||
3. Fill in the subscriber name and select a picture
|
||||
4. View uploaded pictures on the homepage
|
||||
5. Click on any picture to view it in full size
|
||||
6. Use the "Download Original" button to download the original file
|
||||
7. Mark pictures as posted using the "Mark as Posted" button
|
||||
4. Add an optional description for the pet picture
|
||||
5. View uploaded pictures on the homepage
|
||||
6. Click on any picture to view it in full size
|
||||
7. Use the "Download Original" button to download the original file
|
||||
8. Mark pictures as posted using the "Mark as Posted" button
|
||||
|
||||
## File Structure
|
||||
|
||||
- `main.py` - Main Flask application
|
||||
- `migrate.py` - Database migration script
|
||||
- `templates/` - Jinja2 templates
|
||||
- `base.html` - Base template with common layout
|
||||
- `index.html` - Homepage with picture grid
|
||||
|
||||
@@ -11,11 +11,31 @@ services:
|
||||
environment:
|
||||
- FLASK_APP=main.py
|
||||
- FLASK_ENV=production
|
||||
- GUNICORN_CMD_ARGS=--workers=4 --bind=0.0.0.0:5000 --timeout=120
|
||||
- GUNICORN_CMD_ARGS=--workers=4 --bind=0.0.0.0:5000 --timeout=120 --keep-alive=5 --worker-class=sync --worker-connections=1000 --max-requests=1000 --max-requests-jitter=50
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5000"]
|
||||
test:
|
||||
[
|
||||
"CMD",
|
||||
"curl",
|
||||
"-f",
|
||||
"http://localhost:5000/",
|
||||
"--connect-timeout",
|
||||
"5",
|
||||
"--retry",
|
||||
"3",
|
||||
"--retry-delay",
|
||||
"5",
|
||||
]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
migrate:
|
||||
build: .
|
||||
volumes:
|
||||
- ./pet_pictures.db:/app/pet_pictures.db
|
||||
command: python migrate.py
|
||||
profiles:
|
||||
- migrate
|
||||
|
||||
Reference in New Issue
Block a user