-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pasha Radchenko
committed
Mar 31, 2021
1 parent
096508f
commit 2a0164a
Showing
8 changed files
with
135 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,11 @@ MAIL_USE_SSL=True | |
MAIL_USERNAME=<[email protected]> | ||
MAIL_PASSWORD=<account_password> | ||
|
||
SQLALCHEMY_DATABASE_URI="sqlite:///autopsy.db" | ||
SQLALCHEMY_TRACK_MODIFICATIONS=True | ||
DATABASE_HOST=<database_host> | ||
DATABASE_USER=docker | ||
DATABASE_PASSWORD=docker | ||
DATABASE_PORT=5432 | ||
DATABASE_NAME=docker | ||
|
||
SQLALCHEMY_DATABASE_URI="postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}" | ||
SQLALCHEMY_TRACK_MODIFICATIONS=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ venv* | |
.env | ||
__pycache__* | ||
*.db | ||
pgdata/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,9 @@ Autopsy spreads postmortems culture, involves people to learn on the failures. | |
## Features | ||
|
||
* Dashboard shows latest and random postmortems | ||
* Postmortems shows list of postmortems with CRUD | ||
* Postmortems provides lists postmortems with CRU(D) capabilities | ||
* Search performs search operation in Postmortems' names | ||
* Admin page manages all the service's data in Flask-admin way | ||
* Admin manages all the service's data in Flask-admin way | ||
* Users can register, login, update the profile, create support tickets (attaching screenshot), logout and restore their password via email. | ||
|
||
## Roadmap | ||
|
@@ -52,7 +52,7 @@ Autopsy spreads postmortems culture, involves people to learn on the failures. | |
## Requirements | ||
|
||
* python3 | ||
* sqlite* | ||
* PostgreSQL | ||
* SMTP server (for password reset) | ||
|
||
## Installation | ||
|
@@ -88,17 +88,28 @@ cp .env.example .env | |
|MAIL_USE_SSL| True | depends | SMTP server SSL| | ||
|MAIL_USERNAME| <[email protected]> | Yes | Username for no-reply@ account| | ||
|MAIL_PASSWORD| <account_password>| Yes | Password for no-reply account| | ||
|SQLALCHEMY_DATABASE_URI| "sqlite:///autopsy.db"| Yes | Database URI| | ||
|SQLALCHEMY_TRACK_MODIFICATIONS| True | depends| Track DB modification| | ||
|DATABASE_HOST| <database_host> | Yes | Database URI| | ||
|DATABASE_USER| docker | Yes | Database Username| | ||
|DATABASE_PASSWORD| docker | Yes | Database Password| | ||
|DATABASE_PORT| 5432 | depends | Database Port| | ||
|DATABASE_NAME| docker | Yes | Database Name| | ||
|SQLALCHEMY_DATABASE_URI| "postgresql://...."| Yes | Database URI| | ||
|SQLALCHEMY_TRACK_MODIFICATIONS| True | No | Track DB modification| | ||
|
||
#### Install dependencies | ||
``` | ||
pip3 install -r requirements.txt | ||
``` | ||
|
||
#### Apply DB migrations | ||
``` | ||
flask db migrate | ||
flas db upgrade | ||
``` | ||
|
||
#### Run app | ||
``` | ||
ussgi app.ini | ||
uswgi app.ini | ||
``` | ||
|
||
#### Go to | ||
|
@@ -107,6 +118,24 @@ http://localhost:5000/ | |
``` | ||
|
||
|
||
## PostgreSQL development instance | ||
It is available to spin-up PostgreSQL database in container via docker-compose. | ||
``` | ||
cd docker/db | ||
docker-compose up -d | ||
``` | ||
|
||
Database credentials can be found in `docker/db/docker-compose.yml`: | ||
``` | ||
- APP_DB_USER=docker | ||
- APP_DB_PASS=docker | ||
- APP_DB_NAME=docker | ||
``` | ||
|
||
:hankey: Be aware from running the production database instance this ways and other monsters! | ||
|
||
|
||
|
||
## Icon authors: | ||
[DinosoftLabs](https://www.flaticon.com/authors/dinosoftlabs) | ||
[FreePik](https://www.freepik.com/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
set -e | ||
export PGPASSWORD=$POSTGRES_PASSWORD; | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL | ||
CREATE USER $APP_DB_USER WITH PASSWORD '$APP_DB_PASS'; | ||
CREATE DATABASE $APP_DB_NAME; | ||
GRANT ALL PRIVILEGES ON DATABASE $APP_DB_NAME TO $APP_DB_USER; | ||
\connect $APP_DB_NAME $APP_DB_USER | ||
EOSQL | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: '3' | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
healthcheck: | ||
test: [ "CMD", "pg_isready", "-q", "-d", "postgres", "-U", "root" ] | ||
timeout: 45s | ||
interval: 10s | ||
retries: 10 | ||
restart: always | ||
environment: | ||
- POSTGRES_USER=root | ||
- POSTGRES_PASSWORD=password | ||
- APP_DB_USER=docker | ||
- APP_DB_PASS=docker | ||
- APP_DB_NAME=docker | ||
volumes: | ||
- ./db_init:/docker-entrypoint-initdb.d/ | ||
- ./pgdata:/var/lib/postgresql/data | ||
ports: | ||
- 5432:5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Initial migration | ||
Revision ID: ee9c2caf9d31 | ||
Revises: | ||
Create Date: 2021-04-01 00:39:58.002389 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'ee9c2caf9d31' | ||
down_revision = None | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('users', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('user_name', sa.String(length=20), nullable=False), | ||
sa.Column('user_email', sa.String(length=20), nullable=False), | ||
sa.Column('user_password', sa.String(length=100), nullable=False), | ||
sa.Column('user_image', sa.String(length=20), nullable=True), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('user_email') | ||
) | ||
op.create_table('mortems', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('mortem_name', sa.String(length=100), nullable=False), | ||
sa.Column('mortem_url', sa.String(length=16), nullable=False), | ||
sa.Column('mortem_content', sa.Text(), nullable=False), | ||
sa.Column('mortem_created', sa.DateTime(), nullable=False), | ||
sa.Column('mortem_updated', sa.DateTime(), nullable=False), | ||
sa.Column('user_id', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_table('support', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('support_subject', sa.String(length=100), nullable=False), | ||
sa.Column('support_content', sa.Text(), nullable=False), | ||
sa.Column('support_created', sa.DateTime(), nullable=False), | ||
sa.Column('support_attach', sa.LargeBinary(), nullable=True), | ||
sa.Column('user_id', sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('support') | ||
op.drop_table('mortems') | ||
op.drop_table('users') | ||
# ### end Alembic commands ### |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters