docs: dev environment instructions

This commit is contained in:
realaravinth 2021-04-11 14:08:14 +05:30
parent d1aea6c456
commit 6f0cd2891d
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
2 changed files with 113 additions and 2 deletions

108
DEVELOPMENT.md Normal file
View file

@ -0,0 +1,108 @@
# Development Setup
## Setting up development environment
### Toolchain
You'll have to install before you can start writing code.
1. Install Rust:
Install Cargo(Rust toolchain) using [rustup](https://rustup.rs/) with:
```
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
2. Install Node:
Please refer to [official instructions](https://nodejs.org/en/download/)
3. Install yarn:
`npm install -g yarn`
For more details, refer to [official
instructions](https://yarnpkg.com/getting-started/install)
4. GNU Make:
If you are on Linux, it's probably already installed on your machine.
You can check it's existence by running:
```bash
$ make --version
```
If it's not available, you download it with your package manager or
refer to [official instructions](https://www.gnu.org/software/make/)
### External Dependencies:
### Postgres databse:
The backend requires a Postgres database. We have
compiletime SQL checks so without a database available, you won't be
able to build the project.
I use Postgres in Docker.
1. To install Docker, please refer to [official
instructions](https://docs.docker.com/engine/install/].
2. Create create database user:
```bash
$ docker create --name mcaptcha-postgres \
-e POSTGRES_PASSWORD=password \
-p 5432:5432 postgres
```
3. Start database container:
```bash
$ docker start mcaptcha-postgres
```
4. Set configurations:
```bash
$ cd guard # your copy of https://github.com/mCaptcha/guard
$ echo 'export DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"' > .env
```
**NOTE: Don't use this database for other projects**
5. Run migrations:
This step is only required when migrations are updated. The server
binary has inbuilt migrations manager but that can only be used after
the server is compiled. Since we are trying to compile the server here,
we can't use that.
However, this project ships with a utility to run migrations!
```bash
$ cd guard # your copy of https://github.com/mCaptcha/guard
$ cargo run --bin tests-migrate
```
That's it, you are all set!
## Build commands:
### Compile:
```bash
$ cd guard # your copy of https://github.com/mCaptcha/guard
$ make
```
### Additional commands:
```bash
➜ guard git:(master) ✗ make help
docs - build documentation
run - run developer instance
test - run unit and integration tests
migrate - run database migrations
dev-env - download dependencies
clean - drop builds and environments
coverage - build test coverage in HTML format
xml-coverage - build test coverage in XML for upload to codecov
```

View file

@ -18,7 +18,11 @@
Guard is the back-end component of [mCaptcha](https://mcaptcha.org)
system.
**STATUS: UNUSABLE BUT ACTIVE DEVELOPMENT**
**STATUS: UNUSABLE BUT ACTIVE DEVELOPMENT**
### Development:
See [DEVELOPMENT.md](./DEVELOPMENT.md)
### How to build
@ -48,7 +52,6 @@ Configuration is applied/merged in the following order:
1. `config/default.toml`
2. environment variables.
#### Setup
##### Environment variables: