This holds the demos I present during our Community Calls.
Currently, the project is a simple Go library for greeting. It is located in the greeting package.
It is used by 2 apps:
- a CLI
- a 3D frontend
Dagger Pipeline using the Dagger Node SDK
The CLI is straightforward, and thanks to Go, we can cross-compile in our pipeline just changing the
classic Go environment variables GOOS
and GOARCH
. A simple for each
allows to cross compile.
N.B.: the for each
is a little more involved than the JS forEach
as we have async
functions to call.
N.B.2: I'm not a JS/TypeScript expert :p
The app shows a rotating Earth in space. The api uses the greeting
package to generate a greeting 2D Texture that is then applied on the 3D model of the Earth.
The simple cross-compiling of Go cannot operate here. The g3n 3D game engine access some native libraries (mostly the 3D hardware drivers). Therefore, we need CGO
. And we need the native libraries to be present on the system when compiling.
We use Dagger capacity to use multi arch images, and pull the right image for the GOARCH
we're building for.
The apt-get
will get the right libraries (amd64
or arm64
), and then it will build and link correctly for the aimed platform.
The other tricky part is that a 3D app needs some assets (images/textures) or external scripts (shader files). We use Dagger to copy them alongside the binary so we can execute the binary and it can find its assets.
N.B.: in Go, I could actually use go:embed
to embed those assets in my binary, but for other 3D projects in C++, you don't have this possibility natively and you need some strategy for this. So I decided to show how to do it if you were in this case.