Skip to content

Commit

Permalink
Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuzyashin committed Jun 11, 2020
1 parent 28af467 commit 286803c
Show file tree
Hide file tree
Showing 26 changed files with 1,840 additions and 45 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,16 @@ fabric.properties
.idea
*.db*
app/settings/config.py
.prod.env
.local.env
.prod.full.env
!/app/templates/emails/build/
/docker/redis/redis-data/
/docker/redis/log/
/docker/postgres/
/docker/rabbitmq/data/
/docker/rabbitmq/logs/
/docker/rabbitmq/etc/rabbitmq.conf
!/docker/rabbitmq/etc/enabled_plugins
docker-stack.yml
!/docker/postgres/.gitkeep
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Alexey Kuzyashin

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.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,29 @@ up:
upb:
docker-compose up -d --force-recreate --build

upb-prod-slim:
docker-compose -f docker-compose.prod.slim.yml up -d --force-recreate --build

upb-prod-full:
docker-compose -f docker-compose.prod.full.yml up -d --force-recreate --build

generate-slim-swarm:
docker-compose -f docker-compose.prod.slim.swarm.yml config > docker-stack.yml

generate-full-swarm:
docker-compose -f docker-compose.prod.full.swarm.yml config > docker-stack.yml

deploy-swarm:
docker stack deploy --compose-file docker-stack.yml $(c)

down:
docker-compose down

docker-network:
docker network create --driver overlay webgateway



connect:
docker exec -it $(c) su

Expand Down
9 changes: 8 additions & 1 deletion app/core/init_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from app.core.exceptions import APIException, on_api_exception
from app.settings.config import settings
from app.settings.log import DEFAULT_LOGGING
from app.core.auth.routers.login import router as login_router
from app.applications.users.routes import router as users_router


def configure_logging(log_settings: dict = None):
Expand Down Expand Up @@ -42,4 +44,9 @@ def register_db(app: FastAPI, db_url: str = None):


def register_exceptions(app: FastAPI):
app.add_exception_handler(APIException, on_api_exception)
app.add_exception_handler(APIException, on_api_exception)


def register_routers(app: FastAPI):
app.include_router(login_router, prefix='/api/auth/login')
app.include_router(users_router, prefix='/api/auth/users')
10 changes: 2 additions & 8 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from fastapi import FastAPI
from app.core.auth.routers.login import router as login_router
from app.applications.users.routes import router as users_router
from app.core.exceptions import SettingNotFound
from app.core.init_app import configure_logging, init_middlewares, register_db, register_exceptions

from app.core.init_app import configure_logging, init_middlewares, register_db, register_exceptions, register_routers

try:
from app.settings.config import settings
Expand All @@ -17,11 +14,8 @@
version=settings.VERSION
)


configure_logging()
init_middlewares(app)
register_db(app)
register_exceptions(app)

app.include_router(login_router, prefix='/api/auth/login')
app.include_router(users_router, prefix='/api/auth/users')
register_routers(app)
3 changes: 3 additions & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ email-validator==1.1.1
emails==0.5.15
fastapi==0.55.1
fastapi-users==1.1.1
flower==0.9.4
future==0.18.2
h11==0.9.0
h2==3.2.0
Expand All @@ -33,6 +34,7 @@ httpcore==0.9.1
httptools==0.1.1
httpx==0.13.3
httpx-oauth==0.3.0
humanize==0.5.1
hyperframe==5.2.0
idna==2.9
importlib-metadata==1.6.1
Expand Down Expand Up @@ -69,6 +71,7 @@ six==1.15.0
sniffio==1.1.0
SQLAlchemy==1.3.17
starlette==0.13.2
tornado==6.0.4
tortoise-orm==0.16.13
typing-extensions==3.7.4.2
urllib3==1.25.9
Expand Down
3 changes: 0 additions & 3 deletions app/settings/celery_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from __future__ import absolute_import, unicode_literals
from app.settings.config import settings

broker_url = f'amqp://{settings.RABBIT_LOGIN}:{settings.RABBIT_PASSWORD}@{settings.RABBIT_HOST}:5672'
accept_content = ['json']
enable_utc = False
task_serializer = 'json'
result_backend = f'redis://{settings.REDIS_URL}'
timezone = 'UTC'
task_track_started = True
worker_hijack_root_logger = False
Expand Down
Loading

0 comments on commit 286803c

Please sign in to comment.