The Build Architecture
Did you mean?
If you were looking to build an emulator server, check out the emulator servers.
The emulator server is packaged using a build pattern that works with rules_oci
of Bazel to attempt to create hermetic container images. This pattern breaks the build process into distinct stages, with each stage focusing on a specific part of the process. By separating the build into layers, you can tell when things have changed.
What is: Hermetic
A hermetic build is like baking a cake in a sealed factory where everything is already inside—perfectly measured ingredients, the same oven, and even the same temperature every time. Since nothing from the outside can change it, the cake will always turn out exactly the same, no surprises.
Think of this process like baking a cake:
- You gather your ingredients (dependencies).
- Mix and bake the cake (build the server).
- Setup the decorations & packaging (runtime environment).
- Package the cake & add the decorations (release image ready to serve).
Here's how this pattern works:
flowchart TD
A[Build Deps Image] --> B[Builder Image]
B -->|Build Artifacts| D[Release Image]
C[Runtime Image] -->|Runtime Dependencies| D
classDef deps stroke-width:2px;
classDef builder stroke-width:2px;
classDef runtime stroke-width:2px;
classDef release stroke-width:2px;
class A deps;
class B builder;
class C runtime;
class D release;
The Four Layers of the Build Pattern
Build Dependencies Image
Think of this as your pantry of ingredients
This image contains all the tools, libraries, and system packages needed to build the emulator server. It includes things like compilers, standard libraries, and other software required to turn the source code into a working program.
- Purpose: Provides the foundation for the build process.
- Key Point: It's not part of the release image. It's only used to help "mix the ingredients."
Builder Image
This is like the kitchen where you prepare the cake
This image builds on top of the build dependencies image by bundling the source code. Using the tools provided by the dependencies image, it can compile the source into working server binaries (the actual program files that run the game server).
- Purpose: Runs the build process, producing the emulation server binaries (the server).
- Key Point: Includes a specific version of the source code, ensuring the same result every time.
Runtime Image
Now the cake is baked, and you've cleaned up the kitchen. Only the cake remains
This image provides a clean, minimal environment containing only the libraries and system packages necessary to run the server—nothing extra. It excludes all build tools and unnecessary files.
- Purpose: Provides the environment where the emulator server will run.
- Key Point: Smaller, faster, and less to go wrong because it doesn't include unnecessary tools.
Release Image
This is the beautifully decorated cake, ready to serve.
This image builds on top of the runtime image by incorporating the built server binaries from the Builder stage and adding any default configuration files. This is the image you'll actually deploy to run your emulator server.
- Purpose: The complete, deployable server image.
- Key Point: Contains everything needed to run the emulation server in production.