Improve services docs (#927)

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
This commit is contained in:
6543 2022-05-19 20:27:50 +02:00 committed by GitHub
parent a8c23e9771
commit 328eb98109
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
```