Coder Social home page Coder Social logo

celo-org / safe-config-service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from safe-global/safe-config-service

1.0 2.0 0.0 806 KB

The safe-config-service is a service that provides configuration information in the context of the Safe clients environment

License: MIT License

Dockerfile 0.71% Python 91.82% Shell 5.63% Smarty 1.85%

safe-config-service's Introduction

safe-config-service

Coverage Status

The safe-config-service is a service that provides configuration information in the context of the Safe clients environment (eg.: list of available safe apps).

Requirements

Setup

The service uses Gunicorn+Nginx as a connection proxy, Django as the main application layer and PostgreSQL as a relational database. All these services are provided with Docker images that can be started using the provided docker-compose (local setup of the services is out of scope for this document).

1. Configuration

The environment variables are set via the .env file. The configuration in .env.example is meant to be production ready. You can copy it and adjust it to your development needs (refer to the file for the explanation about each environment variable).

cp .env.example .env

Some variables are required to be set before running the application: SECRET_KEY, POSTGRES_USER, POSTGRES_PASSWORD. They can be set either locally on your environment or (as a provided example) by uncommenting these variables from the .env file.

2. Service deployment/development

a) with Django

If you wish to develop locally without running an image for the Django service you can do the following:

  1. Install the required Python dependencies. Eg.: With a python virtual environment:
python -m venv venv # creates a virtual environment venv in the local directory
source venv/bin/activate
pip install -r requirements-dev.txt
  1. Export the environment variables of .env to the local shell/environment (some shells might require you to allexport before doing that)
source .env
  1. Run a PostgreSQL database locally. Check your .env to see the user, host and port details which are expected by the Django application. You can also run the bundled Postrges image with Docker.
docker-compose up -d db # postgres will list on port $POSTGRES_PORT
  1. Launch the django app:
python src/manage.py runserver

b) with Docker

  1. Override the docker-compose for local development – by default the Django application won't reload when the codebase changes (restarting the images is required). In order to see our changes without restarting the docker images:
cp docker-compose.override.yml.example docker-compose.override.yml
  1. Set the mount point to /app in the .env file
DOCKER_WEB_VOLUME=.:/app
  1. Launch images
docker-compose up -d

This will start the Nginx proxy server, the safe-config-service and a postgres database. Nginx exposes the port 8080 to the host which is the port used to interact with the application.

Once you have the images up and running the service can be reached via localhost:8080.

  1. ./run script

The ./run script is meant to be used as an utility to interact with the running image. You can execute ./run help to see the available commands.

Example: if you want to issue a command to the image which is running the Django service from your host you can do the following:

./run manage <django-command>

Development Tools

The project uses a variety of tools to make sure that the styling, health and correctness are validated on each change. These tools are available via requirements-dev.txt so to have them available in your virtual environment run:

pip install -r requirements-dev.txt

Testing

Pytest is used to run the available tests in the project. Some of these tests validate the integration with the database so having one running is required. From the project root:

pytest src

Code Style Formatter and Linter

Black, Flake8 and isort are the tools used to validate the style of the changes being pushed. You can refer to the documentation of these tools to check how to integrate them with your editor/IDE.

isort --profile black src # sorts imports according to the isort spec with a profile compatible with Black
black src # formats the files in the src folder using Black
flake8 src # runs flake8 Linter in the src folder

There's also a pre-commit hook that you can install locally via pre-commit so that it formats the files changed on each commit automatically:

pre-commit install # installs commit hook under .git/hooks/pre-commit
git commit # Initially this can take a couple minutes to setup the environment (which will be reused in following commits)

safe-config-service's People

Contributors

fmrsabino avatar dependabot[bot] avatar alvarof2 avatar nambrot avatar mmv08 avatar lvpeschke avatar nicolasbrugneaux avatar

Stargazers

Gábor Mihálcz avatar

Watchers

James Cloos avatar  avatar

safe-config-service's Issues

Bug: $ token balances calculated incorrectly

Copying bug reported by @douglasqian on Telegram

Congrats on launching the new Celo Safe! Looks a lot nicer than the old one 🙂
Noticed a small issue here with value of tokens? Seems like it’s off for both Celo & cUSD

Previously:

Image

Now:

Image

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.