Browse Source

Dockerize the app

feature/delete
Wojciech Kwolek 6 months ago
parent
commit
d2871e86cc
5 changed files with 62 additions and 3 deletions
  1. 14
      Dockerfile
  2. 9
      app/__init__.py
  3. 14
      docker-compose-example.yaml
  4. 4
      entrypoint.sh
  5. 24
      requirements.txt

14
Dockerfile

@ -0,0 +1,14 @@
FROM python:3-slim-buster
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DATABASE_URL sqlite:////data/app.db
COPY ./requirements.txt /app/requirements.txt
RUN apt-get update && \
apt-get install -y gosu && \
rm -rf /var/lib/apt/lists/* && \
pip install -r requirements.txt && pip install gunicorn
COPY . /app/
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:create_app()"]

9
app/__init__.py

@ -1,11 +1,14 @@
import os
from flask import Flask
def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = "raleicuu0Engohh3iageephoh3looge0okupha2omeiph7Nooyeey1tiewooxu7phaeshi0ohlaaThai2eth1oapong5iroo4fieleekaidohmoh1eYahjei9Yi6aema"
app.config['SQLALCHEMY_ECHO'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
app.config['SECRET_KEY'] = os.getenv(
"FLASK_SECRET_KEY", "raleicuu0Engohh3iageephoh3looge0okupha2omeiph7Nooyeey1tiewooxu7phaeshi0ohlaaThai2eth1oapong5iroo4fieleekaidohmoh1eYahjei9Yi6aema")
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv(
"DATABASE_URL", "sqlite:///app.db")
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
from . import db
db.init_app(app)

14
docker-compose-example.yaml

@ -0,0 +1,14 @@
version: '3'
volumes:
data:
services:
app:
build: .
volumes:
- data:/data
ports:
- 3103:5000
environment:
- FLASK_SECRET_KEY="changeme"

4
entrypoint.sh

@ -0,0 +1,4 @@
#!/bin/bash
chown -R www-data:www-data /data
flask db upgrade && gosu www-data "$@"

24
requirements.txt

@ -0,0 +1,24 @@
alembic==1.4.2
autopep8==1.5.4
bcrypt==3.2.0
cffi==1.14.2
click==7.1.2
Flask==1.1.2
Flask-Bcrypt==0.7.1
Flask-Login==0.5.0
Flask-Migrate==2.5.3
Flask-SQLAlchemy==2.4.4
Flask-WTF==0.14.3
itsdangerous==1.1.0
Jinja2==2.11.2
Mako==1.1.3
MarkupSafe==1.1.1
pycodestyle==2.6.0
pycparser==2.20
python-dateutil==2.8.1
python-editor==1.0.4
six==1.15.0
SQLAlchemy==1.3.19
toml==0.10.1
Werkzeug==1.0.1
WTForms==2.3.3
Loading…
Cancel
Save