LogoRevali

Build Construct

Assets to be generated during the build process

A Build Construct is what generates the build assets. These assets can be anything from a Dockerfile to a Makefile to a shell script. The code generated by a Build Construct is the code that will be executed on the developer's machine to build the server in a production-ready state.

Creating a Build Construct#

To create a Build Construct, you need to set the is_build field in the construct.yaml file to true. This tells Revali that this construct is a Build Construct.

constructs:
    - name: my_construct
      is_build: true
      ...

Pre-Build and Post-Build Hooks#

A Build Construct can have two hooks: preBuild and postBuild. These hooks are executed before and after the build process, respectively.

These hooks can be used to perform any additional tasks that are required before or after the build process. For example, you can use the preBuild hook to verify for the presence of a required tool or the postBuild hook to deploy the built server.

import 'package:revali_construct/revali_construct.dart';

class MyConstruct extends BuildConstruct {
    const MyConstruct();

    @override
    BuildDirectory generate(RevaliBuildContext context, MetaServer server) {
        ...
    }

    @override
    Future<void> preBuild(RevaliBuildContext context, MetaServer server) async {
        ...
    }

    @override
    Future<void> postBuild(RevaliBuildContext context, MetaServer server) async {
        ...
    }
}