Skip to content

Latest commit

 

History

History
82 lines (57 loc) · 1.61 KB

self_host.md

File metadata and controls

82 lines (57 loc) · 1.61 KB

Instructions for self-hosting

This guide will help you set up and run the DiscountDB API with containerized PostgreSQL and Redis services.

Prerequisites

Setup Steps

1. Clone the Repository

git clone https://github.com/ImGajeed76/discountdb-api.git
cd discountdb-api

2. Update Environment Variables and Compose File

Copy the .env.example file to .env:

cp .env.example .env

Check and update all the environment variables in the .env file.

If you just want a quick local setup you can use this .env file:

DB_USERNAME = root
DB_PASSWORD = root
DB_HOST = localhost
DB_PORT = 25060
DB_DATABASE = discountdb
DB_SSL_MODE = disable

REDIS_USERNAME = default
REDIS_PASSWORD = root
REDIS_HOST = localhost
REDIS_PORT = 25061
REDIS_USE_TLS = false

Update the following in the docker-compose.yml file:

POSTGRES_USER: [ DB_USERNAME ]
POSTGRES_PASSWORD: [ DB_PASSWORD ]
POSTGRES_DB: [ DB_DATABASE ]

ports:
  - "[DB_PORT]:5432"
command: redis-server --requirepass [REDIS_PASSWORD]

ports:
  - "[REDIS_PORT]:6379"

3. Start the Services

Start the services using Docker Compose:

docker-compose up -d

This will spin up Redis and PostgreSQL containers.

4. Run the API Locally

Once Redis and PostgreSQL are running via Docker Compose, you can run the API:

go run cmd/api/main.go