GoWindGoWind
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
  • Introduction

    • GoWind Admin Product Introduction
    • GoWind Admin Installation Guide
    • Release Notes
  • Backend

    • Backend Architecture Overview
    • Backend Core Modules in Depth
    • Backend API & Protobuf Definitions
    • Backend Configuration & Deployment
    • Backend Extension Development
  • Frontend

    • Frontend Architecture Overview
    • Frontend Core Features in Depth
  • Secondary-Dev Tutorials

    • Backend Tutorial: Adding a New Business Module
    • Frontend Tutorial: Adding a New Business Page
    • Full-Stack Integration Tutorial
  • Advanced Tutorials

    • Lua Script Extension Tutorial
    • Permission System in Depth
    • Multi-Tenancy Architecture Tutorial
    • Task Scheduling and Asynchronous Processing
    • File Upload and Object Storage
    • Event Bus and Decoupled Architecture
    • Frontend Theming and Internationalization
    • Performance Optimization and Monitoring
    • SSE Real-Time Push
    • Login Policies and Security Hardening
    • Encryption Toolkit in Practice

Backend Configuration & Deployment

This document details all configuration items of the GoWind Admin backend and the deployment approaches for development/production environments.

1. Configuration File System

Backend configuration files are located in the app/admin/service/configs/ directory in YAML format, split by functional domain:

configs/
├── server.yaml     # Server configuration (REST, Asynq, SSE)
├── data.yaml       # Data source configuration (database, Redis)
├── auth.yaml       # Authentication & authorization configuration
├── client.yaml     # Client configuration
├── oss.yaml        # Object storage configuration
└── logger.yaml     # Logger configuration

1. Server Configuration (server.yaml)

server:
  rest:
    addr: ":7788"               # REST API listen address
    timeout: 10s                # Request timeout
    enable_swagger: true        # Enable Swagger UI
    enable_pprof: true          # Enable pprof profiling
    cors:                       # CORS configuration
      headers:
        - "X-Requested-With"
        - "X-Request-ID"
        - "Content-Type"
        - "Authorization"
      methods:
        - "GET"
        - "POST"
        - "PUT"
        - "DELETE"
      origins:
        - "*"
    middleware:                  # Middleware toggles
      enable_logging: true      # Request logging
      enable_recovery: true     # Panic recovery
      enable_tracing: true      # Distributed tracing
      enable_validate: true     # Parameter validation
      enable_circuit_breaker: true  # Circuit breaker
      enable_metadata: true     # Metadata propagation

  asynq:                        # Asynq async task configuration
    uri: "redis://:*Abcd123456@redis:6379/1"
    codec: "json"
    concurrency: 10             # Number of concurrent workers
    shutdown_timeout: 10s
    queues:                     # Queue priority configuration
      critical: 10
      default: 5
      low: 1

  sse:                          # SSE push service configuration
    addr: ":7789"
    codec: "json"
    path: "/events"
    auto_stream: true
    auto_reply: false

2. Data Source Configuration (data.yaml)

data:
  database:
    driver: "postgres"          # Database driver: postgres / mysql
    source: "host=postgres port=5432 user=postgres password=*Abcd123456 dbname=gwa sslmode=disable"
    # MySQL configuration example:
    # driver: "mysql"
    # source: "root:*Abcd123456@tcp(localhost:3306)/gwa?parseTime=true&charset=utf8mb4&loc=Asia%2FShanghai"
    migrate: true               # Run database migrations automatically
    debug: false                # Enable SQL debug logging
    enable_trace: false         # Enable database tracing
    max_idle_connections: 25    # Max idle connections
    max_open_connections: 25    # Max open connections
    connection_max_lifetime: 300s  # Max connection lifetime

  redis:
    addr: "redis:6379"
    password: "*Abcd123456"
    dial_timeout: 10s
    read_timeout: 0.4s
    write_timeout: 0.6s

3. Authentication & Authorization Configuration (auth.yaml)

authn:
  type: "jwt"                  # Authentication method: jwt / oidc / preshared_key
  jwt:
    method: "HS256"             # JWT signing algorithm
    key: "some_api_key"         # JWT signing key

