Build Baetyl From Source¶
Compared to the quick installation of Baetyl, users can compile Baetyl from source to get the latest features.
Before compiling, users should configure the build environment. So this article consist of two parts: environment configuration and source code compilation.
Environment Configuration¶
Linux Platform¶
Install Go¶
Go to related resources to complete the download, then:
tar -C /usr/local -zxf go$VERSION.$OS-$ARCH.tar.gz # Decompress the Go archive to the /usr/local directory
export PATH=$PATH:/usr/local/go/bin # Configuring environment variables
export GOPATH=yourpath # GOPATH setting
go env # View Go's environment variables
go version # View Go's version
NOTE: Baetyl requires that the compiled version of Go should be above 1.10.0.
Install the container runtime¶
In docker container mode, Baetyl relies on docker container runtime. If docker
is not installed yet, users can install the latest version of docker (for Linux-like systems) with the following command:
curl -sSL https://get.docker.com | sh
View the version of installed docker:
docker version
NOTE:According to the Official Release Log, the version of docker lower than 18.09.2 has some security implications. It is recommended to install/update the docker to 18.09.2 and above.
For more details, please see the official documentation.
Darwin Platform¶
Install Go¶
- Install by using HomeBrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # install homebrew
brew install go
Modify the environment configuration file after the installation is complete.(e.g: ~/.bash_profile):
export GOPATH="${HOME}/go"
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
Make the environment variable take effect:
source yourfile
Create the GOPATH specified directory:
test -d "${GOPATH}" || mkdir "${GOPATH}"
- Install by using binary file
Go to related resources to complete the download, then:
tar -C /usr/local -zxf go$VERSION.$OS-$ARCH.tar.gz # Decompress the Go archive to the /usr/local directory
export PATH=$PATH:/usr/local/go/bin # Configuring environment variables
export GOPATH=yourpath # GOPATH setting
go env # View Go's environment variables
go version # View Go's version
NOTE: Baetyl requires that the compiled version of Go should be above 1.10.0.
Install the container runtime¶
Go to official page to download the .dmg file you need. Once done, double-click to open and drag docker into the application folder.
Install On Darwin
View the version of installed docker:
docker version
Source Code Compilation¶
Download Source Code¶
After completing the compilation environment configuration according to the corresponding environment, go to the Baetyl Github Page to download source code of baetyl.
go get github.com/baetyl/baetyl
Build Docker Image¶
In container mode, docker starts the module by running the image corresponding to each module, so build the mirror first with the following command:
cd $GOPATH/src/github.com/baetyl/baetyl
make clean
make image # build image
Note: Under the Darwin system, users need to specify the compilation parameters because the compiled images themselves are based on Linux system:
env GOOS=linux GOARCH=amd64 make image
The following docker images are generated by the above command:
baetyl-agent:latest
baetyl-hub:latest
baetyl-function-manager:latest
baetyl-remote-mqtt:latest
baetyl-timer:latest
baetyl-function-python27:latest
baetyl-function-python36:latest
baetyl-function-node85:latest
View the generated images with the following command:
docker images
Compile¶
cd $GOPATH/src/github.com/baetyl/baetyl
make rebuild
Note: You need to install node
and npm
beforehand because the Node 8.5 runtime module will call npm install
command to install dependencies during make
. For details, please refer to [Nodejs official website] (https://nodejs.org/en/download /).
After the compilation is completed, the following executable files will be generated in the root directory and each module directory, respectively:
baetyl
baetyl-agent/baetyl-agent
baetyl-hub/baetyl-hub
baetyl-function-manager/baetyl-function-manager
baetyl-remote-mqtt/baetyl-remote-mqtt
baetyl-timer/baetyl-timer
In addition, package.zip
files are generated in each module directory.
Install¶
Install to default path: /usr/local
。
cd $GOPATH/src/github.com/baetyl/baetyl
make install # install for docker mode with example configuration
make install-native # install for native mode with example configuration
Specify the installation path, such as installing into the output directory:
cd $GOPATH/src/github.com/baetyl/baetyl
make install PREFIX=output
On the Darwin platform, you need to set the /usr/local/var
directory to make it (and it’s subdirectories) can be bind mounted into Docker containers which would be used by Baetyl.
Mount path on Mac
Run¶
If the program is already installed to the default path: /usr/local
。
sudo baetyl start
If the program has been installed to the specified path, such as installing into the output directory:
cd $GOPATH/src/github.com/baetyl/baetyl
sudo ./output/bin/baetyl start
NOTE:
- After the baetyl is started, you can check if the baetyl has run successfully by
ps -ef | grep "baetyl"
and determine the parameters used at startup. And you can check the log file for details. Log files are stored by default in thevar/log/baetyl
directory of the working directory. - If run in docker container mode, the container runtime status can be viewed via the
docker stats
command. - To use your own image, you need to modify the image of the modules and functions in the application configuration to specify your own image.
- For custom configuration, follow the instructions in Configuration Interpretation to make the relevant settings.
Uninstall¶
If it is the default installation:
cd $GOPATH/src/github.com/baetyl/baetyl
make clean # Can be used to clean executable files generated by compilation
make uninstall # Uninstall if you install in docker mode
make uninstall-native # Uninstall if you install in native mode
If the installation path is specified, for example, it is installed into the output directory.
cd $GOPATH/src/github.com/baetyl/baetyl
make clean # Can be used to clean executable files generated by compilation
make uninstall PREFIX=output # Uninstall if you install in docker mode
make uninstall-native PREFIX=output # Uninstall if you install in native mode