added docker for production
This commit is contained in:
parent
6d4bf67d5a
commit
f6b3020350
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,2 +1,9 @@
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# Database
|
||||
instance/*.db
|
||||
|
||||
# Docker
|
||||
.env
|
||||
|
||||
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@ -0,0 +1,26 @@
|
||||
# Use official Python runtime as base image
|
||||
FROM python:3.10-alpine
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
ENV FLASK_ENV production
|
||||
|
||||
# Create and set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Expose the application port
|
||||
EXPOSE 5001
|
||||
|
||||
# Run application with Gunicorn
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5001", "--workers", "4", "app:app"]
|
||||
13
README.md
13
README.md
@ -23,6 +23,7 @@ flask init-db
|
||||
|
||||
## Usage
|
||||
|
||||
### Local Development
|
||||
```bash
|
||||
# Start development server
|
||||
flask run --host=0.0.0.0 --port=5001
|
||||
@ -31,8 +32,20 @@ flask run --host=0.0.0.0 --port=5001
|
||||
pkill -f "flask run" && flask run --host=0.0.0.0 --port=5001
|
||||
```
|
||||
|
||||
### Docker Deployment
|
||||
```bash
|
||||
# Build and start container
|
||||
docker-compose up --build
|
||||
|
||||
# For production (detached mode)
|
||||
docker-compose up --build -d
|
||||
```
|
||||
|
||||
The application will be available at `http://localhost:5001`
|
||||
|
||||
### Persisting Data
|
||||
The database will be preserved between container restarts through the `./instance` volume mount.
|
||||
|
||||
## Features
|
||||
- User registration with password confirmation
|
||||
- Secure password hashing
|
||||
|
||||
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@ -0,0 +1,13 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "5001:5001"
|
||||
environment:
|
||||
- FLASK_ENV=production
|
||||
- FLASK_SECRET_KEY=${FLASK_SECRET_KEY:-your-secret-key-here}
|
||||
- SQLALCHEMY_DATABASE_URI=sqlite:////app/instance/users.db
|
||||
volumes:
|
||||
- ./instance:/app/instance
|
||||
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
||||
flask==3.0.0
|
||||
flask-sqlalchemy==3.1.1
|
||||
flask-login==0.6.3
|
||||
werkzeug==3.0.0
|
||||
gunicorn==21.2.0
|
||||
Loading…
x
Reference in New Issue
Block a user