Giter Club home page Giter Club logo

struct-drf-celery-docker's Introduction

Struct source DRF + Celery + Redis in Docker-compose

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

This is instructions based on OS: Ubuntu v18.04

  • Docker version >= 19.03.5 . sudo apt-get install docker
  • Docker-compose version >= 1.25.4 . sudo apt-get install docker-compose

Installing

Prepare variable environment

  1. Rename the file .env.sample to .env
  2. Update value of variable in file .env

Run docker-compose

docker-compose up --build -d
  1. HealthCheck Acccess to: http://localhost:8000/api/v1/healthCheck will be received response as
{
  "description": "the service is healthy"
}
  1. Test Celery: Acccess to: http://localhost:8000/api/v1/testCelery will be received response as
{
  "task_id": "f14e3eb8-b496-4705-b417-5620308d4ab7",
  "status": "ok"
}
  1. Test S3 Config: Acccess to: http://localhost:8000/api/v1/testS3Config will be received response as

{
  "status": "Ok",
  "buckets": [
    "bucket-name-1",
    "bucket-name-2"
  ]
}

Running the tests

Run Unit test & Performance test

1. docker exec -it <folder-name>_app_1 bash # Attach Shell to container web
2. pipenv shell # Active environment
3. python manage.py test # Run test case

Run Coverage Test

1. docker exec -it <folder-name>_app_1 bash # Attach Shell to container web
2. pipenv shell # Active environment
3. coverage run manage.py test # Run test case by coverage
(Optional: View By HTML) coverage html
(Optional: View Report) coverage report

Deployment

Updating ...

Contributing

Pre-setup for contributing

  1. Install black and isort
pipenv shell
pip3 install black
pip3 install isort
pip3 install flake8
  1. (Optional) IDE Visual Studio Code (N.01) 1.1 Create folder .vscode and create file .settings.json in that. > .vscode/.settings.json 1.2 Add the script below and save
{
  "python.linting.enabled": true,
  "python.linting.flake8Enabled": true,
  "python.linting.flake8Args": ["--ignore=E501,W503"],
  "python.formatting.provider": "black",
  "python.sortImports.args": ["--profile", "black"],
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[python]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  },
  "python.formatting.blackArgs": [
    "--skip-string-normalization",
    "--skip-magic-trailing-comma"
  ]
}

Install new package

1. rm -rf Pipfile.lock # Remove Pipfile.lock
2 (Option with docker) docker exec -it sap_app_1 bash # Attach Shell to container web
3. pipenv shell # Active environment
4. pipenv install <package-name> # Install new package
5. pipenv install # Generate new Pipfile.lock

Before push code to repository

(*) Run command bellow

1. pipenv shell
2. isort . # format sort import library
3. black . # format code
4. flake8 --ignore=E501,F401,W503 . # Check issue and fix if have.

(If use IDE Visual Studio Code and configured (N.01) can skip step 2 and step 3)

Versioning

0.1.0

Authors

License

struct-drf-celery-docker's People

Contributors

jimmi2051 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

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.