|
| 1 | +--- |
| 2 | +title: "Development Installation" |
| 3 | +linkTitle: "Development Installation" |
| 4 | +weight: 1 |
| 5 | +description: > |
| 6 | + Create a dev install on your laptop |
| 7 | +--- |
| 8 | + |
| 9 | +This guide will help you create a development installation of Elekto on your laptop, for hacking and testing purposes. |
| 10 | + |
| 11 | +## Create a development environment |
| 12 | + |
| 13 | +The application is written in `python` using `flask` and `sqlalchemy`. This repository ships a `requirements.txt` and a `environment.yml` for conda users. |
| 14 | + |
| 15 | +```bash |
| 16 | +# Installation with pip |
| 17 | +pip install -r requirements.txt |
| 18 | + |
| 19 | +# Installation with Conda |
| 20 | +conda env create -f environment.yml && conda activate elekto |
| 21 | +``` |
| 22 | + |
| 23 | +## Setup env variables |
| 24 | + |
| 25 | +The repository has a `.env.example` file which can be used as a template for `.env` file, update the environment file after copying from `.env.example`. |
| 26 | + |
| 27 | +```bash |
| 28 | +# create a new .env file from .env.example |
| 29 | +cp .env.example .env |
| 30 | +``` |
| 31 | + |
| 32 | +Set the basic information about the application in the upper section |
| 33 | +```bash |
| 34 | +APP_NAME=k8s.elections # set the name of the application |
| 35 | +APP_ENV=development # development | production |
| 36 | +APP_KEY= # random secret key (!! important !!) |
| 37 | +APP_DEBUG=True # True | False (production) |
| 38 | +APP_URL=http://localhost # Url where the application is hosted |
| 39 | +APP_PORT=5000 # Default Running port for development |
| 40 | +APP_HOST=localhost # Default Host for developmemt |
| 41 | +``` |
| 42 | + |
| 43 | +Update the database credentials, |
| 44 | +```bash |
| 45 | +DB_CONNECTION=mysql # Mysql is only supported |
| 46 | +DB_HOST=localhost |
| 47 | +DB_PORT=3306 |
| 48 | +DB_DATABASE=name |
| 49 | +DB_USERNAME=user |
| 50 | +DB_PASSWORD=password |
| 51 | +``` |
| 52 | + |
| 53 | +Update the meta repository info |
| 54 | +```bash |
| 55 | +META_REPO=https://github.com/elekto-io/elekto.meta.test.git |
| 56 | +META_DEPLOYMENT=local |
| 57 | +META_PATH=meta |
| 58 | +META_BRANCH=main |
| 59 | +META_SECRET=db5a951969c379e75d0bf15ad6ff8b4a36fbeb02 # same as webhook of the same meta repository |
| 60 | +``` |
| 61 | + |
| 62 | +Update the Oauth info, create an github oauth app if already not created. |
| 63 | +```bash |
| 64 | +GITHUB_REDIRECT=/oauth/github/callback |
| 65 | +GITHUB_CLIENT_ID=d79f002c1d2e3cf20521 |
| 66 | +GITHUB_CLIENT_SECRET=2f64fff6612c46f87314ad5bb81d05c8fd29c561 |
| 67 | +``` |
| 68 | + |
| 69 | +#### Migrate and Sync DB with Meta |
| 70 | + |
| 71 | +The `console` script in the repository is used to perform all the table creations and syncing of the meta. |
| 72 | + |
| 73 | +```bash |
| 74 | +# to migrate the database from command line |
| 75 | +python console --migrate |
| 76 | +``` |
| 77 | + |
| 78 | +To sync the database with the meta files |
| 79 | + |
| 80 | +```bash |
| 81 | +# to the sync the database with the meta |
| 82 | +python console --sync |
| 83 | +``` |
| 84 | + |
| 85 | +#### Run the application Server locally |
| 86 | + |
| 87 | +The flask server will start on `5000` by default but can be changed using `--port` option. |
| 88 | + |
| 89 | +```bash |
| 90 | +# to run the server on default configs |
| 91 | +python console --run |
| 92 | + |
| 93 | +# to change host and port |
| 94 | +python console --port 8080 --host 0.0.0.0 --run |
| 95 | +``` |
0 commit comments