Backend service of Plutus, a monetary management system from Nyxordinal
- Clone this repo and change directory to project folder
git clone https://github.com/nyxordinal/plutus-be.git && cd /plutus-be
- Install dependencies
composer install
- Copy .env.example to .env
cp .env.example .env
- Generate aplication key
php artisan key:generate
- Generate JWT secret key
php artisan jwt:secret
- Set your database credential in .env on key
DB\_\*
- Generate a pair of public and private RSA key with
pkcs1
padding - Place your private RSA key in .env on key
RSA_PRIVATE_KEY
. If you want to make it as a one-line, make sure to use single quote - Save your previously generated public RSA key and use it in plutus-fe
- If you are in production, do not forget to set APP_ENV in .env to "production" and set APP_DEBUG to "false"
- Open terminal in your project folder
- Use below command in the terminal
php artisan serve
- Access development server in http://localhost:8000
- Create
plutus_be
database in your RDMBS - Run migration
php artisan migrate
A. Publish Development Changes
- Do your changes
- Build plutus-be docker image
docker build \ --build-arg NEW_RELIC_AGENT_VERSION=<new_relic_version> \ --build-arg NEW_RELIC_LICENSE_KEY=<license_key> \ --build-arg NEW_RELIC_APPNAME=<app_name> \ -t nyxordinal/plutus-be:{tag} .
- Push docker image to nyxordinal registry
docker push nyxordinal/plutus-be:{tag}
B. Deploy Docker Image (Production Server)
- Pull plutus-be docker image
docker pull nyxordinal/plutus-be:{tag}
- Create and start plutus-be container
docker run -d -p {host-port}:8001 --name plutus-be \
--env APP_NAME=plutus-be \
--env APP_ENV=production \
--env APP_DEBUG=false \
--env APP_URL=http://localhost:8001 \
--env APP_TIMEZONE=UTC \
--env DB_CONNECTION=mysql \
--env DB_HOST={your-docker-host-ip} \
--env DB_PORT=3306 \
--env DB_DATABASE=plutus_be \
--env DB_USERNAME={your-db-username} \
--env DB_PASSWORD={your-db-password} \
--env REDIS_HOST={your-redis-host} \
--env REDIS_PASSWORD={your-redis-password} \
--env JWT_SECRET={your-jwt-secret} \
--env JWT_TTL={your-jwt-ttl} \
--env RSA_PRIVATE_KEY={your-private-rsa-key} \
--env MAIL_MAILER=smtp \
--env MAIL_HOST=smtp.mailtrap.io \
--env MAIL_PORT=2525 \
--env MAIL_USERNAME={your-mail-username} \
--env MAIL_PASSWORD={your-mail-password} \
--env MAIL_ENCRYPTION=tls \
--env [email protected] \
--env MAIL_FROM_NAME="Plutus Nyxordinal" \
nyxordinal/plutus-be:{tag}
- Access plutus-be in http://localhost:{host-port}/api
NOTE: How to check your docker host IP, find out in this link
Or you can add--net="host"
indocker run
command and then for DB_HOST you can use"localhost"
.
If you use--net="host"
indocker run
command,-p {host-port}:8001
must be removed fromdocker run
command
After doing your changes, you might want to run tlint
command to run the linter
Developed with passion by Nyxordinal