Skip to content

Latest commit

 

History

History
120 lines (93 loc) · 4.3 KB

development.md

File metadata and controls

120 lines (93 loc) · 4.3 KB

Developing for OpenPitrix

The community repository hosts all information about building OpenPitrix from source, how to contribute code and documentation, who to contact about what, etc. If you find a requirement that this doc does not capture, or if you find other docs with references to requirements that are not simply links to this doc, please submit an issue.


To start developing OpenPitrix

First of all, you should fork the project. Then follow one of the three options below to develop the project. Please note you should replace the official repo when using go get or git clone below with your own one.

1. You have a working Docker Compose environment [recommend].

You need to install Docker first.

$ git clone https://github.com/openpitrix/openpitrix
$ cd openpitrix
$ make build-in-docker
$ docker-compose up -d

Exit docker runtime environment

$ docker-compose down

2. You have a working Docker environment.

$ git clone https://github.com/openpitrix/openpitrix
$ cd openpitrix
$ make build-in-docker
$ docker network create -d bridge openpitrix-bridge
$ docker run --name openpitrix-db -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=openpitrix \
    --network openpitrix-bridge -p 3306:3306 -d mysql:5.6
$ docker run --rm --name openpitrix-app --network openpitrix-bridge -d openpitrix app
$ docker run --rm --name openpitrix-runtime --network openpitrix-bridge -d openpitrix runtime
$ docker run --rm --name openpitrix-cluster --network openpitrix-bridge -d openpitrix cluster
$ docker run --rm --name openpitrix-repo --network openpitrix-bridge -d openpitrix repo
$ docker run --rm --name openpitrix-api --network openpitrix-bridge -p 9100:9100 -d openpitrix api

Exit docker runtime environment

$ docker stop $(docker ps -f name=openpitrix -q)

3. You have a working Go environment.

$ go get github.com/golang/protobuf/protoc-gen-go
$ go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
$ go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
$ go get github.com/mwitkow/go-proto-validators/protoc-gen-govalidators
  • Get openpitrix source code and build service:
$ go get -d openpitrix.io/openpitrix
$ cd $GOPATH/src/openpitrix.io/openpitrix
$ make generate
$ GOBIN=`pwd`/bin go install ./cmd/...
  • Install mysql server first. Then add the services name to the /etc/hosts file as follows.

Note: If you install mysql server remotely then configure the server IP correspondingly. You may need to create the database openpitrix and change the user root password to password in advance. If the user root password is different than the default one, then you need to specify the password in the command line when start OpenPitrix services.

127.0.0.1 openpitrix-api
127.0.0.1 openpitrix-repo
127.0.0.1 openpitrix-app
127.0.0.1 openpitrix-runtime
127.0.0.1 openpitrix-cluster
127.0.0.1 openpitrix-db
  • Start OpenPitrix service:
$ ./bin/openpitrix-api &
$ ./bin/openpitrix-repo &
$ ./bin/openpitrix-app &
$ ./bin/openpitrix-runtime &
$ ./bin/openpitrix-cluster &
  • Exit go runtime environment
$ ps aux | grep openpitrix- | grep -v grep | awk '{print $2}' | xargs kill -9

Test OpenPitrix

Visit http://127.0.0.1:9100/swagger-ui in browser, and try it online, or test openpitrix api service via command line:

$ curl http://localhost:9100/v1/apps
{"total_items":0,"total_pages":0,"page_size":10,"current_page":1}
$ curl http://localhost:9100/v1/apps/app-12345678
{"error":"App Id app-12345678 not exist","code":5}
$ curl http://localhost:9100/v1/appruntimes
{"total_items":0,"total_pages":0,"page_size":10,"current_page":1}
$ curl http://localhost:9100/v1/clusters
{"total_items":0,"total_pages":0,"page_size":10,"current_page":1}
$ curl http://localhost:9100/v1/repos
{"total_items":0,"total_pages":0,"page_size":10,"current_page":1}

DevOps

Please check How to set up DevOps environment.