Skip to content

Commit 4db9972

Browse files
ndeloofglours
authored andcommitted
clarify support for Git URLs a build context
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 4c69548 commit 4db9972

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

build.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,24 @@ On push, both `awesome/webapp` and `awesome/database` docker images are pushed t
8484
The `build` element define configuration options that are applied by Compose implementations to build Docker image from source.
8585
`build` can be specified either as a string containing a path to the build context or a detailed structure:
8686

87+
Using this string syntax, only the build context can be configured as either:
88+
- a relative path to the Compose file's parent folder. This path MUST be a directory and contain a `Dockerfile`
89+
8790
```yml
8891
services:
8992
webapp:
9093
build: ./dir
9194
```
9295

93-
Using this string syntax, only the build context can be configured as a relative path to the Compose file's parent folder.
94-
This path MUST be a directory and contain a `Dockerfile`.
96+
- a git repository URL. Git URLs accept context configuration in their fragment section, separated by a colon (`:`).
97+
The first part represents the reference that Git will check out, and can be either a branch, a tag, or a remote reference.
98+
The second part represents a subdirectory inside the repository that will be used as a build context.
99+
100+
```yml
101+
services:
102+
webapp:
103+
build: https://github.com/mycompany/example.git#branch_or_tag:subdirectory
104+
```
95105

96106
Alternatively `build` can be an object with fields defined as follow
97107

@@ -108,6 +118,12 @@ build:
108118
context: ./dir
109119
```
110120

121+
```yml
122+
services:
123+
webapp:
124+
build: https://github.com/mycompany/webapp.git
125+
```
126+
111127
### dockerfile
112128

113129
`dockerfile` allows to set an alternate Dockerfile. A relative path MUST be resolved from the build context.

0 commit comments

Comments
 (0)