Microservice that serves image BLOBs via a REST API, using the following services:
- Postgres as primary Database
- Redis as cache (LFU)
- Consul for Service Discovery
- HAProxy as Load Balancer
- Jaeger as Tracing Platform
consul:
enable:
service_name: # Service under which the microservices will be registered. Each one will have an unique id.
service_address: # Either auto or manually set. auto finds the first non-loopback address.
address:
datacenter:
port:
redis:
enable: # Optional
host: # If Consul is enabled then this is the service name, otherwise ip:port
password:
db:
postgres:
host: # If Consul is enabled then this is the service name, otherwise ip:port
database:
username:
password:
ssl: # Optional
http:
port: # Optional
allow_insert:
allow_delete:
rate_limit_enable:
rate_limit: # RPS
telemetry:
enable:
jaeger_address: # If Consul is enabled then this is the service name, otherwise ip:port
sampling: # Optional
logs_path:
logs_max_size: # Optional
logs_max_backups: # Optional
logs_max_age: # Optional
docker build -t local/go-cdn .
docker run -v "./configs/config-docker.yaml:/cdn/configs.yaml:ro" --net "cdn-default" -d local/go-cdn
Check the provided docker-compose.yml
for a deployment example. The provided stack contains an example Consul container for demo purposes.
docker compose build
docker compose up -d
docker compose logs -f
Apply all the deployments.
kubectl apply -f .
Due the nature of Go, tests are ran inside their respective packages. This creates confusion with the relative paths regarding configs and migrations. To get around this limitation it's possible to compile each test individually, and then run it from the root of the folder:
go test -c ./...
./{PACKAGE}.test
Otherwise use:
make test