This guide will help you set up and run the DiscountDB API with containerized PostgreSQL and Redis services.
- Git
- Docker and Docker Compose
- Go (1.24.0 or later)
git clone https://github.com/ImGajeed76/discountdb-api.git
cd discountdb-api
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"
Start the services using Docker Compose:
docker-compose up -d
This will spin up Redis and PostgreSQL containers.
Once Redis and PostgreSQL are running via Docker Compose, you can run the API:
go run cmd/api/main.go