Infinite Experiment Backend is a Go-based application designed to serve requests for a Discord bot. It provides a hybrid API approach using both REST and gRPC endpoints to handle different use cases. This repository is structured to support fast, iterative local development with hot reloading (via Air) and production-ready builds using Docker multi-stage builds.
This project serves as the backend for a Discord bot, managing communication between the bot and services such as a PostgreSQL database, REST endpoints, and gRPC endpoints for real-time communication. The goal is to provide a fast and scalable system that can be easily tested locally and deployed in production.
-
Hybrid API Design:
Combines REST for simple request-response operations with gRPC for performance-critical or streaming functionalities. -
Dockerized Development & Production:
Uses a multi-stage Dockerfile to provide separate configurations for local development (with hot reloading via Air) and production builds. -
Environment Configuration:
Easily switch between local (.env.local) and production (.env.production) settings.
To start local development with hot reloading:
-
Ensure Docker is installed and running.
-
Configure your local environment variables:
Create a.env.localfile in the root directory with variables similar to:APP_ENV=local DEBUG=true PORT=8080
-
Run the application using Docker Compose:
docker-compose -f docker-compose.local.yml up --build -
Stop application using Docker Compose:
docker componse -f docker-compose.local.yml down -
To rebuild a single service:
docker-compose -f docker-compose.prod.yml up -d --build api
To build a production-ready image:
-
Configure your production environment variables: Create a
.env.productionfile in the root directory with variables like:APP_ENV=production DEBUG=false PORT=8080
-
Build the production image using Docker:
docker build --target prod -t politburo:latest . -
Deploy the production container:
docker run -p 8080:8080 politburo:latest
Alternatively, push this image to a container registry and deploy it on your target VM or cloud platform.