Git Product home page Git Product logo

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 and chain metadata).

Requirements

Setup

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

Important: 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. Running the service image

The project relies on nginx and postgres services. If you are running this locally this is already set in the docker-compose.yml file:

docker compose up

The service will then be available under localhost:$NGINX_HOST_PORT.

3. Create an admin user

The admin interface of the service is available under http://<host>:<NGINX_HOST_PORT>/admin but you need to have a an admin registered before you are able to access the panel.

To create an admin user (assuming that the name of the web container is safe-config-service-web-1):

docker exec -it safe-config-service-web-1 /bin/bash
python src/manage.py createsuperuser

And then just follow the prompts in order to create an admin user. Further users (admin or not) can be created from the admin interface itself.

Development

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 be listening on port $POSTGRES_PORT
  1. Launch the service:
python src/manage.py runserver

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 (you can have one running in the background with docker compose up -d db). 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

dependabot[bot] avatar fmrsabino avatar gmonty030 avatar inomurko avatar jpalvarezl avatar mmv08 avatar rmeissner avatar uxio0 avatar

Forkers

dogetoools

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.