Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8eb69ea

Browse files
author
LRubin
authored
Merge pull request docker#495 from sanscontext/test-branch
Docker Cloud: updates for caching/context
2 parents a37f369 + c1ae823 commit 8eb69ea

File tree

2 files changed

+81
-19
lines changed

2 files changed

+81
-19
lines changed

docker-cloud/builds/automated-build.md

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ When you set up automated builds (also called autobuilds), you create a list of
1717
branches and tags of the images that you want to build. When you push code to a
1818
source code branch (for example in Github) for one of those listed image tags,
1919
the push uses a webhook to trigger a new build, which produces a Docker image.
20-
The built image is then pushed to the Docker Cloud registry or external
20+
The built image is then pushed to the Docker Cloud registry or to an external
2121
registry.
2222

2323
If you have automated tests configured, these run after building but before
@@ -28,6 +28,8 @@ their own. [Learn more about automated image testing here.](automated-testing.md
2828
You can also just use `docker push` to push pre-built images to these
2929
repositories, even if you have automatic builds set up.
3030

31+
![An automated build dashboard](images/build-dashboard.png)
32+
3133
## Configure automated build settings
3234

3335
You can configure your repositories in Docker Cloud so that they automatically
@@ -49,8 +51,9 @@ the code repository service where the image's source code is stored.
4951

5052
4. Select the **source repository** to build the Docker images from.
5153

52-
You might need to specify an organization or user from the source code
53-
provider to find the code repository you want to build.
54+
You might need to specify an organization or user (the _namespace_) from the
55+
source code provider. Once you select a namespace, its source code
56+
repositories appear in the **Select repository** dropdown list.
5457

5558
5. Choose where to run your build processes.
5659

@@ -74,25 +77,31 @@ the code repository service where the image's source code is stored.
7477

7578
* Enter the name of the **Source** branch or tag you want to build.
7679

77-
You can enter a name, or use a regex to match which source branch or tag
78-
names to build. To learn more, see
79-
[regexes](automated-build.md#regexes-and-automated-builds).
80+
The first time you configure automated builds, a default tag mapping is set up for you. This default set builds from the `Branch` in your source code called `master`, and creates a Docker image tagged with `latest`.
81+
82+
You can also use a regex to select which source branches or tags to build.
83+
To learn more, see
84+
[regexes](automated-build.md#regexes-and-automated-builds).
8085

8186
* Enter the tag to apply to Docker images built from this source.
8287

83-
If you configured a regex to select the source, you can reference the
84-
capture groups and use its result as part of the tag. To learn more, see
85-
[regexes](automated-build.md#regexes-and-automated-builds).
88+
If you configured a regex to select the source, you can reference the
89+
capture groups and use its result as part of the tag. To learn more, see
90+
[regexes](automated-build.md#regexes-and-automated-builds).
8691

8792
* Specify the **Dockerfile location** as a path relative to the root of the source code repository. (If the Dockerfile is at the repository root, leave this path set to `/`.)
8893

8994
9. For each branch or tag, enable or disable the **Autobuild** toggle.
9095

9196
Only branches or tags with autobuild enabled are built, tested, *and* have
9297
the resulting image pushed to the repository. Branches with autobuild
93-
disabled will be built for testing purposes if enabled, but not pushed.
98+
disabled will be built for test purposes (if enabled at the repository level), but not pushed.
99+
100+
10. For each branch or tag, enable or disable the **Build Caching** toggle.
101+
102+
[Build caching](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/build-cache) can save time if you are building a large image frequently or have many dependencies. You might want to leave build caching disabled to make sure all of your dependencies are resolved at build time, or if you have a large layer that is quicker to build locally.
94103

95-
10. Click **Save** to save the settings, or click **Save and build** to save and
104+
11. Click **Save** to save the settings, or click **Save and build** to save and
96105
run an initial test.
97106

98107
A webhook is automatically added to your source code repository to notify
@@ -119,12 +128,10 @@ values used by your service (for example to create service links).
119128

120129
## Check your active builds
121130

122-
1. To view active builds, go to the repository view and click **Timeline**.
131+
You can view a summary of the last five builds for a repository from the repository's **General** tab. You can also click **Timeline** to view a list of all active builds, and expand each build to see their real-time logs. The **Builds** tab also displays a color coded bar chart of the build queue times and durations.
123132

124-
The Timeline displays the pending, in progress, successful and failed builds
125-
for any tag of the repository.
126-
127-
2. Click to expand a timeline entry to check the build logs.
133+
Both views display the pending, in progress, successful, and failed builds
134+
for any tag of the repository.
128135

129136
You can click the **Cancel** button for pending builds and builds in progress.
130137
If a build fails, the cancel button is replaced by a **Retry** button.
@@ -153,7 +160,61 @@ to automatically build.
153160

154161
5. Click **Save** to save your changes.
155162

156-
## Regexes and automated builds
163+
## Advanced automated build options
164+
165+
At the minimum you need a build rule composed of a source branch (or tag) and
166+
destination Docker tag to set up an automated build. You can also change where
167+
the build looks for the Dockerfile, set a path to the files the build will use
168+
(the build context), set up multiple static tags or branches to build from, and
169+
use regular expressions (regexes) to dynamically select source code to build and
170+
create dynamic tags.
171+
172+
All of these options are available from the **Build configuration** screen for
173+
each repository. Click **Repositories** from the left navigation, click the name
174+
of the repository you want to edit, click the **Builds** tab, and click
175+
**Configure Automated builds**.
176+
177+
### Tag and Branch builds
178+
179+
You can configure your automated builds so that pushes to specific branches or tags will trigger a build.
180+
181+
1. In the **Tag mappings** section, click the plus sign to add more sources to build.
182+
183+
2. Select the **Source type** to build: either a **tag** or a **branch**.
184+
185+
This tells the build system what type of source to look for in the code
186+
repository.
187+
188+
3. Enter the name of the **Source** branch or tag you want to build.
189+
190+
You can enter a name, or use a regex to match which source branch or tag
191+
names to build. To learn more, see
192+
[regexes](automated-build.md#regexes-and-automated-builds).
193+
194+
4. Enter the tag to apply to Docker images built from this source.
195+
196+
If you configured a regex to select the source, you can reference the
197+
capture groups and use its result as part of the tag. To learn more, see
198+
[regexes](automated-build.md#regexes-and-automated-builds).
199+
200+
5. Repeat steps 2 through 4 for each new tag mapping you set up.
201+
202+
### Set the build context and Dockerfile location
203+
204+
Depending on how the files are arranged in your source code repository, the
205+
files required to build your images may not be at the repository root. If that's
206+
the case, you can specify a path where the build looks for the files.
207+
208+
The _build context_ is the path to the files needed for the build, relative to the root of the repository. Enter the path to these files in the **Build context** field. Enter `/` to set the build context as the root of the source code repository.
209+
210+
> **Note**: If you delete the default path `/` from the **Build context** field and leave it blank, the build system uses the path to the Dockerfile as the build context. However, to avoid confusion we recommend that you specify the complete path.
211+
212+
You can specify the **Dockerfile location** as a path relative to the build
213+
context. If the Dockerfile is at the root of the build context path, leave the
214+
Dockerfile path set to `/`. (If the build context field is blank, set the path
215+
to the Dockerfile from the root of the source repository.)
216+
217+
### Regexes and automated builds
157218

158219
You can specify a regular expression (regex) so that only matching branches or
159220
tags are built. You can also use the results of the regex to create the Docker
@@ -175,7 +236,7 @@ To do this, specify a `branch` build with the regex `/[0-9.]+$/` in the
175236
**Source** field, and use the formula `version-{sourceref}` in the **Docker
176237
tag** field.
177238

178-
<!-- Not a priority
239+
<!-- Capture groups Not a priority
179240
#### Regex example: build from version number branch and tag with version number
180241
181242
You could also use capture groups to build and label images that come from various sources. For example, you might have
@@ -197,7 +258,8 @@ To work around this, you can set up your automated build using the `SSH_PRIVATE`
197258
198259
1. Generate a SSH keypair that you will use for builds only, and add the public key to your source code provider account.
199260

200-
This step is optional, but allows you to revoke the build-only keypair without removing other access. <!-- (TODO: Link to instructions for GH & BB ) -->
261+
This step is optional, but allows you to revoke the build-only keypair without removing other access.
262+
201263
2. Copy the private half of the keypair to your clipboard.
202264
3. In Docker Cloud, navigate to the build page for the repository that has linked private submodules. (If necessary, follow the steps [here](automated-build.md#configure-automated-build-settings) to configure the automated build.)
203265
4. At the bottom of the screen, click the plus sign ( **+** ) next to **Build Environment variables**.
93.3 KB
Loading

0 commit comments

Comments
 (0)