Skip to main content

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 pipeline#

The 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 format#

Polywrap 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 schema#

A 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.

format: # Polywrap YAML format version
repository: # URL of Core toolchain repository
language: # Language that will be compiled to wasm
modules: # Modules of Polywrap schema and implementation
query: # Modules can be for either query or mutations
schema: # Path to graphql schema
module: # Path to Polywrap implementation
import_redirects: # Redirects enabling the import of plugins
- uri: # URI resolving to the plugin schema
schema: # Graphql schema for imported plugin

Customizing the YAML build file#

The manifest shown above does not require configuring the build process. When you run yarn build, the following default build YAML file is used:

format: 0.0.1-prealpha.2
name: build-env
node_version: 14.16.0
- ./src
- ./package.json

To customize the build, first create a new YAML file in the project's root directory and name it Then, in the original YAML file, add a key called build with the path of the custom build YAML as the value.

format: 0.0.1-prealpha.2
language: wasm/assemblyscript
build: ./
schema: ./src/query/schema.graphql
module: ./src/query/index.ts
- uri: w3://w3/logger
schema: ../../core-apis/logger/schema.graphql

In the file, you could then customize your build. In the code below, you can see the schema as well as an example custom build YAML:

format: # Polywrap YAML Format version
docker: # Configure the name of Docker image
name: # Name of the Docker image
config: # Build configuration
node_version: # Node version
include: # Files to include in build

Customizing the Dockerfile#

For 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 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.

format: 0.0.1-prealpha.2
name: build-env
dockerfile: ./Dockerfile

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 file. For example, in your file, you could have a key such as foo with the value hey like so:

format: 0.0.1-prealpha.2
name: build-env
dockerfile: ./Dockerfile.mustache
foo: hey

To use this variable in your Mustache-enabled Dockerfile, simply use curly braces like so:

{{ foo }}