Skip to content

Commit

Permalink
feat: add simple Compose tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
georg committed Apr 26, 2024
1 parent a72c1c8 commit ae42574
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
67 changes: 67 additions & 0 deletions docs/guides/compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
sidebar_position: 6
---

# Codezero Compose

Codezero Compose is a way to define your Consume and Serve sessions in a `codezero-compose.yaml` file which can be checked into your project repository.

If you have a `codezero-compose.yaml` or `codezero-compose.yml` file in your current directory, you can start your sessions with the following command:

```sh
czctl compose start
```

## The Compose File

The following `codezero-compose.yaml` file will set the primary namespace to `sample-project`, consume all services within that namespace except the `sample-project-core` service and serve a user variant of the `sample-project-core` service.

```yaml
version: "1.0"
consume:
primaryNamespace: sample-project
rules:
- sample-project/*
- '!sample-project/sample-project-core'
serve:
- namespace: sample-project
service: sample-project-core
ports:
- local: 3000
remote: 3000
```
## Templating
A template directive is enclosed in `{{` and `}}` blocks.
Your local environment variables are exposed in the `Env` template object.
The following example shows how you can use the `USER` environment variable as a custom header value.

```yaml
version: "1.0"
consume:
primaryNamespace: sample-project
rules:
- sample-project/*
- '!sample-project/sample-project-core'
serve:
- namespace: sample-project
service: sample-project-core
ports:
- local: 3000
remote: 3000
condition:
type: 'header'
key: 'X-Custom-Header'
value: 'user-{{ .Env.USER }}'
```

In the above example, if the `USER` environment variable would be set to `joe`, any traffic to the `sample-project-core` service where the HTTP header `X-Custom-Header` is set to `user-joe` would be directed to your local machine.

## Stopping all Consume and Serve sessions

To stop all Consume and Serve sessions simply run the following command:

```sh
czctl reset
```
2 changes: 1 addition & 1 deletion docs/guides/vpn.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 7
---

# Coexisting with VPNs
Expand Down
2 changes: 1 addition & 1 deletion docs/references/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To update your Codezero Space Agent, follow these steps:

### Features

* New command: `czctl compose start` to start consume and serve sessions based on rules in `codezero-compose.yml`.
* New command: `czctl compose start` to start consume and serve sessions based on rules in `codezero-compose.yml`. You can read about this new feature in the [Codezero Compose](../guides/compose) guide.

## 2.1.1

Expand Down

0 comments on commit ae42574

Please sign in to comment.