mengstack-website/guide/getting-started.md
SoftUnis ecb29e0aa4 初始化 MengStack 官方网站仓库
包含 VitePress 文档站完整源码及全新自定义首页设计:
- 自定义首页组件 (Home.vue):Hero + 终端动效 + 核心能力 + 架构展示 + 快速开始 + CTA
- 自定义 Layout.vue:首页/文档页布局切换
- 金铜色品牌主题样式
- 完整文档页面(指南、API、更新日志、演示、社区)
- SEO 配置(sitemap、robots、meta 标签)
2026-10-02 23:37:25 +08:00

1.9 KiB
Raw Blame History

title
快速开始 | 5分钟搭建MengStack项目环境 - MengStack官方文档

快速开始

环境要求

  • Go 1.23+
  • PostgreSQL 14+
  • Redis 7+
  • Docker & Docker Compose(可选)

使用 Docker Compose 启动(推荐)

最简单的方式是使用 Docker Compose 一键启动所有服务:

# 克隆项目
git clone https://gitea.softunis.com/mengstack/mengstack.git
cd mengstack

# 启动所有服务
docker-compose up -d

# 查看日志
docker-compose logs -f app

服务启动后:

  • API 服务:http://localhost:2222
  • Swagger UI:http://localhost:2222/swagger/index.html
  • 健康检查:http://localhost:2222/health

本地开发

1. 安装依赖

# 下载 Go 模块
go mod download

# 确保 PostgreSQL 和 Redis 已启动

2. 配置环境变量

复制 .env.example 为 .env 并修改:

cp .env.example .env

关键配置项:

MENGSTACK_SERVER_PORT=2222

# PostgreSQL
MENGSTACK_DB_HOST=localhost
MENGSTACK_DB_PORT=5432
MENGSTACK_DB_NAME=mengstack
MENGSTACK_DB_USER=postgres
MENGSTACK_DB_PASSWORD=your_password

# Redis
MENGSTACK_REDIS_HOST=localhost
MENGSTACK_REDIS_PORT=6379

# JWT
MENGSTACK_JWT_SECRET=your_jwt_secret_key

3. 启动服务

# 直接运行
go run cmd/server/main.go

# 或使用 Makefile
make run

4. 验证

# 健康检查
curl http://localhost:2222/health

# 注册新用户
curl -X POST http://localhost:2222/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "admin@example.com",
    "username": "admin",
    "password": "password123"
  }'

项目命令

命令 说明
make run 启动开发服务
make build 编译二进制文件
make test 运行测试
make swagger 重新生成 API 文档
make lint 代码检查
make docker-up Docker 启动所有服务
make docker-down Docker 停止所有服务