Skip to content

Commit 3d47403

Browse files
quick doc on local development with multiple compose files
1 parent 2c4ba06 commit 3d47403

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

docs/concepts/local-development.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Local Development
3+
description:
4+
sidebar-position: 800
5+
---
6+
7+
# Local Development
8+
9+
While Defang encourages using a single compose file, there are times when it is more convenient to use different files for different environments. For example, if some services should be configured differently locally: maybe you want to mount your working directory as a volume for live-reloading, or you want to build a different container image for local development. Another reason may be that you have some local services, like an auth mock or a local webhook listener that you don't want to deploy to the cloud.
10+
11+
## `compose.local.yaml`
12+
13+
In these cases, Defang recommends creating a file like `compose.local.yaml` which extends service definitions from your primary `compose.yaml` file.
14+
15+
For example,
16+
17+
```yaml
18+
# compose.yaml
19+
services:
20+
app:
21+
build:
22+
context: .
23+
dockerfile: Dockerfile
24+
```
25+
26+
```yaml
27+
# compose.local.yaml
28+
services:
29+
app:
30+
extends:
31+
file: compose.yaml
32+
service: app
33+
build:
34+
context: .
35+
dockerfile: local.Dockerfile
36+
volumes:
37+
- .:/web
38+
local_service:
39+
image: myservice:latest
40+
```
41+
42+
This configuration can then be launched locally with
43+
44+
```
45+
docker compose -f compose.local.yaml
46+
```
47+
48+
And the primary compose file can be deployed to the cloud with
49+
50+
```
51+
defang compose up
52+
```

docs/tutorials/deploy-to-gcp.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ This tutorial will show you how to deploy your services to your own GCP project
1313
* [A `compose.yaml` file in your project](https://docs.docker.com/compose/gettingstarted/)
1414
* [A Defang Account](/docs/concepts/authentication)
1515
* [The Defang CLI](/docs/getting-started#install-the-defang-cli)
16-
* [GCP Account Credentials](https://cloud.google.com/docs/authentication)
16+
* [gcloud CL](https://cloud.google.com/sdk/docs/install)
17+
* [GCP Account Credentials](https://cloud.google.com/docs/authentication/set-up-adc-local-dev-environment)
1718

1819
## Step 1 - Navigate to your project directory
1920
Head to the folder where your project is located.

0 commit comments

Comments
 (0)