Giter Club home page Giter Club logo

dnyf-api-group's Introduction

DFNY Group API

Code style: black

Deployment with ElasticBeanstalk

  1. Activate Python virtual env
  2. pip install awsebcli
  3. If your virtual env files are stored in the application folder, add them to .ebignore to prevent them from being uploaded to ElasticBeanstalk.
  4. One-time: eb init -> 1 -> DNYF-API-Group -> N -> Python -> Python 3.8 -> N -> N
  5. Create EB environment and deploy existing code: eb create dnyf-group-api-prod --single
  6. Deploy new code: eb deploy dnyf-group-api-prod
  7. Terminate EB environment: eb terminate

Terminating cleans up all resources associated with the environment.

Development

Install dependencies

pip install -r requirements-dev.txt

Activate pre-commit hooks

pre-commit install

Lint with Flake8

flake8 . --count --statistics

DB Schema

The whole DB schema is re-created on app startup and data re-populated from the sample_data.py file

Running the service

Start up local API and DB

Create a network (one-time):

docker network create dnyfcomposite
docker-compose -f docker-compose.yml up --build

Only using DB with Docker

docker-compose -f docker-compose.yml up -d --build db

To start the API using a local Python environment:

uvicorn src.app:app --reload

Debugging in VSCode

First build and start the containers in debug mode:

docker-compose -f docker-compose.debug.yml up --build

Then in VSCode:

  • Navigate to Run and Debug
  • Select the Python: Remote Attach configuration
  • Start debugging

Without Docker Compose (for reference)

docker volume create mysql
docker volume create mysql_config
docker network create dnyfnet
docker build --tag dnyf-group-api .
docker run --name dnyf-group-api \
    -p 8000:8000 \
    --network dnyfnet \
    -d dnyf-group-api
docker run --rm --name dnyf-group-db \
    --network dnyfnet \
    -v mysql:/var/lib/mysql \
    -v mysql_config:/etc/mysql \
    -e MYSQL_ROOT_PASSWORD=dbuser \
    -e MYSQL_USER=dbuser \
    -e MYSQL_PASSWORD=dbuser \
    -e MYSQL_DATABASE=dnyf-group-db \
    -p 3306:3306 \
    -d mysql:8.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.