authz:
  type: "noop"                  # Authorization engine: casbin / opa / zanzibar / noop
  casbin:                       # Casbin configuration (active when type=casbin)
  opa:                          # OPA configuration (active when type=opa)
  zanzibar:                     # Zanzibar configuration (active when type=zanzibar)
    type: "keto"                # keto / open_fga
    keto:
      write_url: "http://keto:4466"
      read_url: "http://keto:4466"
      use_grpc: true

4. Object Storage Configuration (oss.yaml)

oss:
  minio:
    endpoint: "minio:9000"
    upload_host: "minio:9000"
    download_host: "minio:9000"
    access_key: "root"
    secret_key: "*Abcd123456"
    token: ""
    use_ssl: false

5. Logger Configuration (logger.yaml)

logger:
  type: std                     # Logger type: std / file / fluent / zap / logrus / aliyun / tencent
  zap:
    level: "debug"
    filename: "./logs/info.log"
    max_size: 1                 # Max MB per log file
    max_age: 30                 # Days to retain logs
    max_backups: 5              # Max number of backup files

2. Startup Flow

The backend service starts on the kratos-bootstrap framework, following a standardized lifecycle:

1. Startup Entry Point

// cmd/server/main.go
func runApp() error {
    ctx := bootstrap.NewContext(
        context.Background(),
        &conf.AppInfo{
            Project: service.Project,
            AppId:   service.AdminService,
            Version: version,
        },
    )
    return bootstrap.RunApp(ctx, initApp)
}

2. Command-Line Arguments

Configuration can be overridden via command-line arguments, making it easy to switch between environments:

ArgumentShortDefaultDescription
--conf-c../../configsConfiguration file directory
--env-edevRuntime environment (dev/test/prod)
--chost-s127.0.0.1:8500Remote config center address
--ctype-tconsulConfig center type (etcd/nacos/consul)
--daemon-dfalseRun as a daemon
# Production startup, using the Etcd config center
go run main.go -e prod -c ./configs/prod -t etcd -s 192.168.1.100:2379

3. Configuration Precedence

Configuration is loaded with the following precedence (higher priority overrides lower):

Remote config center > command-line arguments > environment variables > local config files

4. Remote Configuration Center

Supports Etcd / Nacos / Consul / Apollo / Polaris and other config centers, activated by an "import-to-enable" approach:

import (
    _ "github.com/tx7do/kratos-bootstrap/config/etcd"  // enable Etcd
)

Configuration example:

config:
  type: "etcd"
  etcd:
    endpoints: ["127.0.0.1:2379"]
    path: "/go-wind-admin/configs"

3. Environment Variables

The .env file at the project root configures environment variables used by the Makefile and scripts.

4. Docker Deployment

1. Docker Compose Files

The project provides two Docker Compose files:

FileDescription
docker-compose.yamlFull deployment (middleware + application services)
docker-compose.libs.yamlMiddleware dependencies only

2. Middleware Services

ServiceImagePortDescription
PostgreSQLbitnami/postgresql:latest5432Primary database
MySQL (optional)mariadb:latest3306Alternative database
Redisbitnami/redis:latest6379Cache/queue
MinIOminio/minio:latest9000/9001Object storage
Jaeger (optional)jaegertracing/all-in-one:latest16686Distributed tracing

3. Deployment Scripts

All deployment scripts are located in the scripts/ directory:

Environment Initialization Scripts

ScriptDescription
scripts/env/install_unix_dev.shLinux/macOS development environment install
scripts/env/install_unix_prod.shLinux/macOS production environment install
scripts/env/install_windows_dev.ps1Windows development environment install

Docker Deployment Scripts

ScriptDescription
scripts/docker/full_deploy.shFull Docker deployment (middleware + app)
scripts/docker/full_deploy.ps1Full Docker deployment (Windows)
scripts/docker/libs_only.shMiddleware dependencies only (recommended for development)
scripts/docker/libs_only.ps1Middleware dependencies only (Windows)

Production Deployment Scripts

ScriptDescription
scripts/deploy/pm2_service.shPM2 process-managed deployment

5. Development Environment Deployment

