Developer Center

Static

Add static components to a service to deploy static websites, assets and even binaries!

Static components

Static components let you deploy code to an https endpoint that is either public or internal.

The most common use case of a static component is to deploy a JAMstack app or static site.

Static components can also be used to deploy CLI binaries (this is how we deploy pt).

Minimum config

A minimum static-public component config looks like:

components:
  - type: static-public
    cmd: /app/scripts/cmd
    route: www.example.com

A minimum static-internal component config looks like:

components:
  - type: static-internal
    cmd: /app/scripts/cmd
    route: www-internal.example.com

The build script in each of these configs builds and copies the compiled assets into the `/bundle` directory.

An example of a static component configured to share code from the local code directory into the running service, for live reloads.

components:
  - type: static-public
    route: www.example.com

    # call yarn build and copy output to /bundle
    cmd: /app/scripts/build

    # run yarn dev locally and listen on port 3000 for live reloading, withthe local src directory being synced into the
    # container via a shared mount.
    dev_cmd: /app/scripts/dev
    dev_port: 3000
    dev_mounts:
      - src => /app/src

This example is useful for running a modern node website development server inside a container. It will configure mounting so that when you run pt dev, your code is synced into your container and live-reload changes occur.

You can run pt schema validate at any time to validate a service config.

Fields

  • type: component type (required)
  • cmd: command to run inside the container that will build and copy static assets to /bundle (required)
  • route (required)

Optional

configs for serving websites

  • not_found_path: page to use when a page is not found (default: notfound.html)
  • index_path: homepage path to use (default: index.html)

configs for local dev

  • dev_cmd: development command to run instead of building assets in pt dev
  • dev_port: port to serve traffic in pt dev
  • dev_mounts: list of local directories to mount into pt dev

configs for serving files

  • versions: list of additional git ref versions to deploy with this app
  • manifest: whether to create a manifest.json file with file contents and checksums

Versions and manifests are useful when creating a static site to distribute a binary.

Provisioned resources

Each static component provisions

  • cloud storage bucket
  • internal ip address
  • dns entry

Additionally, each public static component provisions the following:

  • CDN configuration
  • WAF configuration
  • managed SSL certificate