Skip to content

Commit

Permalink
Merge pull request #425 from Qihoo360/feature/frontend-separate
Browse files Browse the repository at this point in the history
Feature/frontend separate
  • Loading branch information
70data authored Jun 11, 2019
2 parents 5b21f3f + 556f02b commit 5c9b412
Show file tree
Hide file tree
Showing 23 changed files with 334 additions and 310 deletions.
47 changes: 0 additions & 47 deletions Dockerfile

This file was deleted.

31 changes: 31 additions & 0 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# requiring Docker 17.05 or higher on the daemon and client
# see https://docs.docker.com/develop/develop-images/multistage-build/
# BUILD COMMAND :
# docker --build-arg RELEASE_VERSION=v1.0.0 -t infra/wayne:v1.0.0 .

# build server
FROM 360cloud/wayne-server-builder:v1.0.1 as backend

COPY go.mod /go/src/github.com/Qihoo360/wayne
COPY go.sum /go/src/github.com/Qihoo360/wayne

COPY src/backend /go/src/github.com/Qihoo360/wayne/src/backend

RUN export GO111MODULE=on && \
export GOPROXY=https://goproxy.io && \
cd /go/src/github.com/Qihoo360/wayne/src/backend && \
bee generate docs && \
bee pack -o /_build

# build release image
FROM 360cloud/centos:7

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

COPY --from=backend /_build/backend.tar.gz /opt/wayne/

WORKDIR /opt/wayne/

RUN tar -xzvf backend.tar.gz

CMD ["./backend"]
21 changes: 21 additions & 0 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# requiring Docker 17.05 or higher on the daemon and client
# see https://docs.docker.com/develop/develop-images/multistage-build/
# BUILD COMMAND :
# docker --build-arg RELEASE_VERSION=v1.0.0 -t infra/wayne:v1.0.0 .

# build ui
FROM 360cloud/wayne-ui-builder:v1.0.1 as frontend

COPY src/frontend /workspace

RUN cd /workspace && \
npm config set registry https://registry.npm.taobao.org && \
npm install && \
npm run build

# build server
FROM openresty/openresty:1.15.8.1-1-centos

COPY --from=frontend /workspace/dist/ /usr/local/openresty/nginx/html/

CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"]
25 changes: 15 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ RELEASE_VERSION :=$(shell git describe --always --tags)
UI_BUILD_VERSION :=v1.0.1
SERVER_BUILD_VERSION :=v1.0.1


release: build-release-image push-image
release: build-backend-image build-frontend-image push-image

update-version:
./hack/updateversion.sh

# run module
run-backend:
cd src/backend/ && bee run -main=./main.go -runargs="apiserver"
export GO111MODULE=on && export GOPROXY=https://goproxy.io && cd src/backend/ && bee run -main=./main.go -runargs="apiserver"

run-worker:
cd src/backend/ && bee run -main=./main.go -runargs="worker -t AuditWorker -c 2"
Expand All @@ -42,20 +41,26 @@ swagger-openapi:
cd src/backend && swagger generate spec -o ./swagger/openapi.swagger.json

# release, requiring Docker 17.05 or higher on the daemon and client
build-release-image:
build-backend-image:
@echo "version: $(RELEASE_VERSION)"
docker build --no-cache --build-arg RAVEN_DSN=$(RAVEN_DSN) -t $(REGISTRY_URI)/wayne:$(RELEASE_VERSION) .
docker build --no-cache -t $(REGISTRY_URI)/wayne-backend:$(RELEASE_VERSION) -f Dockerfile.backend .

push-image:
docker push $(REGISTRY_URI)/wayne:$(RELEASE_VERSION)
build-frontend-image:
@echo "version: $(RELEASE_VERSION)"
docker build --no-cache -t $(REGISTRY_URI)/wayne-frontend:$(RELEASE_VERSION) -f Dockerfile.frontend .

push-image:
docker tag $(REGISTRY_URI)/wayne-backend:$(RELEASE_VERSION) $(REGISTRY_URI)/wayne-backend:latest
docker push $(REGISTRY_URI)/wayne-backend:$(RELEASE_VERSION)
docker push $(REGISTRY_URI)/wayne-backend:latest
docker tag $(REGISTRY_URI)/wayne-frontend:$(RELEASE_VERSION) $(REGISTRY_URI)/wayne-frontend:latest
docker push $(REGISTRY_URI)/wayne-frontend:$(RELEASE_VERSION)
docker push $(REGISTRY_URI)/wayne-frontend:latest

