Custom services
To properly test an application, you often need a database or some other service. On top of predefined services, such as MySQL, PSQL or MongoDB, you can create your own service from scratch. This feature allows you, for example, to run tests for both frontend and backend of your application, or to create a database service with custom configuration and use it in your builds.
Configuration
Custom services are available in the Services tab of build actions:
Service list
Upon adding the custom service, the following needs to be defined:
- Options. Here you define how the service communicates with other containers:
- Hostname – the ID that other services use to connect to the service
- Wait for port – if specified, the action will wait until the service is available at the provided port
Pass variables to this service – allows passing user-defined variables to the service. This option is always on as custom services have no default variables that could overwrite them.
Custom service configuration
- Image. The Docker image from which the service is launched. You can use images hosted on Docker registries, or created by pipeline actions.
- Caching. Use this option to attach the pipeline filesystem to the service if it requires access to files from version control (e.g. config files). You can also cache data in the service to speed up your builds. The mounted volumes will remain persistent between pipeline runs until the cache is cleared by the user.
Custom service configuration
Using custom images as service
Containers are launched from Docker images. By default, Buddy pulls images from the selected Docker registry. You can also use an image built by a preceding action in the pipeline. For instance, you can build separate images for backend and frontend of your application, and then use the Custom Build action to run the tests with both images attached as services:
Example pipeline
To do that, set the image location to From action in the service, and select the action that builds the image:
Selecting service image
Last modified on October 20, 2022