Quick start

This topic shows you how to quickly set up the development environment for building, testing, packaging, and running the sample code.

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

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 git@github.com:mosn/mosn.git
cd mosn

The MOSN source code is finally saved to $GOPATH/src/mosn.io/mosn.

Import the MOSN source code into the IDE

Import $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.

Local compilation

Run the following command to compile a local executable binary file.

make build-local

Cross-compile a Linux 64-bit executable binary file on a non-Linux machine.

make build-linux64

Cross-compile a Linux 32-bit executable binary file on a non-Linux machine.

make build-linux32

Find the compiled binary file in build/bundles/${version}/binary.

Create an RPM package

Run the following command in the project’s root directory to create an RPM package.

make rpm

Find the package in build/bundles/${version}/rpm.

Create a docker image

Run the following command to create a docker image.

make image

Run tests

Run the following command in the project’s root directory to start the unit test.

make unit-test

Run the following command in the project’s root directory to start the integration test (which takes some time).

make integrate

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.