You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -129,7 +134,7 @@ This pipeline is triggered automatically on:
129
134
- Commits pushed to the `main` branch
130
135
- Pull requests targeting `main` main branch
131
136
132
-
> [!NOTE]
137
+
> [!TIP]
133
138
> Learn more: [Define pipeline triggers in Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops)
134
139
135
140
@@ -148,7 +153,7 @@ These variables ensure consistent naming, versioning, and reuse throughout the p
148
153
- `buildTag`: a unique tag for each pipeline run
149
154
- `latestTag`: a stable alias for your most recent image
150
155
151
-
> [!NOTE]
156
+
> [!TIP]
152
157
> Learn more: [Define and use variables in Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch)
153
158
154
159
@@ -166,7 +171,7 @@ This stage executes only if:
166
171
- The pipeline completes successfully.
167
172
- The source branch is main.
168
173
169
-
> [!NOTE]
174
+
> [!TIP]
170
175
> Learn more: [Stage conditions in Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/stages?view=azure-devops&tabs=yaml)
171
176
172
177
### Step 4: Job Configuration
@@ -181,7 +186,7 @@ jobs:
181
186
182
187
This job uses the latest Ubuntu VM image provided by Microsoft-hosted agents. It can be swapped with a custom pool for self-hosted agents if needed.
183
188
184
-
> [!NOTE]
189
+
> [!TIP]
185
190
> Learn more: [Specify a pool in your pipeline](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/pools-queues?view=azure-devops&tabs=yaml%2Cbrowser)
186
191
187
192
#### Step 4.1 Checkout Code
@@ -195,7 +200,7 @@ steps:
195
200
196
201
This step pulls your repository code into the build agent, so the pipeline can access the Dockerfile and application files.
@@ -211,38 +216,45 @@ This step pulls your repository code into the build agent, so the pipeline can a
211
216
212
217
Uses a preconfigured Azure DevOps Docker registry service connection to authenticate securely without exposing credentials directly.
213
218
214
-
> [!NOTE]
219
+
> [!TIP]
215
220
> Learn more: [Use service connections for Docker Hub](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops#docker-hub-or-others)
216
221
217
222
218
223
#### Step 4.3 Build the Docker Image
219
224
220
225
```yaml
221
-
- task: Docker@2
222
-
displayName: Build Docker Image
223
-
inputs:
224
-
command: build
225
-
repository: $(imageName)
226
-
tags: |
227
-
$(buildTag)
228
-
$(latestTag)
229
-
dockerfile: './Dockerfile'
230
-
arguments: '--cache-from $(imageName):latest'
231
-
env:
232
-
DOCKER_BUILDKIT: 1
226
+
- task: Docker@2
227
+
displayName: Build Docker Image
228
+
inputs:
229
+
command: build
230
+
repository: $(imageName)
231
+
tags: |
232
+
$(buildTag)
233
+
$(latestTag)
234
+
dockerfile: './Dockerfile'
235
+
arguments: |
236
+
--sbom=true
237
+
--attest type=provenance
238
+
--cache-from $(imageName):latest
239
+
env:
240
+
DOCKER_BUILDKIT: 1
233
241
```
234
242
235
243
This builds the image with:
236
244
237
-
- Two tags: one with the build ID and one as latest
238
-
- Docker BuildKit for faster builds and layer caching
239
-
- Cache pull from the last pushed latest tag
240
-
241
-
> [!NOTE]
242
-
> Learn more: [Docker task for Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/docker-v2?view=azure-pipelines&tabs=yaml)
245
+
- Two tags: one with the unique Build ID and one as latest
246
+
- Docker BuildKit enabled for faster builds and efficient layer caching
247
+
- Cache pull from the most recent pushed latest image
248
+
- Software Bill of Materials (SBOM) for supply chain transparency
249
+
- Provenance attestation to verify how and where the image was built
243
250
251
+
> [!TIP]
252
+
> Learn more:
253
+
> - [Docker task for Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/docker-v2?view=azure-pipelines&tabs=yaml)
@@ -260,7 +272,7 @@ This uploads both tags to Docker Hub:
260
272
- `latest`is used for most recent image references.
261
273
262
274
263
-
5. Logout from Docker (Self-Hosted Agents)
275
+
#### Step 4.5 Logout from Docker (Self-Hosted Agents)
264
276
265
277
```yaml
266
278
- script: docker logout
@@ -288,4 +300,4 @@ With this Azure Pipelines CI setup, you get:
288
300
- [Azure Pipelines Documentation](https://learn.microsoft.com/en-us/azure/devops/pipelines/?view=azure-devops) - Comprehensive guide to configuring and managing CI/CD pipelines in Azure DevOps.
289
301
- [Docker Task for Azure Pipelines](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker) - Detailed reference for using the Docker task in Azure Pipelines to build and push images.
290
302
- [Docker Buildx Bake](/manuals/build/bake/_index.md) - Explore Docker's advanced build tool for complex, multi-stage, and multi-platform build setups. See also the [Mastering Buildx Bake Guide](/guides/bake/index.md) for practical examples and best practices.
291
-
- [Docker Build Cloud](/guides/docker-build-cloud/_index.md) - Learn about Docker's managed build service for faster, scalable, and multi-platform image builds in the cloud.
303
+
- [Docker Build Cloud](/guides/docker-build-cloud/_index.md) - Learn about Docker's managed build service for faster, scalable, and multi-platform image builds in the cloud.
0 commit comments