Skip to content

Commit 302341a

Browse files
feat(readme): Add config section to readme (#234)
* add config section to readme
1 parent ce0fec3 commit 302341a

File tree

1 file changed

+121
-9
lines changed

1 file changed

+121
-9
lines changed

README.md

+121-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ A standalone cli tool used to manage dependencies for services. It simplifies th
66

77
`devservices` reads configuration files located in the `devservices` directory of your repository. These configurations define services, their dependencies, and various modes of operation.
88

9-
## Installation
10-
11-
The recommended way to install devservices is through a virtualenv in the requirements.txt.
12-
13-
```
14-
devservices==1.0.17
15-
```
16-
17-
189
## Usage
1910

2011
devservices provides several commands to manage your services:
@@ -31,3 +22,124 @@ NOTE: service-name is an optional parameter. If not provided, devservices will a
3122
- `devservices list-dependencies <service-name>`: List all dependencies for a service and whether they are enabled/disabled.
3223
- `devservices update` Update devservices to the latest version.
3324
- `devservices purge`: Purge the local devservices cache.
25+
26+
## Installation
27+
28+
### 1. Add devservices to your requirements.txt
29+
30+
The recommended way to install devservices is through a virtualenv in the requirements.txt. Once that is installed and a devservices config file is added, you should be able to run `devservices up` to begin local development.
31+
32+
```
33+
devservices==1.0.17
34+
```
35+
36+
### 2. Add devservices config files
37+
38+
Each repo should have a `devservices` directory with a `config.yml` file. This file is used to define services, dependencies, and modes. Other files and subdirectories in the `devservices` directory are optional and can be most commonly used for volume mounts.
39+
40+
The configuration file is a yaml file that looks like this:
41+
42+
```yaml
43+
# This is a yaml block that holds devservices specific configuration settings. This is comprised of a few main sections:
44+
# - version: The version of the devservices config file. This is used to ensure compatibility between devservices and the config file.
45+
# - service_name: The name of the service. This is used to identify the service in the config file.
46+
# - dependencies: A list of dependencies for the service. Each dependency is a yaml block that holds the dependency configuration. There are two types of dependencies:
47+
# - local: A dependency that is defined in the config file. These dependencies do not have a remote field. These dependency definitions are specific to the service and are not defined elsewhere.
48+
# - remote: A dependency that is defined in the devservices directory in a remote repository. These configs are automatically fetched from the remote repository and installed. Any dependency with a remote field will be treated as a remote dependency. Example: https://github.com/getsentry/snuba/blob/59a5258ccbb502827ebc1d3b1bf80c607a3301bf/devservices/config.yml#L8
49+
# - modes: A list of modes for the service. Each mode includes a list of dependencies that are used in that mode.
50+
x-sentry-service-config:
51+
version: 0.1
52+
service_name: example-service
53+
dependencies:
54+
example-dependency-1:
55+
description: Example dependency defined in the config file
56+
example-dependency-2:
57+
description: Example dependency defined in the config file
58+
example-remote-dependency:
59+
description: Remote dependency defined in the `devservices` directory in the example-repository repo
60+
remote:
61+
repo_name: example-repository
62+
branch: main
63+
repo_link: https://github.com/getsentry/example-repository.git
64+
mode: default # Optional field, mode to run remote dependency in that defaults to `default`
65+
modes:
66+
default: [example-dependency-1, example-remote-dependency]
67+
custom-mode: [example-dependency-1, example-dependency-2, example-remote-dependency]
68+
69+
# This will be a standard block used by docker compose to define dependencies.
70+
#
71+
# The following fields are important to all dependencies:
72+
# - image: The docker image to use for the dependency.
73+
# - ports: The ports to expose for the dependency. Please only expose ports to localhost(127.0.0.1)
74+
# - healthcheck: The docker healthcheck to use for the dependency.
75+
# - environment: The environment variables to set for the dependency.
76+
# - extra_hosts: The extra hosts to add to the dependency.
77+
# - networks: The networks to add to the dependency. In order for devservices to work properly, the dependency must be on the `devservices` network.
78+
# - labels: The labels to add to the dependency. The `orchestrator=devservices` label is required for devservices to determine a container is managed by devservices.
79+
# - restart: The restart policy to use for the dependency.
80+
#
81+
# These fields are optional:
82+
# - ulimits: The ulimits to set for the dependency. This is useful for setting resource constraints for the dependency.
83+
# - volumes: The volumes to mount for the dependency. This is useful for mounting data volumes for the dependency if data should be persisted between runs. It can also be useful to use a bind mount to mount a local directory into a container. Example of bind mounting clickhouse configs from a local directory https://github.com/getsentry/snuba/blob/59a5258ccbb502827ebc1d3b1bf80c607a3301bf/devservices/config.yml#L44
84+
# - command: The command to run for the dependency. This can override the default command for the docker image.
85+
# For more information on the docker compose file services block, see the docker compose file reference: https://docs.docker.com/reference/compose-file/services/
86+
services:
87+
example-dependency-1:
88+
image: ghcr.io/getsentry/example-dependency-1:1.0.0
89+
ulimits:
90+
nofile:
91+
soft: 262144
92+
hard: 262144
93+
healthcheck:
94+
test: wget -q -O - http://localhost:1234/health
95+
interval: 5s
96+
timeout: 5s
97+
retries: 3
98+
environment:
99+
EXAMPLE_ENV_VAR: example-value
100+
volumes:
101+
- example-dependency-1-data:/var/lib/example-dependency-1
102+
restart: unless-stopped
103+
# Everything below this line is required for devservices to work properly.
104+
ports:
105+
- 127.0.0.1:1234:1234
106+
extra_hosts:
107+
host.docker.internal: host-gateway
108+
networks:
109+
- devservices
110+
labels:
111+
- orchestrator=devservices
112+
113+
example-dependency-2:
114+
image: ghcr.io/getsentry/example-dependency-2:1.0.0
115+
command: ["devserver"]
116+
healthcheck:
117+
test: curl -f http://localhost:2345/health
118+
interval: 5s
119+
timeout: 5s
120+
retries: 3
121+
environment:
122+
EXAMPLE_ENV_VAR: example-value
123+
restart: unless-stopped
124+
# Everything below this line is required for devservices to work properly.
125+
ports:
126+
- 127.0.0.1:2345:2345
127+
extra_hosts:
128+
host.docker.internal: host-gateway
129+
networks:
130+
- devservices
131+
labels:
132+
- orchestrator=devservices
133+
134+
# This is a standard block used by docker compose to define volumes.
135+
# For more information, see the docker compose file reference: https://docs.docker.com/reference/compose-file/volumes/
136+
volumes:
137+
example-dependency-1-data:
138+
139+
# This is a standard block used by docker compose to define networks. Defining the devservices network is required for devservices to work properly. By default, devservices will create an external network called `devservices` that is used to connect all dependencies.
140+
# For more information, see the docker compose file reference: https://docs.docker.com/reference/compose-file/networks/
141+
networks:
142+
devservices:
143+
name: devservices
144+
external: true
145+
```

0 commit comments

Comments
 (0)