Skip to content

Installation and Deployment

Reqirements

For local deployment: - docker

For local debugging: - docker - python 3.11 with package pipenv - dbeaver - PyCharm or VSCode

Before install you need install docker app on your machine

Installations by steps

1. Clone sources from github

Clone this main repository to local machine

git clone https://github.com/Stretch-com/api-stretch.git
Clone submodules
cd api-stretch
git submodule init
git submodule update

2. Create security keys

For authorization, we use JWT with signature (RS256). Any external application can check access token by our public key.

For creating you can use openssl tool:

mkdir cert && cd cert
openssl genrsa -out stretch.pem 2048
openssl rsa -in stretch.pem -pubout -outform PEM -out stretch.crt
cd ..
or for testing use online service: - Go to https://jwt.io/ - Select algorithm RS256 - From decoder side copy public key and private key to files

3. Setup environments variables:

Project contain environments variables (if needed).

For easy setup copy env-dist to .env:

cp env-dist .env
and env.common-dist to .env.common
cp env.common-dist .env.common

After that setup environment variables if needed:

JWT settings
  • JWT_PRIVATE_KEY: path to private key file (default: /cert/stretch.pem)
  • JWT_PUBLIC_KEY: path to public key file (default: /cert/stretch.crt)
  • ACCESS_TOKEN_EXPIRE_MINUTES: expire time for access token (default: 10)
  • STRETCH_SECRET_KEY: secret key salt for hash generation
Database settings
  • DB_HOST: database hostname (default: localhost)
  • DB_PORT: database port (default: 5432)
  • DB_NAME: database name (default: stretch)
  • DB_USER: database user (default: stretch)
  • DB_PASSWORD: database password
API route settings
  • STRETCH_API_PREFIX: api prefix (default: /api/v1)
  • STRETCH_API_URL: api base url (default: http://localhost)
Twilio settings
  • TWILIO_ACCOUNT_SID: twilio sid
  • TWILIO_AUTH_TOKEN: twilio auth token
  • TWILIO_SERVICE_TOKEN: twilio service token
  • TWILIO_TEMPLATE_TOKEN: twilio template for sms (prefer: HJca6f305ff106ab052a1b16caf180586f)
Payment settings
  • PAYMENT_STRIPE_PUBLIC_KEY: stripe payment key
  • PAYMENT_STRIPE_SECRET_KEY: stripe secret key

Map

  • STRETCH_MAPTILER_KEY: maptiler.com api key for access to api
  • MAPBOX_PUBLIC_TOKEN: mapbox.com api key for mapbox

Google credentials for access to gmail and firebase api

  • GOOGLE_CREDENTIALS_FILE: google credentials file (default: /cert/google-auth.json)
  • GOOGLE_CREDENTIALS_TOKEN_FILE: google access token file (default: /cert/token-gmail.json)

App settings

  • STRETCH_AUTO_APPROVE: auto approve all resources and services if true (default: false)

4. Building frontend

For building ReactJS project we use also docker.

Setup .env vars - VITE_CLIENT_ID= - VITE_CLIENT_SECRET= - VITE_BE_URL=http://localhost/api/v1/ - VITE_WS_URL=ws://localhost/api/v1/ - VITE_HASH="0000000" - VITE_MAPBOX_TOKEN=

For building write command:

docker compose run frontend npm run build

5. Running

Configure database with demo data

docker compose run auth python install.py

For run project just write:

docker compose up