Skip to content

Commit

Permalink
update: adjust deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
shiqinfeng1 committed Mar 28, 2024
1 parent 2286026 commit ff2c413
Show file tree
Hide file tree
Showing 61 changed files with 668 additions and 532 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

####################################
## (1) Setup the build environment
FROM dockerproxy.com/library/golang:1.21-bullseye AS build-env
FROM dockerproxy.com/library/golang:1.22-bullseye AS build-env
# FROM golang:1.22-bullseye AS build-env

# Build the app binary in /app
RUN mkdir /app
Expand Down Expand Up @@ -70,7 +71,8 @@ RUN --mount=type=ssh \
RUN chmod a+x /app/bin/app

## (4) Add the statically linked debug binary to a distroless image configured for debugging
FROM dockerproxy.com/library/golang:1.21-bullseye as debug-dlv
FROM dockerproxy.com/library/golang:1.22-bullseye as debug-dlv
# FROM golang:1.22-bullseye as debug-dlv
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go install github.com/go-delve/delve/cmd/dlv@latest

Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ api:
# --openapiv2_out=./api
# --openapiv2_opt logtostderr=true

# generate image names,like:
# app/biz-trainer
# app/biz-training
# app/gateway-gomono
# app/task-migration
# app/bff-gomono
names=$(shell find app -name main.go|xargs -I X dirname X)

# build execute
Expand All @@ -89,7 +95,7 @@ wire:
find app -mindepth 2 -maxdepth 2 | grep cmd | $(wireCmd)

export DOCKER_BUILDKIT := 1
# (optional)Image registry address
# (optional)Image registry address
CONTAINER_REGISTRY=

# build docker images
Expand Down Expand Up @@ -144,7 +150,7 @@ build-docker-debug-dlv:

.PHONY: all
# make all
all: init config api wire build build-docker-debug
all: init config api wire build build-docker-debug

# show help
help:
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,30 @@ node1

登录master管理节点,执行:
```bash
ansible-playbook ./deploy/docker/ansible_playbook/ssh_login_no_password.yml
ansible-playbook ./deploy/docker/cluster-init/ssh_login_no_password.yml
```

如果安装失败,需要手动复制key:`ssh-copy-id [email protected]`

### 1.5 批量设置hostname

```bash
ansible-playbook ./deploy/docker/ansible_playbook/modify_hostname.yml
ansible-playbook ./deploy/docker/cluster-init/modify_hostname.yml
```

### 1.5 批量设置dns

```bash
ansible-playbook ./deploy/docker/cluster-init/config_dns.yml
```

## 2部署基础设施

1. 安装docker和docker-compose

```bash
cd goMono
ansible-playbook ./deploy/docker/ansible_playbook/install_docker_online.yml
ansible-playbook ./deploy/docker/infra-docker/install_docker_online.yml
```
> 注意:如果执行palybook时报错:
`fatal: [node1]: FAILED! => {"changed": false, "msg": "The Python 2 bindings for rpm are needed for this module. If you require Python 3 support use the `dnf` Ansible module instead.. The Python 2 yum module is needed for this module. If you require Python 3 support use the dnf Ansible module instead."}`, 需要将`/etc/ansible/hosts`中的`ansible_python_interpreter=/usr/bin/python3` 改为 `ansible_python_interpreter=/usr/bin/python2`, 或者,在ansible-playbook命令后面添加参数:`-e ansible_python_interpreter=/usr/bin/python2`
Expand All @@ -167,7 +172,7 @@ ansible-playbook ./deploy/docker/ansible_playbook/modify_hostname.yml

```bash
cd goMono
ansible-playbook ./deploy/docker/ansible_playbook/install_docker_registry.yml
ansible-playbook ./deploy/docker/infra-docker/install_docker_registry.yml
```

部署完成后,私有仓库在 `http://<域名/IP>:8080/` 上提供服务。(使用域名时,可能需要配置本地DNS)
Expand Down Expand Up @@ -195,8 +200,8 @@ ansible-playbook ./deploy/docker/ansible_playbook/modify_hostname.yml

注意:

- 默认只设置了nacos的数据源,如果需要增加其他数据源,修改 `./deploy/docker/config_prometheus.env` 配置
- nacos的dashboard配置是: `deploy/docker/config_nacos_grafana_dashboard.json`
- 默认只设置了nacos的数据源,如果需要增加其他数据源,修改 `./deploy/docker/infra-prometheus/config_prometheus.env` 配置
- nacos的dashboard配置是: `deploy/docker/infra-prometheus/config_nacos_grafana_dashboard.json`

# 开发微服务

Expand Down
2 changes: 1 addition & 1 deletion api/bff/v1/bff_http.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/user/v1/user_http.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 0 additions & 66 deletions deploy/docker/ansible_playbook/prepare_infra_images.yml

This file was deleted.

36 changes: 0 additions & 36 deletions deploy/docker/ansible_playbook/push_biz_images.yml

This file was deleted.

88 changes: 0 additions & 88 deletions deploy/docker/ansible_playbook/stop_infra.yml

This file was deleted.

Loading

0 comments on commit ff2c413

Please sign in to comment.