# Prepare the Software to Run
To get to production, the first order of business is to build the binary that the nodes will run. If you used Ignite CLI, then you already did this under the hood with the
ignite chain serve command.
# Target platforms
Because you are going to run the nodes on different machines, they may use different operating systems and CPU types. You need to account for that when building the binary. In particular, the computer on which you build may be entirely different from the one on which you eventually run the binary. In the jargon, you need to specify the target platform(s).
What target platforms are available? Because you built your entire blockchain with Go, you can rely on Go target platforms (opens new window) for that. Or a nicely presented one such as this (opens new window). To get the targets specific to your version of Go, just run:
For instance, for
go version go1.18.3 linux/amd64, it returns:
As a side note, some of these platforms are first-class ports of Go while the others are not. If you want to only see the first class ports and have installed the
jq tool, you can run:
GOARCH keywords in the command above. You will see them again later.
The list is now much shorter:
Imagine you are going to run the node:
- On regular office Linux boxes, so target
- Also on AWS EC2 instances with a Graviton processor, so target
- Validator operators are going to generate their genesis transactions on Mac computers with Intel CPUs, so target
# Build and package
There are several ways to build an executable. Pick the one that works best for your situation.
Your Cosmos blockchain project is at heart a Go project, so you can build it with a
go build command.
First, you need to locate your
func main(). In fact, you may have more than one. For instance, choose the one in
This is all you need to do. If your computer is of the
linux/amd64 platform type, you can run:
This should return something you will recognize:
# With Ignite
Whether you prepared your project with or without Ignite, you can still build it with Ignite (opens new window). To see how to write a build command you can do:
You need to adjust the syntax of targets from
linux:amd64. Also, to give a path for the built files. In a project made by Ignite,
release is already added to the
.gitignore so it is as good a choice of build folder as any other.
This creates zipped files and checksums:
The checksum file contains:
If you want to confirm a match between the written checksum values and their calculated values, run:
This should output:
The checksum is performed on the zipped file, not the executable itself. This is just as well as you can expect to send the zipped file around. When on the computer where it needs to run, you can unzip it with:
This creates a
myprojectd executable file.
# With a
Makefile (opens new window) is just a way to keep track of potentially complex commands and summon them with simpler commands. Create your own
Makefile in the root folder of your project with:
Note the lines that add a checksum file as does Ignite. Also, make sure that if you copy paste you have a Tab before each command and not spaces.
If you do not have it yet, install the
make tool. For instance, on Ubuntu:
make you can then call a build with checksums with:
If you want to see what a vastly more complex
Makefile looks like, head to the Cosmos Hub's own
Makefile (opens new window).
# With a
Makefile within Docker
If you do not want to install Go or
make on your build computer, and have Docker (opens new window), you can:
- Reuse the
- Pick a Docker image that already has Go 1.18.3 and
golang:1.18.3(opens new window) is a good choice.
Run the command:
To keep? To modify?
Eventually, you will run these executables on computers. The command will be a perhaps-complex version of:
By default, CometBFT and the Cosmos app are launched together, run together, and communicate via sockets. This is the recommended way of launching. It is not the only way of launching, though.
You can launch CometBFT and the Cosmos app separately, and even on different computers. If you do so, ensure that only your CometBFT app can contact the Cosmos app on the ABCI.
To start only the CometBFT node, run:
192.168.0.5is the address where you launch the Cosmos app.
To start only the Cosmos app, you run:
Again, this is not recommended for performance reasons - for example, due to network latency.
To summarize, this section has explored:
- How to build the binary that the nodes will run, using
go build, Ignite CLI, a
Makefile, or a
- Different methods of deploying, such as by launching CometBFT and the Cosmos app simultaneously, or by starting either one independently of the other.
- The importance of ensuring the binary will run equally well on computers using different OS and CPU types.