Scaffolding a Service

Background

An app will likely depend on one or more services. Scaffolding a service will by default create the following workflows - record, mock, and test. It additionally will enable creating custom workflows for individual services.

Steps to Scaffold a Service

  1. Run the scaffold service create command in the root of your app directory:

stoobly-agent scaffold service create \
    --hostname <SERVICE-HOSTNAME> \
    --scheme <SERVICE-SCHEME> \
    --port <SERVICE-PORT> \
    --workflow mock \
    --workflow record \
    --workflow test \
    <SERVICE-NAME>

For example:

stoobly-agent scaffold service create \
    --hostname api.sampleapis.com \
    --scheme https \
    --port 443 \
    --workflow mock \
    --workflow record \
    --workflow test \
    sampleapis
  1. After running the command, the following files will be created:

$ ls -a .stoobly/docker/sampleapis
.config.yml .docker-compose.base.yml mock record test

From the above, we can see that folders for mock, record, and test workflows are created by default.

  1. Define the hostname

Next, an entry in /etc/hosts should be added for each of your services that have a hostname. This will allow those defined services to be discoverable and requests to them will route-able through the local container proxies.

echo '0.0.0.0 api.sampleapis.com' | sudo tee -a /etc/hosts
  1. For local services, define them using Docker Compose

As a reminder, "local" services are ones you want to run. These are often services your team owns.

"External" services are ones you do not own such as ones owned by other teams or third-party APIs

Adding Custom Container Services

Now that your service is created, you can now run workflows!

Last updated