Build
A build takes application source and converts it to an artifact.
An artifact is the packaged form of an application required for deployment on your target platform: a container image, VM image, or maybe a simple zip file. The build process may also include an optional push operation to push the built artifact to a registry so that it is available for the deployment platform.
A build is triggered during a waypoint up
or using the dedicated
waypoint build
command.
Configuration
The build is configured using the build
stanza within an app
stanza:
Build Methods
Waypoint includes these builtin plugins to build a Docker image for your app.
You can also create a plugin to extend Waypoint with your own builder.
Choosing How to Build Your App
Docker Build
Example configuration
The Docker plugin leverages the application Dockerfile
to create a container
image. If you application works with the docker build
Docker command
it should work well the Waypoint Docker plugin.
Reference the Docker plugin for all configuration options.
Docker Pull Build
Example configuration
The Docker Pull plugin is ideal when you prefer to use an existing Docker image as-is
without rebuilding it.
This plugin performs a docker pull
. The plugin injects the Waypoint Entrypoint by
default, which can be disabled.
Cloud Native Buildpacks
Example configuration
Cloud Native Buildpacks are a fast way to get started
creating a containerized application without writing a Dockerfile
. Buildpacks
take application source and build a container for you if there are matching
buildpacks. The "pack" plugin defaults to Heroku Buildpacks with a builder image
located on Docker Hub at
heroku/buildpacks:18.
Customizing the Buildpack Launch Command
When using the default Heroku Buildpack, you can customize the command that
starts your server process within the workload. This is done by using
adding a Procfile
to the project directory.
An example of this model in practice would be the build process generating the static binaries for your web service within your application image, and then executing the necessary commands to start ExpressJS to host those static files.
See the waypoint-examples
repository for more examples of this model. The Procfile
syntax
is web: <server process> <server file>
. A sample Procfile with this syntax is below:
You will need to include a file that can be executed by a server
process (server.js
above) in order to use this capability.
The ability to use a Procfile is dependent on the Buildpack provider. This capability can be added to alternative buildpack providers, however you will need to build your own builder image and store it in an accessible repository. Please see the Buildpack provider's documentation for further details around this capability.
Configuring an Alternative Buildpack Provider
Provider | Builder Image |
---|---|
Heroku | heroku/buildpacks:18 |
Paketo | paketobuildpacks/builder:base |
Google Cloud Platform | gcr.io/buildpacks/builder:latest |
Several waypoint.hcl
adjustments may be required to enable alternative builders.
- The
builder
variable of thepack
build plugin should explicitly specify the buildpacks builder image likepaketobuildpacks/builder:base
. - The
service_port
variable of the deploy plugin must match the buildpacks port. Paketo buildpacks commonly use8080
and the default Waypointservice_port
is3000
.
Paketo buildpacks example waypoint.hcl
:
GCP buildpacks example waypoint.hcl
:
Buildpack Troubleshooting
If you have a problem using Cloud Native Buildpacks, try using the pack
CLI
directly with Docker
similar to this example.
Registry
In the most common use cases of using static and on-demand runners, the registry must be specified. The registry block is only optional when building an artifact that can be accessed directly by the deploy plugin (such as, with in the same Docker daemon).
If a registry is specified, the deployment step will use the artifact in the registry. If a registry is not specified, the deployment step will use the artifact that is the result of the build.
Example Docker Registry Configuration
Reference the AWS ECS plugin documentation for an AWS Elastic Container Registry example.
Scenarios for a Registry
An example of a scenario requiring a registry: Kubernetes deployments need access to the Docker image that is built, but a Docker build process often produces a local Docker image. The registry configuration is used to push the locally built Docker image to the remote registry.
An example of a scenario that does not require a registry: AMIs (Amazon Machine Images) are registered directly with Amazon and are never local artifacts. Therefore, a separate registry configuration is not required since the build/registry phases are one and the same.
Private Registries
When using the docker plugin to push images to private container registries, the registry authentication may either be configured explicitly or "out of band" from Waypoint.
Explicit Authentication
Create a file with the registry authentication:
Reference the file in waypoint.hcl
:
Authentication with Vault
Waypoint can read dynamic config variables directly from Vault:
This means at runtime, when Waypoint goes to push the built application artifact, the registry username and password will be loaded directly from Vault and used to authenticate to the remote private repository.
Out of Band Authentication
Waypoint invokes Docker APIs, so if you have authentication configured with
docker login
or similar, then Waypoint does not need to authenticate directly
to the private registry. Here is an example:
where /path/to/mysecret
is a file with your secret as contents and USERNAME
is replaced with your actual registry username. Therefore Waypoint does not need
to know the private registry credentials since it invokes the Docker API, which
is configured with the private registry credentials. Here is an example
waypoint.hcl
registry configuration when relying on Docker's authentication:
Platforms and Private Registries
Reference Deploy Private Registry documentation for details on how to configure deployment for private registries.