Skip to content

Commit d685ae7

Browse files
authored
Merge pull request #19287 from dvdksn/build-building-freshness-tier2
freshness(tier2): /build/building/**
2 parents d032a17 + ed1f51d commit d685ae7

File tree

6 files changed

+41
-30
lines changed

6 files changed

+41
-30
lines changed

content/build/building/context.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ ERROR: failed to solve: failed to compute cache key: failed to calculate checksu
411411
You can use a `.dockerignore` file to exclude files or directories from the
412412
build context.
413413

414-
```gitignore
414+
```text
415415
# .dockerignore
416416
node_modules
417417
bar
@@ -471,7 +471,7 @@ on GitHub, which contains the source code.
471471

472472
The following code snippet shows an example `.dockerignore` file.
473473

474-
```gitignore
474+
```text
475475
# comment
476476
*/temp*
477477
*/*/temp*
@@ -514,7 +514,7 @@ You can prepend lines with a `!` (exclamation mark) to make exceptions to
514514
exclusions. The following is an example `.dockerignore` file that uses this
515515
mechanism:
516516

517-
```gitignore
517+
```text
518518
*.md
519519
!README.md
520520
```
@@ -527,7 +527,7 @@ The placement of `!` exception rules influences the behavior: the last line of
527527
the `.dockerignore` that matches a particular file determines whether it's
528528
included or excluded. Consider the following example:
529529

530-
```gitignore
530+
```text
531531
*.md
532532
!README*.md
533533
README-secret.md
@@ -538,7 +538,7 @@ No markdown files are included in the context except README files other than
538538

539539
Now consider this example:
540540

541-
```gitignore
541+
```text
542542
*.md
543543
README-secret.md
544544
!README*.md

content/build/building/multi-platform.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ loads it through a binary registered in the `binfmt_misc` handler.
6161
> Use [multiple native nodes](#multiple-native-nodes) or
6262
> [cross-compilation](#cross-compilation) instead, if possible.
6363
64+
## Support on Docker Desktop
65+
66+
[Docker Desktop](../../desktop/index.md) provides `binfmt_misc`
67+
multi-architecture support, which means you can run containers for different
68+
Linux architectures such as `arm`, `mips`, `ppc64le`, and even `s390x`.
69+
70+
This doesn't require any special configuration in the container itself as it
71+
uses [qemu-static](https://wiki.qemu.org/Main_Page)
72+
from the Docker Desktop VM. Because of this, you can run an ARM container,
73+
like the `arm32v7` or `ppc64le` variants of the busybox image.
74+
75+
#### QEMU without Docker Desktop
76+
6477
For QEMU binaries registered with `binfmt_misc` on the host OS to work
6578
transparently inside containers, they must be statically compiled and
6679
registered with the `fix_binary` flag. This requires a kernel version 4.8 or
@@ -180,7 +193,7 @@ cURL installed for multiple architectures:
180193

181194
```dockerfile
182195
# syntax=docker/dockerfile:1
183-
FROM alpine:3.16
196+
FROM alpine:{{% param "example_alpine_version" %}}
184197
RUN apk add curl
185198
```
186199

@@ -266,14 +279,3 @@ armv7l
266279

267280
In the above example, `uname -m` returns `aarch64` and `armv7l` as expected,
268281
even when running the commands on a native macOS or Windows developer machine.
269-
270-
## Support on Docker Desktop
271-
272-
[Docker Desktop](../../desktop/index.md) provides `binfmt_misc`
273-
multi-architecture support, which means you can run containers for different
274-
Linux architectures such as `arm`, `mips`, `ppc64le`, and even `s390x`.
275-
276-
This does not require any special configuration in the container itself as it
277-
uses [qemu-static](https://wiki.qemu.org/Main_Page)
278-
from the Docker Desktop VM. Because of this, you can run an ARM container,
279-
like the `arm32v7` or `ppc64le` variants of the busybox image.

content/build/building/multi-stage.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
---
22
title: Multi-stage builds
3-
description: 'Learn about multi-stage builds and how you can use
4-
3+
description: |
4+
Learn about multi-stage builds and how you can use
55
them to improve your builds and get smaller images
6-
7-
'
86
keywords: build, best practices
97
aliases:
108
- /engine/userguide/eng-image/multistage-build/
@@ -22,11 +20,11 @@ stage of the build. You can selectively copy artifacts from one stage to
2220
another, leaving behind everything you don't want in the final image.
2321

2422
The following Dockerfile has two separate stages: one for building a binary,
25-
and another where we copy the binary into.
23+
and another where the binary gets copied from the first stage into the next stage.
2624

2725
```dockerfile
2826
# syntax=docker/dockerfile:1
29-
FROM golang:1.21
27+
FROM golang:{{% param "example_go_version" %}}
3028
WORKDIR /src
3129
COPY <<EOF ./main.go
3230
package main
@@ -71,7 +69,7 @@ Dockerfile are re-ordered later, the `COPY` doesn't break.
7169

7270
```dockerfile
7371
# syntax=docker/dockerfile:1
74-
FROM golang:1.21 as build
72+
FROM golang:{{% param "example_go_version" %}} as build
7573
WORKDIR /src
7674
COPY <<EOF /src/main.go
7775
package main

content/build/building/packaging.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ FROM ubuntu:22.04
8484

8585
# install app dependencies
8686
RUN apt-get update && apt-get install -y python3 python3-pip
87-
RUN pip install flask==2.1.*
87+
RUN pip install flask==3.0.*
8888

8989
# install app
9090
COPY hello.py /
9191

9292
# final configuration
9393
ENV FLASK_APP=hello
9494
EXPOSE 8000
95-
CMD flask run --host 0.0.0.0 --port 8000
95+
CMD ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]
9696
```
9797

9898
Here's a breakdown of what this Dockerfile does:
@@ -181,7 +181,7 @@ The second `RUN` instruction installs the `flask` dependency required by the
181181
Python application.
182182

183183
```dockerfile
184-
RUN pip install flask==2.1.*
184+
RUN pip install flask==3.0.*
185185
```
186186

187187
A prerequisite for this instruction is that `pip` is installed into the build
@@ -234,12 +234,22 @@ team members understand what this application is doing.
234234
Finally, [`CMD` instruction](../../engine/reference/builder.md#cmd) sets the
235235
command that is run when the user starts a container based on this image.
236236

237+
```dockerfile
238+
CMD ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]
239+
```
240+
241+
This command starts the flask development server listening on all addresses
242+
on port `8000`. The example here uses the "exec form" version of `CMD`.
243+
It's also possible to use the "shell form":
244+
237245
```dockerfile
238246
CMD flask run --host 0.0.0.0 --port 8000
239247
```
240248

241-
In this case we'll start the flask development server listening on all addresses
242-
on port `8000`.
249+
There are subtle differences between these two versions,
250+
for example in how they trap signals like `SIGTERM` and `SIGKILL`.
251+
For more information about these differences, see
252+
[Shell and exec form](../../engine/reference/builder.md#shell-and-exec-form)
243253

244254
## Building
245255

content/build/ci/github-actions/named-contexts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
with:
4343
context: .
4444
build-contexts: |
45-
alpine=docker-image://alpine:3.16
45+
alpine=docker-image://alpine:{{% param "example_alpine_version" %}}
4646
tags: myimage:latest
4747
```
4848

hugo.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ params:
100100

101101
example_go_version: "1.21"
102102
example_golangci_lint_version: "v1.52"
103+
example_alpine_version: "1.19"
103104

104105
min_api_threshold: 1.41
105106

0 commit comments

Comments
 (0)