Configure Polywrap build pipeline
In this section, we'll explore the Polywrap's build pipeline and how to configure it. This guide will help you understand the follow concepts:
- Polywrap's build pipeline
- The YAML format
- Minimal required schema for the Polywrap YAML file
- Customizing the build YAML file
- Customizing the Dockerfile
#
Polywrap build pipelineThe build process begins by running yarn build
. The command will execute a series of functions that will search for the default manifest, graphql schemas, and Polywrap implementations, and then compile these files into a Docker image. While Polywrap's default is usable for many projects, the toolchain offers a highly configurable build pipeline for those who need more customization.
#
The YAML formatPolywrap package manifests are formatted in YAML. The YAML format was chosen because of its easy of human readability. If you're not familiar with the YAML syntax, you can learn the basics at Learn YAML in Y Minutes.
#
Minimal required schemaA package manifest must include a set of required items. This is represented by the minimal required schema shown below as well as an example showing the "default" manifest.
- Schema
- Example
#
Customizing the YAML build fileThe manifest shown above does not require configuring the build process. When you run yarn build
, the following default build YAML file is used:
To customize the build, first create a new YAML file in the project's root directory and name it web3api.build.yaml
. Then, in the original YAML file, add a key called build
with the path of the custom build YAML as the value.
In the web3api.build.yaml
file, you could then customize your build. In the code below, you can see the schema as well as an example custom build YAML:
- Schema
- Example
#
Customizing the DockerfileFor those who need even more customization of the build pipeline, Polywrap allows for customizing the Dockerfile. The Dockerfile is a text file containing instructions for Docker to build images. You can learn more about it at Docker's documentation.
In the context of Polywrap, it allows you to fully customize your Docker image build steps. To customize your Dockerfile, first, either copy the default Dockerfile from the /build
folder or create your own.
Then, in the web3api.build.yaml
file, add a key called dockerfile
with the path of the newly created Dockerfile as the value. That's it! Now, you can customize the Dockerfile to your heart's content.
You can also name your custom Dockerfile with a mustache file extension like so Dockerfile.mustache
, which would enable Mustache capabilities for your Dockerfile. Mustache is a logic-less template sysetm that can be used for HTML, config files, and more. Learn more about Mustache here.
With Mustache, your Dockerfile will be able to recognize variable tags set by the web3api.build.yaml
file. For example, in your web3api.build.yaml
file, you could have a key such as foo
with the value hey
like so:
To use this variable in your Mustache-enabled Dockerfile, simply use curly braces like so: