Skip to content

Commit

Permalink
docs: add deploy introduction
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayheaven committed Jan 19, 2024
1 parent 7951e85 commit 0777c8e
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 13 deletions.
3 changes: 2 additions & 1 deletion docs/go-gin-boilerplate/docs/start/_category_.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"position": 2,
"link": {
"type": "generated-index"
}
},
"collapsed": false
}
55 changes: 55 additions & 0 deletions docs/go-gin-boilerplate/docs/start/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,58 @@ sidebar_position: 4
# 正式部署

多种方式部署你的项目

## docker-compose

### 要求

- 已有 docker 环境
- 已有 mysql、redis 等服务运行

1. 修改 `configs/config.yaml` 文件中的配置项,确保 mysql、redis 等服务的配置正确,并复制到项目根目录 中

### 配置

1. 修改 `configs/config.yaml` 文件中的配置项,确保 mysql、redis 等服务的配置正确,并复制到项目根目录 中
2. 修改 `deployments/docker-compose.yml` 文件中的配置项,并复制到项目根目录 中

### 运行项目

在项目根目录下,执行以下命令,启动项目

```sh
docker compose up -d
```

### docker-compose 示例

```yml
version: "3"
services:
go-gin-boilerplate:
image: golang:latest
container_name: go-gin-boilerplate
working_dir: /server
volumes:
- ./:/server # mount current directory to /server, make sure your docker-compose.yml is in the root of your project
restart: always
command: sh -c "make build && ./build/ggb server"
```
## 二进制文件运行
### 配置
1. 修改 `configs/config.yaml` 文件中的配置项,确保 mysql、redis 等服务的配置正确,并复制到项目根目录 中

### 打包

```sh
make build
```

### 执行二进制文件

```sh
./build/ggb server
```
10 changes: 7 additions & 3 deletions docs/go-gin-boilerplate/docs/start/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ go mod download

## 创建 githooks 软链接【推荐】

通过创建软链接,可以在每次提交代码时,自动运行 `pre-commit``commit-msg` 钩子,从而实现自动化测试和规范化提交信息。

进入 `.git/hooks` 目录

```sh
Expand All @@ -43,7 +45,7 @@ cd .git/hooks
建立软链接

```sh
ln -s ../../githooks/\* .
ln -s ../../githooks/* .
```

### 提示
Expand All @@ -52,11 +54,13 @@ ln -s ../../githooks/\* .
>
> 运行以下命令:
>
> 现在你的当前目录位置应该在 .git/hooks 目录下
>
> ```sh
> ls -l . # 现在你的当前目录位置应该在 .git/hooks 目录下
> ls -l .
> ```
>
> 如果成功,你将会看到类似输出,包含以下内容
> 如果成功,你将会看到类似输出会包含以下内容
>
> ```sh
> commit-msg -> ../../githooks/commit-msg
Expand Down
9 changes: 7 additions & 2 deletions docs/go-gin-boilerplate/docs/start/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ sidebar_position: 0.1

项目目录结构完全遵守 [project-layout](https://github.com/golang-standards/project-layout) 规范,结构清晰,便于扩展和维护。

> `project-layout`:
## 什么是 project-layout

> 这是 Go 应用程序项目的基本布局。它不是核心 Go 开发团队定义的官方标准;然而,它是 Go 生态系统中一组常见的老项目和新项目的布局模式。其中一些模式比其他模式更受欢迎。它还具有许多小的增强,以及对任何足够大的实际应用程序通用的几个支持目录。
```sh
开发过程中,应该遵循一些规范,这样可以使项目结构更加清晰,便于扩展和维护。
**约定优于配置**,这样可以减少开发人员之间的沟通成本,提高开发效率。

## 目录树形展示

```sh
.
├── .github ---------------------------- GitHub 相关配置
│   └── workflows ------------------------ GitHub Actions 配置
Expand Down
11 changes: 4 additions & 7 deletions docs/go-gin-boilerplate/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ const config: Config = {
favicon: "img/golang.png",

// Set the production url of your site here
url: "https://sanjayheaven.github.io",
url: "https://sanjayheaven.github.io/",
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: "/go-gin-boilerplate/",

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: "facebook", // Usually your GitHub org/user name.
organizationName: "sanjayheaven", // Usually your GitHub org/user name.
projectName: "go-gin-boilerplate", // Usually your repo name.

onBrokenLinks: "throw",
onBrokenLinks: "ignore",
onBrokenMarkdownLinks: "warn",

// Even if you don't use internationalization, you can use this field to set
Expand Down Expand Up @@ -61,10 +61,7 @@ const config: Config = {
image: "img/docusaurus-social-card.jpg",
navbar: {
title: "Go Gin Boilerplate",
logo: {
alt: "My Site Logo",
src: "../img/golang.png",
},
logo: { alt: "Logo", src: "img/golang.png" },
items: [
{
type: "docSidebar",
Expand Down

0 comments on commit 0777c8e

Please sign in to comment.