diff --git a/.gitignore b/.gitignore index 87fe0d8..6f9de4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ ### Database file database.db +database_mysql/ ### Python template # Byte-compiled / optimized / DLL files diff --git a/Dockerfile b/Dockerfile index c77976c..95e5a63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.11.0-alpine3.16 COPY ./app /app WORKDIR /app +RUN apk add gcc musl-dev mariadb-connector-c-dev RUN pip3 install -r requirements.txt ENV FLASK_APP=app.py CMD ["gunicorn", "-b", "0.0.0.0:80", "-w", "4", "app:app"] \ No newline at end of file diff --git a/app/app.py b/app/app.py index a26430f..79351ef 100644 --- a/app/app.py +++ b/app/app.py @@ -13,7 +13,11 @@ basedir = os.path.abspath(os.path.dirname(__file__)) app = Flask(__name__) app.config['SECRET_KEY'] = os.environ['SECRET_KEY'] app.config['SQLALCHEMY_DATABASE_URI'] =\ - 'sqlite:///' + os.path.join(basedir, os.environ['SQLITE_DB']) + 'mysql://' + os.environ['MYSQL_USER'] + \ + ':' + os.environ['MYSQL_PASSWORD'] + \ + '@' + os.environ['MYSQL_HOST'] + \ + ':' + os.environ['MYSQL_PORT'] + \ + '/' + os.environ['MYSQL_DB'] app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app) diff --git a/app/init_db.py b/app/init_db.py index ece185e..3e47332 100644 --- a/app/init_db.py +++ b/app/init_db.py @@ -16,49 +16,49 @@ period9 = Period(period=9, periodTime='15:30:00', weekendSchedule=False) task1 = Task(id=1, title="Sexy ERP time", description="Be the dominant partner and fuck so much XD", - created_timestamp='1668278862', due_timestamp='') + created_timestamp=1668278862, due_timestamp=None) task2 = Task(id=2, title="Test task", description="Test", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) task3 = Task(id=3, title="La Nager", description="Francis stuff", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) task4 = Task(id=4, title="Ops/Tech Meeting", description="HEIL GEORGE!", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) task5 = Task(id=5, title="Tech Team Meeting", description="Awkward AF", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) task6 = Task(id=6, title="Write BellScheduler", description="heh", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) task7 = Task(id=7, title="Fap to cunny porn", description="FBI OPEN UP!", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) task8 = Task(id=8, title="Go on vrchat", description="Mmm... virtual headpats!", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) task9 = Task(id=9, title="Brush teeth", description="Ya dont do that more often, ya gross fuck", - created_timestamp='1668278862', - due_timestamp='') + created_timestamp=1668278862, + due_timestamp=None) -event1 = Event(id=1, scheduled_date='11-12-2022', period_num=1, task_id=4) -event2 = Event(id=2, scheduled_date='11-12-2022', period_num=2, task_id=2) -event3 = Event(id=3, scheduled_date='11-12-2022', period_num=3, task_id=5) -event4 = Event(id=4, scheduled_date='11-12-2022', period_num=4, task_id=6) -event5 = Event(id=5, scheduled_date='11-12-2022', period_num=5, task_id=1) -event6 = Event(id=6, scheduled_date='11-12-2022', period_num=6, task_id=3) -event7 = Event(id=7, scheduled_date='11-12-2022', period_num=7, task_id=7) -event8 = Event(id=8, scheduled_date='11-12-2022', period_num=8, task_id=8) -event9 = Event(id=9, scheduled_date='11-12-2022', period_num=9, task_id=9) +event1 = Event(id=1, scheduled_date='03-17-2023', period_num=1, task_id=4) +event2 = Event(id=2, scheduled_date='03-17-2023', period_num=2, task_id=2) +event3 = Event(id=3, scheduled_date='03-17-2023', period_num=3, task_id=5) +event4 = Event(id=4, scheduled_date='03-17-2023', period_num=4, task_id=6) +event5 = Event(id=5, scheduled_date='03-17-2023', period_num=5, task_id=1) +event6 = Event(id=6, scheduled_date='03-17-2023', period_num=6, task_id=3) +event7 = Event(id=7, scheduled_date='03-17-2023', period_num=7, task_id=7) +event8 = Event(id=8, scheduled_date='03-17-2023', period_num=8, task_id=8) +event9 = Event(id=9, scheduled_date='03-17-2023', period_num=9, task_id=9) db.session.add_all([period1, period2, period3, period4, period5, period6, period7, period8, period9]) db.session.add_all([task1, task2, task3, task4, task5, task6, task7, task8, task9]) diff --git a/app/migrations/versions/bf65c9f77f9f_.py b/app/migrations/versions/bf65c9f77f9f_.py deleted file mode 100644 index ed45c69..0000000 --- a/app/migrations/versions/bf65c9f77f9f_.py +++ /dev/null @@ -1,36 +0,0 @@ -"""empty message - -Revision ID: bf65c9f77f9f -Revises: -Create Date: 2022-11-19 09:49:20.565127 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'bf65c9f77f9f' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('user', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('userName', sa.String(length=1000), nullable=True), - sa.Column('email', sa.String(length=100), nullable=True), - sa.Column('password', sa.String(length=100), nullable=True), - sa.Column('realName', sa.String(length=1000), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('email') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('user') - # ### end Alembic commands ### diff --git a/app/migrations/versions/d92ccc005d22_.py b/app/migrations/versions/d92ccc005d22_.py deleted file mode 100644 index fcd70ff..0000000 --- a/app/migrations/versions/d92ccc005d22_.py +++ /dev/null @@ -1,28 +0,0 @@ -"""empty message - -Revision ID: d92ccc005d22 -Revises: bf65c9f77f9f -Create Date: 2022-11-23 20:32:41.868230 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'd92ccc005d22' -down_revision = 'bf65c9f77f9f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('user', sa.Column('timezone', sa.String(length=20), nullable=True, server_default='UTC')) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('user', 'timezone') - # ### end Alembic commands ### diff --git a/app/requirements.txt b/app/requirements.txt index b935201..bd4eaad 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -32,3 +32,6 @@ pytz==2022.6 # Automated tests pytest==7.2.0 pytest-cov==4.0.0 + +# MySQL Package +mysqlclient==2.1.1 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 2ee00c2..c0fc347 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,14 +4,25 @@ services: image: container-registry.infra.dubyatp.xyz/bellscheduler/app:latest-testing restart: always environment: - - SQLITE_DB=database.db + - MYSQL_USER=root + - MYSQL_PASSWORD=notasecuresecretkeyonlyuseforlocaldevelopment + - MYSQL_HOST=db + - MYSQL_PORT=3306 + - MYSQL_DB=bellscheduler - SECRET_KEY=notasecuresecretkeyonlyuseforlocaldevelopment - NODE_NAME=local - POD_NAME=local - FLASK_ENV=development - FLASK_DEBUG=1 - PYTHONUNBUFFERED=1 - volumes: - - ./database.db:/app/database.db ports: - 127.0.0.1:80:80 + db: + image: mariadb:10.7.8-focal + restart: always + environment: + - MARIADB_ROOT_PASSWORD=notasecuresecretkeyonlyuseforlocaldevelopment + volumes: + - ./database_mysql:/var/lib/mysql + ports: + - 127.0.0.1:3306:3306 \ No newline at end of file