Skip to content

Commit

Permalink
docs: stop using build field in docs and examples (#5700)
Browse files Browse the repository at this point in the history
When we released Bonsai we introduced the following short hand
for referencing container Build actions in container Deploy actions
via the `build` field:

```yaml
kind: Deploy
name: api
build: api
spec:
```

The longer version would be:

```yaml
kind: Deploy
name: api
dependencies: [build.api]
spec:
  image: ${actions.build.api.outputs.deploymentImageId}
  # ...
```

The short hand works for `container` Deploy actions but not for `helm`
or `kubernetes` Deploy actions. In fact using the `build` field there
sets the build context to the `.garden/build` dir of the corresponding
`build`.

This has caused a lot of confusion for users as they copy examples
containing the `build` field to `kubernetes` and `helm` Deploy actions.

A common symptom is that a Garden command will fail because it can't
find the files belonging to the Deploy action.

Furthermore, the `build` field has in general caused confusion and we
_may_ end up deprecating it.

In the meantime, this commit removes any unneeded/false usage of it in our
examples and docs.

The result is that `container` Deploy actions are slightly more
verbose but in turn we've removed a big footgun that users keep bumping
into as they copy/paste example config.

There are still legit use cases for the `build` field and I've left
those examples alone.
  • Loading branch information
eysi09 authored Feb 8, 2024
1 parent d2c6560 commit ee126a3
Show file tree
Hide file tree
Showing 61 changed files with 354 additions and 255 deletions.
6 changes: 4 additions & 2 deletions docs/getting-started/next-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ kind: Test
name: api-integ
type: container
description: A Test action for integration testing the api after its been deployed
build: api # <--- Use the api image to run the test
dependencies: [deploy.api]
dependencies: [build.api, deploy.api]
spec:
image: ${actions.build.api.outputs.deploymentImageId}
command: [./integ-tests.sh]
```
Depending on the size of your project, you may want to add a handful of actions to get started and then gradually add more as needed.
Expand Down
16 changes: 12 additions & 4 deletions docs/guides/code-synchronization.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ To configure a service for sync mode, add `sync` to your Deploy configuration to
kind: Deploy
name: node-service
type: container
build: node-service-build
dependencies:
- build.node-service-build
spec:
image: ${actions.build.node-service-build.outputs.deploymentImageId}
args: [npm, run, serve]
sync:
paths:
Expand Down Expand Up @@ -146,8 +148,10 @@ Exclusion rules can be specified on individual sync configs:
kind: Deploy
name: node-service
type: container
build: node-service-build
dependencies:
- build.node-service-build
spec:
image: ${actions.build.node-service-build.outputs.deploymentImageId}
args: [npm, run, serve]
sync:
paths:
Expand Down Expand Up @@ -189,8 +193,10 @@ To do this, you can set a few options on each sync:
kind: Deploy
name: node-service
type: container
build: node-service-build
dependencies:
- build.node-service-build
spec:
image: ${actions.build.node-service-build.outputs.deploymentImageId}
sync:
paths:
- target: /app/src
Expand Down Expand Up @@ -236,8 +242,10 @@ type: container
description: |
Here, we sync source code into the remote, and sync back the `test-artifacts` directory
(populated when we run tests) back to the local machine.
build: node-service-build
dependencies:
- build.node-service-build
spec:
image: ${actions.build.node-service-build.outputs.deploymentImageId}
args: [npm, start]
sync:
# Overrides the container's default when the service is deployed in sync mode.
Expand Down
6 changes: 4 additions & 2 deletions docs/guides/migrating-from-docker-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ apiVersion: garden.io/v1
name: backend
description: The backend server container
type: container
build: backend
dependencies:
- build.backend
- deploy.mongo
spec:
image: ${actions.build.backend.outputs.deploymentImageId}
sync:
paths:
- source: ./
Expand Down Expand Up @@ -124,10 +125,11 @@ apiVersion: garden.io/v1
name: frontend
description: The frontend server and UI components container
type: container
build: frontend
dependencies:
- build.frontend
- deploy.backend
spec:
image: ${actions.build.frontend.outputs.deploymentImageId}
env:
DANGEROUSLY_DISABLE_HOST_CHECK: true
sync:
Expand Down
6 changes: 5 additions & 1 deletion docs/guides/running-service-in-local-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ type: container
kind: Deploy
name: node-app
type: container
build: node-app
dependencies:
- build.node-app
...
spec:
image: ${actions.build.node-app.outputs.deploymentImageId}
localMode:
ports:
- local: 8090 # The port of the local app, will be used for port-forward setup.
Expand Down Expand Up @@ -195,6 +197,8 @@ kind: Deploy
name: backend
type: kubernetes # this example looks the same for helm actions (i.e. with `type: helm`)
build: backend
dependencies:
- build.backend
localMode:
ports:
- local: 8090
Expand Down
4 changes: 3 additions & 1 deletion docs/k8s-plugins/ephemeral-k8s/ingress.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ kind: Deploy
name: frontend
description: Frontend service container
type: container
build: frontend
dependencies:
- build.frontend
variables:
base-hostname: "${environment.name == 'ephemeral' ? providers.ephemeral-kubernetes.outputs.default-hostname : local.demo.garden}"
spec:
image: ${actions.build.frontend.outputs.deploymentImageId}
ports:
- name: http
containerPort: 8080
Expand Down
7 changes: 5 additions & 2 deletions docs/other-plugins/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,22 @@ Here is a configuration example for two different test suites:
kind: Test
name: my-app-unit
type: container
build: my-app
dependencies:
- build.my-app
spec:
image: ${actions.build.my-app.outputs.deploymentImageId}
args: [ npm, test ]
---
kind: Test
name: my-app-integ
type: container
build: my-app
dependencies:
- build.my-app
- deploy.my-app
spec:
image: ${actions.build.my-app.outputs.deploymentImageId}
args: [ npm, run, integ ]
```
Expand Down
6 changes: 4 additions & 2 deletions docs/using-garden/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ You add Tests when you want Garden to run your test suites for you. A minimalist
kind: Test
name: frontend-integ
type: container
build: frontend
dependencies:
- build.frontend # <- we depend on the build because the image is used when running the test
- deploy.frontend # <- we want the frontend service to be running and up-to-date for this test
spec:
image: ${actions.build.frontend.outputs.deploymentImageId} # <- use the output from the corresponding image build
args: [npm, run, integ]
```
Expand All @@ -40,10 +41,11 @@ Below is an example of a `frontend-integ` Test that checks whether the frontend
kind: Test
name: frontend-integ
type: container
build: frontend
dependencies:
- build.frontend # <- we depend on the build because the image is used when running the test
- deploy.frontend # <- we want the frontend service to be running and up-to-date for this test
spec:
image: ${actions.build.frontend.outputs.deploymentImageId} # <- use the output from the corresponding image build
args: [npm, run, integ]
```

Expand Down
3 changes: 2 additions & 1 deletion e2e/projects/open-telemetry/otlp-server/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ type: container
kind: Deploy
name: otlp-http
description: OTLP HTTP service container
dependencies: [build.otlp-http]
type: container
build: otlp-http
spec:
image: ${actions.build.otlp-http.outputs.deploymentImageId}
ports:
- name: http-otlp
containerPort: 8080
Expand Down
7 changes: 3 additions & 4 deletions examples/base-image/backend/backend.garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ spec:
BASE_IMAGE_VERSION: ${actions.build.base-image.version}

---

kind: Deploy
name: backend
description: Backend service
type: container

build: backend

dependencies:
- build.backend
spec:
image: ${actions.build.backend.outputs.deploymentImageId}
ports:
- name: http
containerPort: 8080
Expand Down
11 changes: 6 additions & 5 deletions examples/build-dependencies/backend/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ kind: Deploy
name: backend
description: Backend service container
type: container

build: backend

dependencies:
- build.backend
spec:
image: ${actions.build.backend.outputs.deploymentImageId}
ports:
- name: http
containerPort: 8080
Expand All @@ -34,7 +34,8 @@ kind: Run
name: backend
description: Simple run task
type: container
build: backend

dependencies:
- build.backend
spec:
command: ["sh", "-c", "echo task output"]
image: ${actions.build.backend.outputs.deploymentImageId}
28 changes: 14 additions & 14 deletions examples/build-dependencies/frontend/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,25 @@ copyFrom:
targetPath: "config/"

---

kind: Deploy
name: frontend
description: Frontend service container
type: container

build: frontend

dependencies:
- build.frontend
- deploy.backend

spec:
image: ${actions.build.frontend.outputs.deploymentImageId}
sync:
command: [ npm, run, dev ]
command: [npm, run, dev]
paths:
- source: .
target: /app
exclude: [ node_modules ]
mode: one-way # do not set to one-way-replica, otherwise it will remove the /config dir
exclude: [node_modules]
mode: one-way
- source: ../shared-config/
target: /app/config/
exclude: [ garden.yml ]
exclude: [garden.yml]
mode: one-way-replica
ports:
- name: http
Expand All @@ -52,16 +49,19 @@ spec:
kind: Test
name: frontend-unit
type: container
build: frontend
dependencies:
- build.frontend
spec:
args: [ npm, test ]
args: [npm, test]
image: ${actions.build.frontend.outputs.deploymentImageId}

---
kind: Test
name: frontend-integ
type: container
build: frontend
dependencies:
- deploy.frontend # <- we want the frontend service to be running and up-to-date for this test
- build.frontend
- deploy.frontend
spec:
args: [ npm, run, integ ]
args: [npm, run, integ]
image: ${actions.build.frontend.outputs.deploymentImageId}
14 changes: 8 additions & 6 deletions examples/cert-manager-ext-dns/frontend/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ type: container
name: frontend
description: React App Build for TLS and DNS example
---
# Deploys the frontend React App
kind: Deploy
type: container
name: frontend
description: React App Deploy for TLS and DNS example
build: frontend
dependencies:
- build.frontend
spec:
image: ${actions.build.frontend.outputs.deploymentImageId}
ports:
- name: http
protocol: TCP
Expand All @@ -19,13 +20,14 @@ spec:
- path: /
hostname: "react.${var.base-hostname}"
port: http

---
# Setup tests for the frontend React App
kind: Test
name: react-unit
type: container
build: frontend
dependencies:
- build.frontend
- deploy.frontend
spec:
args: [npm, test]
dependencies:
- deploy.frontend
image: ${actions.build.frontend.outputs.deploymentImageId}
4 changes: 3 additions & 1 deletion examples/code-synchronization/node-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ kind: Deploy
description: Node greeting service
name: node-service
type: container
build: node-service
dependencies:
- build.node-service
spec:
image: ${actions.build.node-service.outputs.deploymentImageId}
args: [npm, start]
sync:
command: [npm, run, dev] # Overrides the container's default when the service is deployed in dev mode
Expand Down
13 changes: 6 additions & 7 deletions examples/demo-project/backend/backend.garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ description: Backend service container image
type: container

---

kind: Deploy
name: backend
description: Backend service container
type: container

build: backend

# You can specify variables here at the action level
dependencies:
- build.backend
variables:
ingressPath: /hello-backend

spec:
image: ${actions.build.backend.outputs.deploymentImageId}
healthCheck:
httpGet:
path: /hello-backend
Expand All @@ -35,6 +32,8 @@ spec:
kind: Run
name: backend-run-task
type: container
build: backend
dependencies:
- build.backend
spec:
command: ["sh", "-c", "echo task output"]
image: ${actions.build.backend.outputs.deploymentImageId}
Loading

0 comments on commit ee126a3

Please sign in to comment.