Fakultas Ilmu Komputer UI

Commit 7446f6f1 authored by Azhar Difa Arnanda's avatar Azhar Difa Arnanda 💬
Browse files

Merge branch 'hotfix' into 'dev'

Merubah readme.md

See merge request !6
parents 92450e4b 9adbbe63
Pipeline #67991 passed with stages
in 2 minutes and 17 seconds
# Home Industry API # Home Industry API
[![pipeline status](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/badges/master/pipeline.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/commits/master) [![pipeline status](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/sosial/pilar/pilar-backend/badges/dev/pipeline.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/sosial/pilar/pilar-backend/-/commits/dev)
[![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/badges/master/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-tpu-online/post-rpl-backend/commits/master) [![coverage report](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/sosial/pilar/pilar-backend/badges/dev/coverage.svg)](https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/sosial/pilar/pilar-backend/-/commits/dev)
## Table of Contents
## Table of Contents
- [Environment Variables](#environment-variables)
- [Environment Variables](#environment-variables) - [Local](#local)
- [Local](#local) - [CI](#ci)
- [CI](#ci) - [Staging](#staging)
- [Staging](#staging) - [Production](#production)
- [Production](#production) - [Local Configuration](#local-configuration)
- [Local Configuration](#local-configuration) - [Deployed API URLs](#deployed-api-urls)
- [Deployed API URLs](#deployed-api-urls) - [API Documentation](#api-documentation)
- [API Documentation](#api-documentation)
## Environment Variables
## Environment Variables
### Local
### Local
Key | Required | Example
Key | Required | Example --- | --- | ---
--- | --- | --- `DATABASE_HOST` | yes | `127.0.0.1`
`DATABASE_HOST` | yes | `127.0.0.1` `DATABASE_NAME` | yes | `home_industry`
`DATABASE_NAME` | yes | `home_industry` `DATABASE_PASSWORD` | yes | `postgres`
`DATABASE_PASSWORD` | yes | `postgres` `DATABASE_PORT` | yes | `5432`
`DATABASE_PORT` | yes | `5432` `DATABASE_USER` | yes | `postgres`
`DATABASE_USER` | yes | `postgres` `DEBUG` | no | `True`
`DEBUG` | no | `True` `DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.local`
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.local` `SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
### CI
### CI
Key | Required | Example
Key | Required | Example --- | --- | ---
--- | --- | --- `DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.ci`
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.ci` `SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
### Staging
### Staging
Key | Required | Example
Key | Required | Example --- | --- | ---
--- | --- | --- `AWS_ACCESS_KEY_ID` | yes | `AKIAIOSFODNN7EXAMPLE`
`AWS_ACCESS_KEY_ID` | yes | `AKIAIOSFODNN7EXAMPLE` `AWS_REGION_NAME` | yes | `ap-southeast-1`
`AWS_REGION_NAME` | yes | `ap-southeast-1` `AWS_SECRET_ACCESS_KEY` | yes | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
`AWS_SECRET_ACCESS_KEY` | yes | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` `AWS_STORAGE_BUCKET_NAME` | yes | `homeindustry-api`
`AWS_STORAGE_BUCKET_NAME` | yes | `homeindustry-api` `DATABASE_URL` | yes | `postgres://postgres:postgres@ec2-117-21-174-214.compute-1.amazonaws.com:5432/home_industry`
`DATABASE_URL` | yes | `postgres://postgres:postgres@ec2-117-21-174-214.compute-1.amazonaws.com:5432/home_industry` `DEBUG` | no | `True`
`DEBUG` | no | `True` `DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.staging`
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.staging` `HOME_INDUSTRY_ADMIN_SITE_URL` | no | `https://homeindustry.com/admin/`
`HOME_INDUSTRY_ADMIN_SITE_URL` | no | `https://homeindustry.com/admin/` `HOME_INDUSTRY_ADMIN_SITE_USER_PATH` | no | `users/`
`HOME_INDUSTRY_ADMIN_SITE_USER_PATH` | no | `users/` `HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH` | no | `products/`
`HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH` | no | `products/` `HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH` | no | `transactions/`
`HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH` | no | `transactions/` `HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH` | no | `programs/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH` | no | `programs/` `HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH` | no | `program-donations/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH` | no | `program-donations/` `SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
### Production
### Production
Key | Required | Example
Key | Required | Example --- | --- | ---
--- | --- | --- `AWS_ACCESS_KEY_ID` | yes | `AKIAIOSFODNN7EXAMPLE`
`AWS_ACCESS_KEY_ID` | yes | `AKIAIOSFODNN7EXAMPLE` `AWS_REGION_NAME` | yes | `ap-southeast-1`
`AWS_REGION_NAME` | yes | `ap-southeast-1` `AWS_SECRET_ACCESS_KEY` | yes | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
`AWS_SECRET_ACCESS_KEY` | yes | `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY` `AWS_STORAGE_BUCKET_NAME` | yes | `homeindustry-api`
`AWS_STORAGE_BUCKET_NAME` | yes | `homeindustry-api` `DATABASE_HOST` | yes | `127.0.0.1`
`DATABASE_HOST` | yes | `127.0.0.1` `DATABASE_NAME` | yes | `home_industry`
`DATABASE_NAME` | yes | `home_industry` `DATABASE_PASSWORD` | yes | `postgres`
`DATABASE_PASSWORD` | yes | `postgres` `DATABASE_PORT` | yes | `5432`
`DATABASE_PORT` | yes | `5432` `DATABASE_USER` | yes | `postgres`
`DATABASE_USER` | yes | `postgres` `DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.production`
`DJANGO_SETTINGS_MODULE` | yes | `home_industry.settings.production` `HOME_INDUSTRY_ADMIN_SITE_URL` | no | `https://homeindustry.com/admin/`
`HOME_INDUSTRY_ADMIN_SITE_URL` | no | `https://homeindustry.com/admin/` `HOME_INDUSTRY_ADMIN_SITE_USER_PATH` | no | `users/`
`HOME_INDUSTRY_ADMIN_SITE_USER_PATH` | no | `users/` `HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH` | no | `products/`
`HOME_INDUSTRY_ADMIN_SITE_PRODUCT_PATH` | no | `products/` `HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH` | no | `transactions/`
`HOME_INDUSTRY_ADMIN_SITE_TRANSACTION_PATH` | no | `transactions/` `HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH` | no | `programs/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_PATH` | no | `programs/` `HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH` | no | `program-donations/`
`HOME_INDUSTRY_ADMIN_SITE_PROGRAM_DONATION_PATH` | no | `program-donations/` `SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
`SECRET_KEY` | yes | `7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u`
## Local Configuration
## Local Configuration
- Create environment variables in root folder (change as needed)
- Create environment variables in root folder (change as needed)
Filename: `.env` Filename: `.env`
```bash ```bash
DATABASE_HOST=db DATABASE_HOST=db
DATABASE_NAME=home_industry DATABASE_NAME=home_industry
DATABASE_PASSWORD=postgres DATABASE_PASSWORD=postgres
DATABASE_PORT=5432 DATABASE_PORT=5432
DATABASE_USER=postgres DATABASE_USER=postgres
DJANGO_SETTINGS_MODULE=home_industry.settings.local DJANGO_SETTINGS_MODULE=home_industry.settings.local
SECRET_KEY=7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u SECRET_KEY=7&s33ax$lxxzti1)0y=8#tu!$7bdy)p$1@kn06tp&8x8i9#h2u
ALLOWED_HOST=0.0.0.0 ALLOWED_HOST=0.0.0.0
``` ```
- Run docker-compose - Change `wait-for-it.sh` permission
```bash ```bash
$ sudo docker-compose up $ chmod +x wait-for-it.sh
``` ```
- In another terminal, check running container - Run docker-compose
```bash ```bash
$ docker ps $ sudo docker-compose up
``` ```
- Run collectstatic - In another terminal, check running container
```bash ```bash
$ docker exec -it <web-container-id> python manage.py collectstatic --noinput $ docker ps
``` ```
- Create or update API configuration in database - Run collectstatic
```bash ```bash
$ docker exec -it <web-container-id> python manage.py createorupdateapiconfig $ docker exec -it <web-container-id> python manage.py collectstatic --noinput
``` ```
- Access database - Create superuser
```bash ```bash
$ docker exec -it <postgres-container-id> psql -U postgres -d home_industry -h db $ docker exec -it <web-container-id> python manage.py createsuperuser
``` ```
- Create or update API configuration in database
## Deployed API URLs ```bash
$ docker exec -it <web-container-id> python manage.py createorupdateapiconfig
- Development: [https://pilar-be-dev.cs.ui.ac.id](https://pilar-be-dev.cs.ui.ac.id) ```
- Staging: [https://pilar-be-staging.cs.ui.ac.id](https://pilar-be-staging.cs.ui.ac.id) - Generate dummy data from seeders for database
- Production: [https://pilar-be.cs.ui.ac.id](https://pilar-be.cs.ui.ac.id) ```bash
$ docker exec -it <web-container-id> python manage.py createdummydata
## API Documentation ```
- Access database
[https://pilar-be-dev.cs.ui.ac.id/docs/](https://pilar-be-dev.cs.ui.ac.id/docs/) ```bash
$ docker exec -it <postgres-container-id> psql -U postgres -d home_industry -h db
```
## Deployed API URLs
- Development: [https://pilar-be-dev.cs.ui.ac.id](https://pilar-be-dev.cs.ui.ac.id)
- Staging: [https://pilar-be-staging.cs.ui.ac.id](https://pilar-be-staging.cs.ui.ac.id)
- Production: [https://pilar-be.cs.ui.ac.id](https://pilar-be.cs.ui.ac.id)
## API Documentation
[https://pilar-be-dev.cs.ui.ac.id/docs/](https://pilar-be-dev.cs.ui.ac.id/docs/)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment