forked from airbnb/knowledge-repo
-
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.
Merge pull request airbnb#685 from airbnb/jg--update_sql_image
[kp2] add docker image for db
- Loading branch information
Showing
10 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
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
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,6 @@ | ||
FLASK_APP=__init__.py | ||
FLASK_DEBUG=1 | ||
DATABASE_URL=postgresql://postgres:postgres@db:5432/knowledge_repo_dev | ||
SQL_HOST=db | ||
SQL_PORT=5432 | ||
DATABASE=postgres |
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
Empty file.
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
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,9 @@ | ||
import os | ||
|
||
|
||
basedir = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
class Config(object): | ||
SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL", "sqlite://") | ||
SQLALCHEMY_TRACK_MODIFICATIONS = False |
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,16 @@ | ||
#!/bin/sh | ||
|
||
if [ "$DATABASE" = "postgres" ] | ||
then | ||
echo "Waiting for postgres..." | ||
|
||
while ! nc -z $SQL_HOST $SQL_PORT; do | ||
sleep 0.1 | ||
done | ||
|
||
echo "PostgreSQL started" | ||
fi | ||
|
||
python manage.py create_db | ||
|
||
exec "$@" |
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,21 @@ | ||
from flask.cli import FlaskGroup | ||
from app import app, db, User | ||
|
||
cli = FlaskGroup(app) | ||
|
||
# docker-compose exec service python manage.py create_db | ||
@cli.command("create_db") | ||
def create_db(): | ||
db.drop_all() | ||
db.create_all() | ||
db.session.commit() | ||
|
||
|
||
@cli.command("seed_db") | ||
def seed_db(): | ||
db.session.add(User(email="[email protected]")) | ||
db.session.commit() | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
black==22.10.0 | ||
flask==2.2.2 | ||
flask-cors==3.0.10 | ||
black==22.10.0 | ||
flask-sqlalchemy==3.0.2 | ||
pylint==2.15.6 | ||
pycodestyle==2.9.1 | ||
pycodestyle==2.9.1 | ||
psycopg2-binary==2.9.4 |