add docker containerization

This commit is contained in:
hex
2025-01-18 18:05:21 -08:00
parent f7deb83cb5
commit d504ab5964
3 changed files with 81 additions and 21 deletions

View File

@@ -10,6 +10,7 @@ A delightful recipe management application built with Flask, featuring a cozy, w
- 🎨 Beautiful, responsive design with custom styling - 🎨 Beautiful, responsive design with custom styling
- 🚀 Modern interactions using HTMX - 🚀 Modern interactions using HTMX
- 🌙 Warm, inviting color scheme - 🌙 Warm, inviting color scheme
- 🐳 Docker support for easy deployment
## 🛠️ Technology Stack ## 🛠️ Technology Stack
@@ -18,8 +19,11 @@ A delightful recipe management application built with Flask, featuring a cozy, w
- **Database**: SQLite - **Database**: SQLite
- **Authentication**: Flask-Login - **Authentication**: Flask-Login
- **Styling**: CSS Variables + Modern CSS Features - **Styling**: CSS Variables + Modern CSS Features
- **Deployment**: Docker + Gunicorn
## 🚀 Getting Started ## 🚀 Quick Start with Docker
The easiest way to run Butter Garden is using Docker:
1. Clone the repository: 1. Clone the repository:
```bash ```bash
@@ -27,49 +31,100 @@ A delightful recipe management application built with Flask, featuring a cozy, w
cd ButterGarden cd ButterGarden
``` ```
2. Create and activate a virtual environment: 2. Set up environment variables:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Set up your environment variables:
```bash ```bash
cp .env.example .env cp .env.example .env
# Edit .env with your preferred settings # Edit .env with your preferred settings
``` ```
5. Initialize the database: 3. Start with Docker Compose:
```bash
docker-compose up -d
```
That's it! Visit `http://localhost:5000` to start using Butter Garden.
## 🐳 Docker Details
### Container Features
- Production-grade Gunicorn server
- Automatic health checks
- Persistent SQLite database volume
- Non-root user for security
- Automatic restarts on failure
### Container Management
**Start the container:**
```bash
docker-compose up -d
```
**View logs:**
```bash
docker-compose logs -f
```
**Stop the container:**
```bash
docker-compose down
```
**Rebuild after changes:**
```bash
docker-compose up -d --build
```
### Docker Configuration
- Port: 5000 (configurable in docker-compose.yml)
- Database location: /app/instance (mounted as volume)
- Environment variables: loaded from .env file
- Health check interval: 30 seconds
## 📝 Manual Installation (Without Docker)
If you prefer to run without Docker:
1. Create and activate a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Set up environment variables:
```bash
cp .env.example .env
# Edit .env with your preferred settings
```
4. Initialize the database:
```bash ```bash
python init_db.py python init_db.py
``` ```
6. Run the application: 5. Run the development server:
```bash ```bash
flask run flask run
``` ```
Visit `http://localhost:5000` to start using Butter Garden!
## 🔒 Environment Variables ## 🔒 Environment Variables
Create a `.env` file with the following variables: Required variables in `.env`:
``` ```bash
FLASK_SECRET_KEY=your-secret-key-here FLASK_SECRET_KEY=your-secret-key-here
ADMIN_USERNAME=your-admin-username ADMIN_USERNAME=your-admin-username
ADMIN_PASSWORD=your-secure-password ADMIN_PASSWORD=your-secure-password
FLASK_ENV=development FLASK_ENV=production # or development
``` ```
## 👩‍💻 Development ## 👩‍💻 Development
The application uses modern CSS features and HTMX for enhanced interactivity: The application uses modern CSS features and HTMX for enhanced interactivity:
- CSS Variables for easy theme customization - CSS Variables for easy theme customization
- Responsive design, mobile friendly - Responsive design, mobile friendly
- HTMX for dynamic content updates - HTMX for dynamic content updates

4
app.py
View File

@@ -135,6 +135,10 @@ def delete_recipe_htmx(recipe_id):
db.session.commit() db.session.commit()
return '', 200 return '', 200
@app.route('/health')
def health_check():
return {'status': 'healthy'}, 200
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])
def login(): def login():
if request.method == 'POST': if request.method == 'POST':

View File

@@ -4,3 +4,4 @@ Flask-Login==0.6.3
Flask-WTF==1.2.1 Flask-WTF==1.2.1
Werkzeug==3.0.1 Werkzeug==3.0.1
python-dotenv==1.0.0 python-dotenv==1.0.0
gunicorn==21.2.0