This commit is contained in:
pika 2025-03-31 17:17:48 +02:00
parent af4b75acb4
commit 3036042416
6 changed files with 30 additions and 82 deletions

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
.gitignore
.git
__pycache__

View file

@ -22,4 +22,4 @@ ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Run the application
CMD ["gunicorn", "-w", "4", "-b", ":8000", "app:create_app()"]
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "wsgi:app"]

21
LICENSE
View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2024 Yohei Nakajima
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

15
compose.yml Normal file
View file

@ -0,0 +1,15 @@
# version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
image: homedocs:latest
ports:
- "8000:8000"
volumes:
- ./instance:/app/instance # Persist SQLite database
environment:
- FLASK_ENV=${FLASK_ENV:-production}
restart: unless-stopped

View file

@ -1,53 +0,0 @@
version: '3'
services:
app:
build:
context: ..
dockerfile: config/Dockerfile
command: gunicorn -w 4 -b :8000 "app:create_app()" --access-logfile - --error-logfile -
volumes:
- ../app:/app/app
environment:
- FLASK_APP=app
- FLASK_ENV=production
- DATABASE_URL=postgresql://user:password@db:5432/app_db
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-default_secret_key_change_in_production}
depends_on:
- db
- redis
restart: unless-stopped
nginx:
image: nginx:1.25
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/ssl:/etc/nginx/ssl
depends_on:
- app
restart: unless-stopped
db:
image: postgres:15
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: app_db
volumes:
- pg_data:/var/lib/postgresql/data
restart: unless-stopped
redis:
image: redis:7
volumes:
- redis_data:/data
restart: unless-stopped
volumes:
pg_data:
redis_data:

18
wsgi.py
View file

@ -1,13 +1,17 @@
import os
import secrets
from app import create_app
# Set the environment variable for database URL if needed
# os.environ['DATABASE_URL'] = 'your_production_database_url'
# Get Flask environment
flask_env = os.environ.get("FLASK_ENV", "production")
# Create a production application
app = create_app("production")
# Create the application
app = create_app(flask_env)
# Also provide 'application' for WSGI servers that look for this name
application = app
if __name__ == "__main__":
# This is only used for development
# In production, a WSGI server would import this file
app.run(host="0.0.0.0", port=5000)
# Only for development
debug = flask_env != "production"
app.run(host="0.0.0.0", port=8000, debug=debug)