From 328eb98109b869b3ccda72983ff02534f8a73b6d Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 19 May 2022 20:27:50 +0200 Subject: [PATCH] Improve services docs (#927) Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com> --- docs/docs/20-usage/60-services.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/docs/20-usage/60-services.md b/docs/docs/20-usage/60-services.md index c0a95086d..62039fe36 100644 --- a/docs/docs/20-usage/60-services.md +++ b/docs/docs/20-usage/60-services.md @@ -1,6 +1,10 @@ # Services -Woodpecker provides a services section in the YAML file used for defining service containers. The below configuration composes database and cache containers. +Woodpecker provides a services section in the YAML file used for defining service containers. +The below configuration composes database and cache containers. + +Services are accessed using custom hostnames. +In the example below, the MySQL service is assigned the hostname `database` and is available at `database:3306`. ```diff pipeline: @@ -18,8 +22,6 @@ services: image: redis ``` -Services are accessed using custom hostnames. In the above example the mysql service is assigned the hostname `database` and is available at `database:3306`. - ## Configuration Service containers generally expose environment variables to customize service startup such as default usernames, passwords and ports. Please see the official image documentation to learn more. @@ -77,3 +79,21 @@ services: database: image: mysql ``` + +## Complete Pipeline Example + +```yml +services: + database: + image: mysql + environment: + - MYSQL_DATABASE=test + - MYSQL_ROOT_PASSWORD=example +pipeline: + get-version: + image: ubuntu + commands: + - ( apt update && apt dist-upgrade -y && apt install -y mysql-client 2>&1 )> /dev/null + - sleep 30s # need to wait for mysql-server init + - echo 'SHOW VARIABLES LIKE "version"' | mysql -uroot -hdatabase test -pexample +```