Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
orihomie committed Sep 9, 2020
1 parent 490c554 commit 70045ca
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,88 @@ This stack can be adjusted and used with several deployment options that are com

Please refer to <a href="https://dockerswarm.rocks" target="_blank">DockerSwarm.rocks</a> to see how to deploy such a cluster in 20 minutes.

## How to debug

### Backend

An easiest way to do that is to launch your service in docker container along with postgre and all its dependencies to get rid of dependencies installation problems so if you'd like to debug backend separately (like for adding your custom routes) you'll need to do following steps to get things work

1. You'll need to have built backend image locally, so do

> docker build -f backend.dockerfile . -t backend
2. Now you need to have postgres container, so put somewhere on your machine this and call it 'stack.yml':
```yml
version: '3.1'
services:

db:
image: postgres
restart: always
environment:
POSTGRES_SERVER: example
POSTGRES_USER: example
POSTGRES_PASSWORD: example
POSTGRES_DB: example
ports:
- 5432:5432
networks:
- default

adminer:
image: adminer
restart: always
ports:
- 8080:8080
networks:
- default

backend:
image: backend
ports:
- 10088:80
links:
- db
networks:
- default
```

3. Now set environment variables at your host machine

```
POSTGRES_USER = "example"
POSTGRES_PASSWORD = "example"
POSTGRES_SERVER = "db:5432"
POSTGRES_DB = "example"
```

4. Next go to backend/app/app/core/config.py and pass settings:

```py
kwargs = {
'SERVER_NAME': '',
'SERVER_HOST': 'http://127.0.0.1:10088',

'PROJECT_NAME': 'CookieBack',

...

'POSTGRES_SERVER': 'example',
'POSTGRES_USER': 'example',
'POSTGRES_PASSWORD': 'example',
'POSTGRES_DB': 'example',
'SQLALCHEMY_DATABASE_URI': 'postgres://example:example@db/example',
...}

settings = Settings(**kwargs)
```

5. You need to rebuild backend image and compose up your stack, so you do:

> docker build -f backend.dockerfile . -t backend && docker-compose -f stack.yml up --force-recreate --build
6. Check if swagger there http://0.0.0.0:10088/docs - backend must be running.

## More details

After using this generator, your new project (the directory created) will contain an extensive `README.md` with instructions for development, deployment, etc. You can pre-read [the project `README.md` template here too](./{{cookiecutter.project_slug}}/README.md).
Expand Down

0 comments on commit 70045ca

Please sign in to comment.