This topic is intended to help developers who are new to MOSN projects quickly set up a development environment for building, testing, packaging, and running the sample code.
Note: MOSN is developed based on Go 1.12.7 and relies on dep for dependency management.
Prepare the running environment
- If you want to run MOSN with docker, install docker first.
- If you are using a local machine, set up a Unix-like environment.
- Install the compilation environment of Go.
- Install dep. For details, see the official installation document of deb.
Obtain the code
Code for MOSN projects is hosted at Github. Run the following command to obtain the code.
go get -u mosn.io/mosn
If the go get command fails, manually create a project.
# Access the src directory under GOPATH. cd $GOPATH/src # Create the mosn.io directory. mkdir -p mosn.io cd mosn.io # Clone MOSN code. git clone email@example.com:mosn/mosn.git cd mosn
The MOSN source code is finally saved to
Import the MOSN source code into the IDE
$GOPATH/src/mosn.io/mosn into your preferred Go IDE (Goland is recommended).
Compile the code
In the project’s root directory, compile the binary file of MOSN by running the following commands, depending on your machine type and the environment in which you want to execute the binary file.
Compilation with a docker image
make build // Compile a Linux 64-bit executable binary file.
Run the following command to compile a local executable binary file.
Cross-compile a Linux 64-bit executable binary file on a non-Linux machine.
Cross-compile a Linux 32-bit executable binary file on a non-Linux machine.
Find the compiled binary file in
Create an RPM package
Run the following command in the project’s root directory to create an RPM package.
Find the package in
Create a docker image
Run the following command to create a docker image.
Run the following command in the project’s root directory to start the unit test.
Run the following command in the project’s root directory to start the integration test (which takes some time).
Start MOSN from the configuration file
Run the following command to start MOSN from the configuration file.
./mosn start -c '$CONFIG_FILE'
Run MOSN samples
Refer to the example projects in the
examples directory to run samples.
Build the Service Mesh platform with MOSN
For more information, see the Istio integration.