Skip to content
Lim Tangmeng edited this page Aug 17, 2024 · 2 revisions

Overview

The server infrastructure for the BUON18 system is designed to provide reliable, scalable, and secure operations. It typically includes the following components:

  1. Programing Language
    • Golang
  2. Database
    • Postgres
    • Valkey

Key Features

  • Filter and Sort Features
  • Cache
  • Log
  • Authentication & Authorization

Set Up

Using Docker Compose

name: buon18-system
services:
  db:
    image: postgres:alpine
    container_name: buon18-system-database
    restart: unless-stopped
    environment:
      - POSTGRES_PASSWORD=postgres
    ports:
      - "5432:5432"
    volumes:
      - ./db/data:/var/lib/postgresql/data
      - ./db/init:/docker-entrypoint-initdb.d
  valkey:
    image: valkey/valkey:8.0-alpine
    container_name: buon18-system-valkey
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - ./valkey/data:/data
      - ./valkey/valkey.conf:/etc/valkey/valkey.conf
    command: ["valkey-server", "/etc/valkey/valkey.conf"]
  server:
    image: buon18/system-server:2.0.0-a.5
    container_name: buon18-system-server
    restart: unless-stopped
    depends_on:
      - db
      - valkey
    ports:
      - "8080:80"
      - "8081:443"
    environment:
      - PORT=80
      - DB_CONNECTION_STRING=postgres://postgres:postgres@db:5432/postgres?sslmode=disable
      - TOKEN_KEY=my_secret_key
      - REFRESH_TOKEN_KEY=my_secret_refresh_key
      - TOKEN_DURATION_SEC=600 # 10 mins
      - REFRESH_TOKEN_SEC=86400 # 1 day
      - VALKEY_ADDRESSES=valkey:6379
      - VALKEY_PWD=valkey
      - CACHE_DURATION_SEC=600
      - LOGGING_DIR=/logs
      - GIN_MODE=release
      - ALLOW_ORIGINS=*
      - ALLOW_METHODS=GET,POST,PATCH,DELETE,OPTIONS
      - ALLOW_HEADERS=*
      - EXPOSE_HEADERS=Content-Length
      - MAX_AGE=120
      - CERT_FILE=
      - KEY_FILE=
    volumes:
      - ./certs:/certs
      - ./logs:/logs

It would help if you created logs, db, and valkey folders in the same compose file.
Create init and data folders inside the db folder and copy 01. Create Schema, 02. Seed and 03. Create Store Procedure into init folder Create a data folder inside the valkey folder and copy the Redis config file into the valkey folder as valkey.conf or valkey will use their default configuration.

After all of that run this command in the current folder terminal

docker-compose up -d
Clone this wiki locally