Use Docker for local development environment
- Update README and CLAUDE.md with Docker-based dev workflow - Add Dockerfile for containerized deployment - Add gunicorn to requirements.txt - Dev uses volume mount for live code reloading Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
23
CLAUDE.md
23
CLAUDE.md
@@ -17,7 +17,7 @@ Kebuu is a spending tracker web app built with Flask. Currently in early develop
|
|||||||
- **Backend**: Flask 3.0, SQLAlchemy, Flask-Login
|
- **Backend**: Flask 3.0, SQLAlchemy, Flask-Login
|
||||||
- **Auth**: bcrypt password hashing, Altcha CAPTCHA (self-hosted)
|
- **Auth**: bcrypt password hashing, Altcha CAPTCHA (self-hosted)
|
||||||
- **Forms**: Flask-WTF with CSRF protection
|
- **Forms**: Flask-WTF with CSRF protection
|
||||||
- **Server**: Gunicorn (production), Flask dev server (local)
|
- **Server**: Docker + Gunicorn (dev and prod)
|
||||||
- **Database**: SQLite (dev), PostgreSQL (prod)
|
- **Database**: SQLite (dev), PostgreSQL (prod)
|
||||||
|
|
||||||
## Directory Structure
|
## Directory Structure
|
||||||
@@ -42,23 +42,24 @@ src/
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
### Local Development
|
### Build
|
||||||
```bash
|
|
||||||
cd src
|
|
||||||
pip install -r requirements.txt
|
|
||||||
python app.py
|
|
||||||
```
|
|
||||||
|
|
||||||
### Docker
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t kebuu .
|
docker build -t kebuu .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development
|
||||||
|
```bash
|
||||||
|
docker run -p 5000:5000 --env-file .env.dev -v $(pwd)/src:/app kebuu
|
||||||
|
```
|
||||||
|
|
||||||
|
### Production
|
||||||
|
```bash
|
||||||
docker run -p 5000:5000 --env-file .env.prod kebuu
|
docker run -p 5000:5000 --env-file .env.prod kebuu
|
||||||
```
|
```
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
```bash
|
```bash
|
||||||
cd src
|
docker run --env-file .env.dev kebuu python -m unittest discover
|
||||||
python -m unittest discover
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|||||||
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
gcc \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy requirements first for better caching
|
||||||
|
COPY src/requirements.txt .
|
||||||
|
|
||||||
|
# Install Python dependencies
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# Copy application code
|
||||||
|
COPY src/ .
|
||||||
|
|
||||||
|
# Create non-root user for security
|
||||||
|
RUN useradd --create-home appuser && chown -R appuser:appuser /app
|
||||||
|
USER appuser
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
# Default to production; override with --env-file at runtime
|
||||||
|
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:create_app()"]
|
||||||
22
README.md
22
README.md
@@ -4,14 +4,7 @@ A spending tracker web application built with Flask.
|
|||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
### 1. Install Dependencies
|
### 1. Create Environment Files
|
||||||
|
|
||||||
```bash
|
|
||||||
cd src
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Create Environment Files
|
|
||||||
|
|
||||||
Copy the example file and configure for your environment:
|
Copy the example file and configure for your environment:
|
||||||
|
|
||||||
@@ -33,17 +26,22 @@ Generate secure keys with:
|
|||||||
python -c "import secrets; print(secrets.token_hex(32))"
|
python -c "import secrets; print(secrets.token_hex(32))"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 2. Build Docker Image
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t kebuu .
|
||||||
|
```
|
||||||
|
|
||||||
### 3. Run the Application
|
### 3. Run the Application
|
||||||
|
|
||||||
**Development:**
|
**Development:**
|
||||||
```bash
|
```bash
|
||||||
cd src
|
docker run -p 5000:5000 --env-file .env.dev -v $(pwd)/src:/app kebuu
|
||||||
python app.py
|
|
||||||
```
|
```
|
||||||
|
The volume mount (`-v`) enables live code reloading during development.
|
||||||
|
|
||||||
**Production (Docker):**
|
**Production:**
|
||||||
```bash
|
```bash
|
||||||
docker build -t kebuu .
|
|
||||||
docker run -p 5000:5000 --env-file .env.prod kebuu
|
docker run -p 5000:5000 --env-file .env.prod kebuu
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ bcrypt==4.1.2
|
|||||||
python-dotenv==1.0.0
|
python-dotenv==1.0.0
|
||||||
email-validator==2.1.0
|
email-validator==2.1.0
|
||||||
altcha==0.1.2
|
altcha==0.1.2
|
||||||
|
gunicorn==21.2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user