Inside:
- Quick install with homebrew
- Prerequisites
- Services creation
- Db helpers creation
- Database seeding
- How to run in dev mode
- If you want to run without cli
- What is my purpose and why go
- Autogenerated docs about cli
Homebrew
Quick install withbrew tap andriiklymiuk/homebrew-tools
brew install corgi
# ask for help to check if it works
corgi -h
It will install it globally.
With it you can run corgi
in any folder on your local.
Create service file, if you want to run corgi.
Prerequisites
If you want to run db_services or your services require docker, then you need
If you want to use auto seeding feature for postgres databases, you need to install
Services creation
You need to create corgi-compose.yml file in root of your target repo to create services and db services. It should be created in the following way:
corgi-compose.yml example
db_services:
corgi:
databaseName: corgi-database
user: corgi
password: corgiSecurePassword
port: 5432
#Use seedFromFilePath or seedFromDb/seedFromDbEnvPath, only one will work
seedFromFilePath: path/to/dump.sql to use, it will precede before seedFromDb.
# can be empty, use either seedFromDbEnvPath or seedFromDb
seedFromDbEnvPath: path/to/db/info/.env
seedFromDb:
host: db_host_for_seed_seed_db
databaseName: db_name_for_seed_db
user: db_user_for_seed_db
password: db_password_for_seed_db
port: db_port_for_seed_db
corgiTest:
databaseName: corgi-database-test
user: corgi
password: corgiSecurePasswordTest
port: 5433
services:
corgiServer:
# copyEnvFromFilePath: path_to_copy_env_from
environment:
- PORT=8965
depends_on_db:
- corgi
beforeStart:
- install your dependencies or do other stuff
- that needs to be run before start cmd
start:
- start corgiServer
corgiApp:
cloneFrom: url_to_use_in_git_clone_if_path_doesn't_exist
path: /path/for/service
environment:
- SOME_ENV=corgi_is_best
- SOME_ENV2=corgi_is_best_indeed
depends_on_services:
- name: corgiServer
envAlias: BEST_CORGI_SERVER_URL
beforeStart:
- install your dependencies or do other stuff
- that needs to be run before start cmd
start:
- start corgiApp
afterStart:
- do some cleanup staff on service close
Then run, which will create db_services.
corgi init
Or, if you want to just run services and already created db_services:
corgi run
Tip: there can be as many services as you wish. But create it with different ports to be able to run in all at the same time, if you want.
You can read of what exactly happens on run or on init to better understand corgi logic.
Without cli
The beauty of this cli is that it is versatile and can be run without even opening cli, if it is broke or smth has happened to it. All database services are in corgi_services/db_services
folder, so you can go to interested service folder and just run make up
to start the database.
It can be done so, because cli is dependent upon on docker-compose.yml
and MAKEFILE for each service, and it can be run independently.
Credits:
- Corgi image by catalyststuff on Freepik
- Random quote is from https://api.quotable.io