Option 1: Middleware Only (Recommended)

Suited to day-to-day development and debugging, with the application running in a local IDE:

# Linux / macOS
./scripts/docker/libs_only.sh
gow run admin

# Windows (PowerShell as administrator)
.\scripts\docker\libs_only.ps1
gow run admin

Option 2: Full Docker Startup

Suited to quick trials or CI environments:

# Linux / macOS
./scripts/docker/full_deploy.sh

# Windows
.\scripts\docker\full_deploy.ps1

6. Production Deployment

Option 1: Full Docker Deployment

All services (middleware + application) run in Docker containers:

./scripts/docker/full_deploy.sh

Option 2: Hybrid Deployment

Middleware runs in Docker, while the application runs on the host (managed by PM2):

# Start middleware
./scripts/docker/libs_only.sh

# Host the application with PM2
./scripts/deploy/pm2_service.sh

Option 3: Manual Build & Deploy

# Build
make build

# Output binaries are located in the app/admin/service/ directory
# Deploy the binaries together with the configs/ directory to the server

7. Makefile Commands in Detail

GoWind Admin uses a layered Makefile design of "root Makefile + app.mk + per-service Makefile":

backend/
├── Makefile              # Global commands (init/build/gen/docker...)
├── app.mk                # Per-service command template (run/api/ent/wire...)
└── app/admin/service/
    └── Makefile           # include ../../../app.mk

1. Global Commands (Root Directory)

CommandDescriptionWhen to Use
make initInstall Protobuf plugins + CLI toolsAfter first cloning the project
make genBatch-generate all service code (Ent + Wire + API)Full regeneration
make buildBuild all service binariesPackaging & deployment
make dockerBuild Docker images for all servicesContainerized deployment
make testRun all unit testsPre-commit verification
make lintgolangci-lint code checkCode standards
make docker-upStart all services + middlewareFull Docker deployment
make docker-libsStart middleware onlyDay-to-day development
make docker-downStop all Docker servicesEnvironment cleanup
make pm2-deployDeploy microservices with PM2Hybrid deployment

2. Service-Level Commands (app/admin/service/ Directory)

CommandDescriptionWhen to Use
make runStart the current service (local debugging)Development & debugging
make apiGenerate the current service's Go API codeAfter API changes
make entGenerate the current service's Ent ORM codeAfter schema changes
make wireGenerate the current service's dependency injection codeAfter dependency changes
make openapiGenerate the current service's OpenAPI documentationUpdating API docs
make tsGenerate the current service's TypeScript codeFrontend/backend sync
make buildBuild the current service's binarySingle-service deployment

3. Common Scenarios

# Scenario 1: first-time initialization and startup
make init && make docker-libs && make gen
make run

# Scenario 2: update after API changes
cd app/admin/service
make api && make openapi && make run

# Scenario 3: build Docker images and deploy
cd ../..
make gen && make docker && make docker-up

8. Hosts Configuration

During local development, since Docker containers communicate with each other via service names, hostname mappings need to be added to the host machine's hosts file:

# Linux/MacOS: /etc/hosts
# Windows: C:\Windows\System32\drivers\etc\hosts
127.0.0.1 postgres
127.0.0.1 redis
127.0.0.1 minio

9. Dockerfile Notes

The backend Dockerfile supports multi-stage builds:

# Specify the service name via a build argument
ARG SERVICE_NAME=admin
ARG APP_VERSION=1.0.0

Build the image:

docker build --build-arg SERVICE_NAME=admin --build-arg APP_VERSION=1.0.0 -t go-wind-admin/admin-service .

10. Database Initialization

Database initialization scripts are located in the sql/ directory.

When migrate: true is set in data.yaml, Ent automatically runs database migrations (creating table structures). For manual initialization, execute the SQL scripts.

11. Related Documents

  • Backend Architecture Overview
  • Backend Core Modules in Depth
  • Backend API & Protobuf Definitions
  • Backend Extension Development
Edit this page
Last Updated:: 11/3/26, 2:14 PM
Contributors: Bobo
Prev
Backend API & Protobuf Definitions
Next
Backend Extension Development