Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ee887733
Commit
ee887733
authored
Aug 28, 2021
by
Systemkern
Committed by
Suzanne Selhorn
Aug 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentation for gitlab-runner issue 1042
parent
f583dad2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
doc/ci/services/index.md
doc/ci/services/index.md
+58
-0
No files found.
doc/ci/services/index.md
View file @
ee887733
...
...
@@ -186,6 +186,38 @@ following these rules:
To override the default behavior, you can
[
specify a service alias
](
#available-settings-for-services
)
.
### Connecting Services
> - [Deployed behind a feature flag](https://gitlab.com/gitlab-org/gitlab-runner/-/issues/11751).
You can use inter-dependent services with complex jobs, like end-to-end tests where an
external API needs to communicate with its own database.
This behavior is currently behind a
[
feature flag
](
https://docs.gitlab.com/runner/configuration/feature-flags.html
)
,
which you can enable by defining the
`FF_NETWORK_PER_BUILD`
CI/CD variable
either in the job or globally.
For example, for an end-to-end test for a front-end application that uses an API, and where the API needs a database:
```
yaml
end-to-end-tests
:
image
:
node:latest
services
:
-
name
:
selenium/standalone-firefox:${FIREFOX_VERSION}
alias
:
firefox
-
name
:
registry.gitlab.com/organization/private-api:latest
alias
:
backend-api
-
postgres:9.6.19
variables
:
FF_NETWORK_PER_BUILD
:
1
POSTGRES_PASSWORD
:
supersecretpassword
BACKEND_POSTGRES_HOST
:
postgres
script
:
-
npm install
-
npm test
```
## Passing CI/CD variables to services
You can also pass custom CI/CD
[
variables
](
../variables/README.md
)
...
...
@@ -311,6 +343,32 @@ services:
The syntax of
`command`
is similar to
[
Dockerfile's `CMD`
](
https://docs.docker.com/engine/reference/builder/#cmd
)
.
## Using `services` with `docker run` (Docker-in-Docker) side-by-side
In addition to letting services talk to each other via
`FF_NETWORK_PER_BUILD`
,
containers started via
`docker run`
can also connect to services provided by GitLab.
This can be useful in case booting the service is expensive or time consuming.
This technique will allow running tests from multiple different client environments,
while only booting up the tested service once.
```
yaml
access-service
:
stage
:
build
image
:
docker:19.03.1
services
:
-
docker:dind
# necessary for docker run
-
tutum/wordpress:latest
variables
:
FF_NETWORK_PER_BUILD
:
"
true"
# activate container-to-container networking
script
:
|
docker run --rm --name curl \
--volume "$(pwd)":"$(pwd)" \
--workdir "$(pwd)" \
--network=host \
curlimages/curl:7.74.0 curl "http://tutum-wordpress"
```
## How Docker integration works
Below is a high level overview of the steps performed by Docker during job
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment