Customization
Stoobly Scaffold Structure - Questions & Answers
After scaffolding an app and services, Stoobly creates a comprehensive directory structure in .stoobly/services/ with workflow-specific configurations, Docker compose files, and helper scripts.
Understanding Scaffold Structure
Q: Where does the scaffold get created?
A: The scaffold is created in the .stoobly/services/ directory within your application directory.
Example:
# Create app
stoobly-agent scaffold app create my-app --app-dir-path ./my-project
# Scaffold structure created at:
# ./my-project/.stoobly/services/Q: What is the overall structure of a scaffolded app?
A: The scaffold contains core services (build, entrypoint, gateway, stoobly-ui), user-defined services, a Makefile, and workflow-specific configurations.
Example:
.stoobly/services/
├── Makefile # Main Makefile for workflow commands
├── build/ # Build service (Docker only)
│ ├── mock/
│ ├── record/
│ └── test/
├── entrypoint/ # Entrypoint service (Docker only)
│ ├── mock/
│ ├── record/
│ └── test/
├── gateway/ # Gateway service (Docker only)
│ ├── mock/
│ ├── record/
│ └── test/
├── stoobly-ui/ # Stoobly UI service
│ ├── exec/
│ ├── mock/
│ └── record/
└── your-service/ # Your custom services
├── mock/
├── record/
└── test/Docker vs Local Runtime Differences
Q: What's the difference between --run-on docker and --run-on local?
A: Docker runtime creates additional core services (build, entrypoint, gateway) for containerized execution, while local runtime creates a simpler structure for native execution.
Example:
Q: Which files are created for Docker runtime only?
A: Docker runtime creates build/, entrypoint/, and gateway/ service directories with Docker Compose configurations.
Example:
Q: Which files are created for both Docker and local runtime?
A: Both runtimes create the Makefile, stoobly-ui service, and user-defined service directories.
Example:
Understanding the Entrypoint Service
Q: What is the entrypoint service?
A: The entrypoint service is the main container that runs your application or test code within the Docker network. It's where your actual service or test scripts execute.
Example:
Q: What is the purpose of the entrypoint service?
A: The entrypoint service provides a containerized environment where your application runs and makes HTTP requests that get intercepted by Stoobly's proxy through the gateway.
Example:
Q: When is the entrypoint service used?
A: The entrypoint service is used in Docker runtime workflows to run your application code, test suites, or any process that makes HTTP requests you want to intercept.
Example:
Q: How do I customize the entrypoint service?
A: Edit the docker-compose.yml file in the entrypoint workflow directory to add your application container, environment variables, or volumes.
Example:
Q: What's the difference between configure and init scripts?
A: The configure script runs before services start to set up Stoobly configuration, while init scripts run during container initialization.
Example:
Understanding Other Core Services
Q: What is the build service?
A: The build service creates the Docker image for Stoobly agent with your application's context, ensuring consistent environments across workflows.
Example:
Q: What is the gateway service?
A: The gateway service runs Traefik reverse proxy that routes HTTP traffic from your services through Stoobly's proxy for interception.
Example:
Q: What is the stoobly-ui service?
A: The stoobly-ui service provides the web interface for managing requests, scenarios, and configuration. It's available in both Docker and local runtimes.
Example:
Service-Specific Directories
Q: What files are created for each user-defined service?
A: Each service gets workflow directories (mock, record, test) with docker-compose.yml, configure script, init script, lifecycle hooks, fixtures, and public directory.
Example:
Q: What is the purpose of the configure script?
A: The configure script sets up Stoobly configuration (rewrite rules, match rules, firewall rules) before the workflow starts.
Example:
Q: What is the purpose of the init script?
A: The init script runs custom initialization logic during service startup, such as database setup, file preparation, or environment checks.
Example:
Q: What is the docker-compose.yml file used for?
A: The docker-compose.yml defines the service container, its dependencies, networks, environment variables, and how it connects to other services.
Example:
Q: What is the fixtures.yml file used for?
A: The fixtures.yml file contains mock response data for the service, used during mock and test workflows.
Example:
Q: What is the lifecycle_hooks.py file used for?
A: The lifecycle_hooks.py file contains Python functions that modify requests/responses during interception.
Example:
Q: What is the public/ directory used for?
A: The public/ directory serves static files for mocking, useful for serving images, CSS, JavaScript, or other assets.
Example:
Workflow-Specific Configurations
Q: How are workflows organized?
A: Each service has separate directories for mock, record, and test workflows, allowing different configurations per workflow.
Example:
Q: Can I have different configurations for different workflows?
A: Yes, each workflow directory has its own configure script, docker-compose.yml, and fixtures, allowing complete customization per workflow.
Example:
Custom Workflows
Q: How do I create a custom workflow?
A: Use scaffold workflow create to create a new workflow based on a template (mock, record, or test).
Example:
Q: What gets created for a custom workflow?
A: A custom workflow gets the same structure as standard workflows: configure, docker-compose.yml, init, fixtures.yml, lifecycle_hooks.py, and public/.
Example:
Temporary Runtime Files
Q: What is the .stoobly/tmp/ directory?
A: The tmp/ directory contains runtime files generated during workflow execution, including logs, run scripts, and Traefik configuration.
Example:
Q: What is the run.sh script?
A: The run.sh script is auto-generated by the scaffold workflow up command and contains the Docker Compose commands to start the workflow.
Example:
Practical Examples
Q: How do I add my application to the entrypoint service?
A: Edit the entrypoint docker-compose.yml to include your application container.
Example:
Q: How do I run my test suite in the entrypoint?
A: Configure the entrypoint service with your test command and ensure it uses the proxy.
Example:
Q: How do I add environment variables to my service?
A: Add environment variables in the docker-compose.yml file for your service.
Example:
Q: How do I mount volumes for my service?
A: Add volume mounts in the docker-compose.yml to share files between host and container.
Example:
Troubleshooting
Q: How do I debug scaffold issues?
A: Check the generated files in .stoobly/services/ and .stoobly/tmp/, and use --dry-run to see what commands would execute.
Example:
Q: Where can I find workflow logs?
A: Workflow logs are stored in .stoobly/tmp/<workflow>/logs/.
Example:
Q: How do I verify my service configuration?
A: Check the service's docker-compose.yml and run the configure script manually.
Example:
Quick Reference
Q: What are the key directories in a scaffold?
A: Here's a quick reference of important directories:
Example:
Q: What files can I customize?
A: You can customize configure scripts, docker-compose.yml, fixtures.yml, lifecycle_hooks.py, and add files to public/.
Example:
Last updated
Was this helpful?