## server builder image
build-server-image:
cd hack/build/server && docker build --no-cache \
-t $(REGISTRY_URI)/wayne-server-builder:$(SERVER_BUILD_VERSION) .
cd hack/build/server && docker build --no-cache -t $(REGISTRY_URI)/wayne-server-builder:$(SERVER_BUILD_VERSION) .

## ui builder image
build-ui-image:
docker build -f hack/build/ui/Dockerfile -t $(REGISTRY_URI)/wayne-ui-builder:$(UI_BUILD_VERSION) .

57 changes: 7 additions & 50 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Wayne已大规模服务于360搜索,承载了内部绝大部分业务,稳定

## 项目依赖

- Golang 1.9+([installation manual](https://golang.org/dl/))
- Golang 1.12+([installation manual](https://golang.org/dl/))
- Docker 17.05+ ([installation manual](https://docs.docker.com/install))
- Bee ([installation manual](https://github.com/wilhelmguo/bee)) (请务必使用链接版本,不要使用 beego 官方版本,存在一些定制)
- Node.js 8+ and npm 5+ ([installation with nvm](https://github.com/creationix/nvm#usage))
Expand All @@ -61,62 +61,19 @@ Wayne已大规模服务于360搜索,承载了内部绝大部分业务,稳定
$ go get github.com/Qihoo360/wayne
```

- 启动MySQL(可选)
- 启动服务

若您没有可用的 MySQL 服务,可以通过 docker-compose 快速创建:
在 Wayne 的根目录下,通过 docker-compose 创建服务

```bash
$ docker-compose up -d mysql
```

- 创建配置文件

```bash
$ cd src/backend/conf && touch dev.conf
```

- 写入数据库相关配置(请修改为数据库实际地址)

```bash
DBName = wayne
# MySQL连接配置,默认是mysql(MySQL服务名称).
# 如果使用docker-compose启动MySQL,同时你没有改变mysql的服务名称,那么保留默认配置即可。
# 你也可以通过执行"docker network inspect wayne_default"(如果没有使用docker-compose
# 的默认网络,需要将“wayne_default”替换为实际使用的网络名称)来获得mysql容器IP,然后将
# “mysql”替换为其容器IP。当你使用自定义运行环境时,使用容器IP会更加灵活。例如:
# "DBTns = tcp(172.17.0.2:3306)"
DBTns = tcp(mysql:3306)
DBUser = root
DBPasswd = root
```

- 启动Wayne服务

进入Wayne根目录,执行

```bash
$ docker-compose up -d wayne
```shell
$ docker-compose -f ./hack/docker-compose/docker-compose.yaml up
```

通过上述命令,您可以从通过 http://127.0.0.1:8080/admin 访问本地 Wayne, 默认管理员账号 admin:admin

> 注意:项目启动后还需要配置集群和Namespace等信息才可正常使用。详见 [集群配置](https://github.com/Qihoo360/wayne/wiki/Wayne-admin-cluster)
> 注意:项目启动后还需要配置集群和Namespace等信息才可正常使用。详见 [集群配置](https://360yun.org/wayne/admin/cluster.html)

## 文档

- 请参照 [Wiki](https://github.com/Qihoo360/wayne/wiki)

## Roadmap

- 国际化
- 支持 Kubernetes 已有项目迁移
- 支持从 Helm 迁移
- 支持一键从 Yaml/Json 导入对象
- 支持 HPA 等其他对象
- 完善运维 Kubernetes 集群功能,提供完整的 Kubectl 功能
- 支持更完整的报表和开放 API 系统

## 贡献者

- 请参照 [贡献者](https://github.com/Qihoo360/wayne/wiki/contributors)
- 请参照 [Wiki](https://360yun.org/wayne/)
55 changes: 5 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The whole system adopts the separation of front and back ends, in which the fron

## Dependence

- Golang 1.9+([installation manual](https://golang.org/dl/))
- Golang 1.12+([installation manual](https://golang.org/dl/))
- Docker 17.05+ ([installation manual](https://docs.docker.com/install))
- Bee ([installation manual](https://github.com/wilhelmguo/bee))(Be sure to use the link version, don't use the official version of beego, there are some customizations.)
- Node.js 8+ and npm 5+ ([installation with nvm](https://github.com/creationix/nvm#usage))
Expand All @@ -60,64 +60,19 @@ The whole system adopts the separation of front and back ends, in which the fron
$ go get github.com/Qihoo360/wayne
```

- Start MySQL(Optional)

If you don't have a MySQL service available, you can quickly create it with docker-compose:

```bash
$ docker-compose up -d mysql
```

- Create configuration file

```bash
$ cd src/backend/conf && touch dev.conf
```

- Write database related configuration (Please modify to the actual address of the database.)

```bash
DBName = wayne
# MySQL connection config, its mysql(service name) by default.
# Keep it default value, if you run MySQL via docker-compose and you didn't
# change the mysql's service name.
# You can also run "docker network inspect wayne_default"(replace wayne_default
# to the real docker network name if you didn't use the default network of
# docker-compose) to get the contianer IP of mysql, then replace `mysql`
# to the container IP. Its more flexible when you want to customize the environment
# of wayne running. For example "DBTns = tcp(172.17.0.2:3306)"
DBTns = tcp(mysql:3306)
DBUser = root
DBPasswd = root
```

- Start Wayne

cd Wayne root directory and execute
Start server by docker-compose at Wayne project.

```bash
$ docker-compose up -d wayne
$ docker-compose -f ./hack/docker-compose/docker-compose.yaml up
```

With the above command, you can access the local Wayne from http://127.0.0.1:8080/admin, the default administrator account admin:admin.

> Note: After Wayne is started, you need to configure information such as cluster and Namespace for normal use. See details [Cluster Configuration](https://github.com/Qihoo360/wayne/wiki/Wayne-admin-cluster)
> Note: After Wayne is started, you need to configure information such as cluster and Namespace for normal use. See details [Cluster Configuration](https://360yun.org/wayne/admin/cluster.html)

## Document

- Refer [Wiki](https://github.com/Qihoo360/wayne/wiki)

## Roadmap

- i18n
- Support for migration of existing projects in kubernetes
- Support for migration from Helm
- Support for importing objects from Yaml/Json with one click
- Support for other objects such as HPA
- Improve operation and maintenance Kubernetes cluster function, providing complete Kubectl function
- Support for more complete reporting and open API system

## Contributors

- Refer [contributors](https://github.com/Qihoo360/wayne/wiki/contributors)
- Refer [Wiki](https://360yun.org/wayne/)
37 changes: 0 additions & 37 deletions docker-compose.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@ module github.com/Qihoo360/wayne

go 1.12

replace (
golang.org/x/crypto => github.com/golang/crypto v0.0.0-20190403202508-8e1b8d32e692
golang.org/x/exp => github.com/golang/exp v0.0.0-20190402192236-7fd597ecf556
golang.org/x/image => github.com/golang/image v0.0.0-20190321063152-3fc05d484e9f
golang.org/x/lint => github.com/golang/lint v0.0.0-20190313153728-d0100b6bd8b3
golang.org/x/mobile => github.com/golang/mobile v0.0.0-20190327163128-167ebed0ec6d
golang.org/x/net => github.com/golang/net v0.0.0-20190403144856-b630fd6fe46b
golang.org/x/oauth2 => github.com/golang/oauth2 v0.0.0-20190402181905-9f3314589c9a
golang.org/x/sync => github.com/golang/sync v0.0.0-20190227155943-e225da77a7e6
golang.org/x/sys => github.com/golang/sys v0.0.0-20190403152447-81d4e9dc473e
golang.org/x/text => github.com/golang/text v0.3.0
golang.org/x/time => github.com/golang/time v0.0.0-20190308202827-9d24e82272b4
golang.org/x/tools => github.com/golang/tools v0.0.0-20190403183509-8a44e74612bc
google.golang.org/appengine => github.com/golang/appengine v1.4.0
)

require (
github.com/astaxie/beego v1.11.1
github.com/certifi/gocertifi v0.0.0-20190410005359-59a85de7f35e // indirect
Expand Down
Loading

0 comments on commit 5c9b412

Please sign in to comment.