Skip to content

Commit e1bdc53

Browse files
authored
publish docker-in-docker (dind) image (#4838)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced Docker image workflows now support multi-platform builds and streamlined tagging for efficient image management. - Refined container startup processes for Docker-in-Docker environments, including improved execution checks and progress indicators. - **Documentation** - Added comprehensive guides for both base and Docker-in-Docker images, with clear usage examples, troubleshooting tips, and best practice instructions. - **Chores** - Performed several internal optimizations to improve overall build consistency and performance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 33c617a commit e1bdc53

File tree

9 files changed

+276
-49
lines changed

9 files changed

+276
-49
lines changed

.cspell/custom-dictionary.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,5 @@ traefik
444444
bprotocolcompute
445445
bprotocolorchestrator
446446
nclprotocolcompute
447-
ncltest
447+
ncltest
448+
dind

Makefile

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -233,45 +233,85 @@ HTTP_GATEWAY_IMAGE ?= "ghcr.io/bacalhau-project/http-gateway"
233233
HTTP_GATEWAY_TAG ?= ${TAG}
234234
.PHONY: build-http-gateway-image
235235
build-http-gateway-image:
236-
docker buildx build \
236+
docker buildx build --load \
237+
--platform linux/amd64,linux/arm64 \
238+
-t ${HTTP_GATEWAY_IMAGE}:${HTTP_GATEWAY_TAG} \
239+
pkg/executor/docker/gateway
240+
241+
.PHONY: push-http-gateway-image
242+
push-http-gateway-image:
243+
docker buildx build --push \
237244
--platform linux/amd64,linux/arm64 \
238245
-t ${HTTP_GATEWAY_IMAGE}:${HTTP_GATEWAY_TAG} \
239246
pkg/executor/docker/gateway
240247

241248
BACALHAU_IMAGE ?= ghcr.io/bacalhau-project/bacalhau
242249
BACALHAU_TAG ?= ${TAG}
243250

244-
# Only tag images with :latest if the release tag is a semver tag (e.g. v0.3.12)
251+
# Only add latest tags if the release tag is a semver tag (e.g. v0.3.12)
245252
# and not a commit hash or a release candidate (e.g. v0.3.12-rc1)
246-
LATEST_TAG :=
247253
ifeq ($(shell echo ${BACALHAU_TAG} | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$'), ${BACALHAU_TAG})
248-
LATEST_TAG := --tag ${BACALHAU_IMAGE}:latest
254+
BASE_TAGS := --tag ${BACALHAU_IMAGE}:${BACALHAU_TAG} \
255+
--tag ${BACALHAU_IMAGE}:latest
256+
DIND_TAGS := --tag ${BACALHAU_IMAGE}:${BACALHAU_TAG}-dind \
257+
--tag ${BACALHAU_IMAGE}:latest-dind
258+
else
259+
BASE_TAGS := --tag ${BACALHAU_IMAGE}:${BACALHAU_TAG}
260+
DIND_TAGS := --tag ${BACALHAU_IMAGE}:${BACALHAU_TAG}-dind
249261
endif
250262

251263
BACALHAU_IMAGE_FLAGS := \
252264
--progress=plain \
253-
--platform linux/amd64,linux/arm64 \
254-
--tag ${BACALHAU_IMAGE}:${BACALHAU_TAG} \
255-
${LATEST_TAG} \
256265
--label org.opencontainers.artifact.created=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
257-
--label org.opencontainers.image.version=${BACALHAU_TAG} \
258-
--cache-from=type=registry,ref=${BACALHAU_IMAGE}:latest \
259-
--file docker/bacalhau-image/Dockerfile \
260-
.
266+
--label org.opencontainers.image.version=${BACALHAU_TAG}
267+
268+
.PHONY: build-bacalhau-base-image
269+
build-bacalhau-base-image:
270+
docker buildx build --load ${BACALHAU_IMAGE_FLAGS} \
271+
${BASE_TAGS} \
272+
--cache-from=type=registry,ref=${BACALHAU_IMAGE}:latest \
273+
--file docker/bacalhau-base/Dockerfile \
274+
.
275+
276+
.PHONY: build-bacalhau-dind-image
277+
build-bacalhau-dind-image:
278+
docker buildx build --load ${BACALHAU_IMAGE_FLAGS} \
279+
${DIND_TAGS} \
280+
--cache-from=type=registry,ref=${BACALHAU_IMAGE}:latest-dind \
281+
--file docker/bacalhau-dind/Dockerfile \
282+
.
283+
284+
# Push targets (multi-platform)
285+
.PHONY: push-bacalhau-base-image
286+
push-bacalhau-base-image:
287+
docker buildx build --push ${BACALHAU_IMAGE_FLAGS} \
288+
--platform linux/amd64,linux/arm64 \
289+
${BASE_TAGS} \
290+
--cache-from=type=registry,ref=${BACALHAU_IMAGE}:latest \
291+
--file docker/bacalhau-base/Dockerfile \
292+
.
293+
294+
.PHONY: push-bacalhau-dind-image
295+
push-bacalhau-dind-image:
296+
docker buildx build --push ${BACALHAU_IMAGE_FLAGS} \
297+
--platform linux/amd64,linux/arm64 \
298+
${DIND_TAGS} \
299+
--cache-from=type=registry,ref=${BACALHAU_IMAGE}:latest-dind \
300+
--file docker/bacalhau-dind/Dockerfile \
301+
.
261302

262-
.PHONY: build-bacalhau-image
263-
build-bacalhau-image:
264-
docker buildx build ${BACALHAU_IMAGE_FLAGS}
303+
# Combined targets for building and pushing all images
304+
.PHONY: build-bacalhau-images
305+
build-bacalhau-images: build-bacalhau-base-image build-bacalhau-dind-image
265306

266-
.PHONY: push-bacalhau-image
267-
push-bacalhau-image:
268-
docker buildx build --push ${BACALHAU_IMAGE_FLAGS}
307+
.PHONY: push-bacalhau-images
308+
push-bacalhau-images: push-bacalhau-base-image push-bacalhau-dind-image
269309

270310
.PHONY: build-docker-images
271311
build-docker-images: build-http-gateway-image
272312

273313
.PHONY: push-docker-images
274-
push-docker-images: build-http-gateway-image
314+
push-docker-images: push-http-gateway-image
275315

276316
# Release tarballs suitable for upload to GitHub release pages
277317
################################################################################

buildkite/scripts/bacalhau_image.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ docker_login() {
1111
echo $GHCR_PAT | docker login ghcr.io -u bacalhau-infra-bot --password-stdin
1212
}
1313

14-
docker_context_create() {
14+
setup_buildx() {
1515
docker context create buildx-build
1616
docker buildx create --use buildx-build
1717
}
@@ -30,26 +30,26 @@ download_and_extract_artifact() {
3030
}
3131

3232
download_artifacts() {
33+
echo "--- Downloading build artifacts"
3334
if ! buildkite-agent artifact download "*.*" . --build "$BUILDKITE_BUILD_ID"; then
3435
echo "Error: Failed to download artifacts from build pipeline" >&2
3536
exit 1
3637
fi
37-
echo "Downloaded artifacts from build pipeline"
3838

3939
download_and_extract_artifact "amd64"
4040
download_and_extract_artifact "arm64"
4141
}
4242

4343
main() {
4444
if [ -n "${BUILDKITE_TAG:-}" ]; then
45+
echo "=== Building and pushing images for tag: ${BUILDKITE_TAG}"
4546
set_environment_variables
46-
docker_context_create
47+
setup_buildx
4748
download_artifacts
48-
make build-bacalhau-image
4949
docker_login
50-
make push-bacalhau-image
50+
make push-bacalhau-images
5151
else
52-
echo "Skipping artifact download: BUILDKITE_TAG is not present"
52+
echo "Skipping image build: BUILDKITE_TAG is not present"
5353
fi
5454
}
5555

docker/bacalhau-image/Dockerfile renamed to docker/bacalhau-base/Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ ARG TARGETPLATFORM
66
# Take advantage of the format for $TARGETPLATFORM being "OS/ARCH"
77
# which matches our output directory structure in ./bin
88
ADD bin/$TARGETPLATFORM/bacalhau /usr/local/bin/bacalhau
9+
910
ENV PATH="/usr/local/bin:/usr/bin"
11+
1012
ENTRYPOINT ["bacalhau"]
11-
LABEL org.opencontainers.image.source https://github.com/bacalhau-project/bacalhau
12-
LABEL org.opencontainers.image.title "Bacalhau"
13-
LABEL org.opencontainers.image.description "The Bacalhau network provides decentralized compute for compute over data. See https://bacalhau.org for more info."
14-
LABEL org.opencontainers.image.licenses Apache-2.0
15-
LABEL org.opencontainers.image.url https://bacalhau.org
13+
14+
LABEL org.opencontainers.image.source="https://github.com/bacalhau-project/bacalhau"
15+
LABEL org.opencontainers.image.title="Bacalhau"
16+
LABEL org.opencontainers.image.description="The Bacalhau network provides decentralized compute for compute over data. See https://bacalhau.org for more info."
17+
LABEL org.opencontainers.image.licenses="Apache-2.0"
18+
LABEL org.opencontainers.image.url="https://bacalhau.org"

docker/bacalhau-base/README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Bacalhau Base Image
2+
3+
This is the standard Bacalhau container image, suitable for running orchestrator nodes, clients, and compute nodes with non-Docker execution engines (like WASM).
4+
5+
## Image Information
6+
7+
- Base Image: `ubuntu:24.04`
8+
- Registry: `ghcr.io/bacalhau-project/bacalhau`
9+
- Tags:
10+
- `latest`: Most recent stable release
11+
- `vX.Y.Z`: Specific version (e.g., `v1.6.0`)
12+
13+
## Use Cases
14+
15+
This image is ideal for:
16+
- Running orchestrator nodes
17+
- Running the Bacalhau client for job submission
18+
- Running compute nodes that don't require Docker execution capabilities
19+
20+
## Usage Examples
21+
22+
### Running an Orchestrator Node
23+
24+
```bash
25+
docker run ghcr.io/bacalhau-project/bacalhau:latest serve --orchestrator
26+
```
27+
28+
### Using as a Client
29+
30+
```bash
31+
docker run ghcr.io/bacalhau-project/bacalhau:latest list
32+
```
33+
34+
### Running a WASM Compute Node
35+
36+
```bash
37+
docker run ghcr.io/bacalhau-project/bacalhau:latest serve --compute
38+
```
39+
40+
### Running a Specific Version
41+
42+
```bash
43+
docker run ghcr.io/bacalhau-project/bacalhau:v1.6.0 serve
44+
```
45+
46+
## Features
47+
48+
- Minimal image size
49+
- Standard Ubuntu-based environment
50+
- Support for orchestrator nodes
51+
- Support for client operations
52+
- Support for WASM compute nodes
53+
- Multi-architecture support (amd64/arm64)
54+
55+
## When to Use This Image
56+
57+
Use this image when:
58+
- Running orchestrator nodes[README.md](../bacalhau-dind/README.md)
59+
[README.md](README.md)
60+
- Using Bacalhau as a client
61+
- Running compute nodes with WASM execution
62+
- Running in environments where Docker-in-Docker is not needed or desired
63+
- Minimal container footprint is desired
64+
65+
For compute nodes requiring Docker execution capabilities, use the DinD variant instead (`bacalhau:latest-dind`).
66+
67+
## Additional Resources
68+
69+
- [Bacalhau Documentation](https://docs.bacalhau.org/)
70+
- [GitHub Repository](https://github.com/bacalhau-project/bacalhau)
71+
- [Getting Started Guide](https://docs.bacalhau.org/getting-started)

docker/bacalhau-dind/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM docker:dind
2+
3+
# Install necessary packages
4+
RUN apk update && apk add --no-cache \
5+
curl \
6+
bash \
7+
coreutils
8+
9+
# Automatically set by Docker to be the --platform flag
10+
ARG TARGETPLATFORM
11+
12+
# Take advantage of the format for $TARGETPLATFORM being "OS/ARCH"
13+
# which matches our output directory structure in ./bin
14+
ADD bin/$TARGETPLATFORM/bacalhau /usr/local/bin/bacalhau
15+
16+
# Add our custom entrypoint script
17+
COPY docker/bacalhau-dind/entrypoint.sh /usr/local/bin/
18+
RUN chmod +x /usr/local/bin/entrypoint.sh
19+
20+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh", "bacalhau"]
21+
22+
LABEL org.opencontainers.image.source="https://github.com/bacalhau-project/bacalhau"
23+
LABEL org.opencontainers.image.title="Bacalhau"
24+
LABEL org.opencontainers.image.description="The Bacalhau network provides distributed compute over data. See https://bacalhau.org for more info."
25+
LABEL org.opencontainers.image.licenses="Apache-2.0"
26+
LABEL org.opencontainers.image.url="https://bacalhau.org"

docker/bacalhau-dind/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Bacalhau DinD Image
2+
3+
This is the Docker-in-Docker (DinD) variant of the Bacalhau container image, specifically designed for running compute nodes that need to execute Docker workloads.
4+
5+
## Image Information
6+
- Base Image: `docker:dind`
7+
- Registry: `ghcr.io/bacalhau-project/bacalhau`
8+
- Tags:
9+
- `latest-dind`: Most recent stable release with DinD support
10+
- `vX.Y.Z-dind`: Specific version (e.g., `v1.6.0-dind`)
11+
12+
## ⚠️ Important: Privileged Mode Required
13+
14+
This image MUST be run with the `--privileged` flag due to the Docker-in-Docker functionality:
15+
16+
```bash
17+
docker run --privileged ghcr.io/bacalhau-project/bacalhau:latest-dind serve --compute
18+
```
19+
20+
## Use Cases
21+
22+
This image is specifically designed for:
23+
- Running compute nodes that execute Docker workloads
24+
- Supporting the full range of Docker-based job execution
25+
- Development environments requiring Docker support
26+
27+
## Usage Examples
28+
29+
### Running a Compute Node
30+
```bash
31+
docker run --privileged \
32+
ghcr.io/bacalhau-project/bacalhau:latest-dind serve --compute
33+
```
34+
35+
### Development Environment
36+
```bash
37+
docker run --privileged \
38+
ghcr.io/bacalhau-project/bacalhau:latest-dind devstack
39+
```
40+
41+
### Running a Specific Version
42+
```bash
43+
docker run --privileged \
44+
ghcr.io/bacalhau-project/bacalhau:v1.6.0-dind serve --compute
45+
```
46+
47+
## Features
48+
- Full Docker-in-Docker support
49+
- Built-in Docker daemon
50+
- Multi-architecture support (amd64/arm64)
51+
- Automatic Docker daemon initialization
52+
53+
## When to Use This Image vs Base
54+
55+
Use this image when you need:
56+
- Compute nodes that run Docker workloads
57+
- Development environments with Docker capabilities
58+
- Full container execution support
59+
60+
Use the base image (`bacalhau:latest`) for:
61+
- Client operations
62+
- Orchestrator nodes
63+
- Compute nodes without Docker requirements
64+
- Environments where privileged mode isn't allowed
65+
66+
## Troubleshooting
67+
68+
If you see this error:
69+
```
70+
ERROR: This container must be run with --privileged flag
71+
```
72+
Add the `--privileged` flag to your docker run command.
73+
74+
## Additional Resources
75+
- [Bacalhau Documentation](https://docs.bacalhau.org/)
76+
- [GitHub Repository](https://github.com/bacalhau-project/bacalhau)
77+
- [Docker-in-Docker Documentation](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities)

docker/bacalhau-dind/entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
# Check for privileged mode by testing iptables access
4+
if ! iptables -L >/dev/null 2>&1; then
5+
echo "ERROR: This container must be run with --privileged flag"
6+
echo "Example: docker run --privileged <image> serve"
7+
exit 1
8+
fi
9+
10+
# Start the Docker daemon
11+
dockerd-entrypoint.sh dockerd &
12+
13+
# Wait for Docker daemon with timeout
14+
timeout 30s sh -c 'until docker info > /dev/null 2>&1; do echo "Waiting for Docker daemon..."; sleep 1; done'
15+
16+
if [ $? -ne 0 ]; then
17+
echo "Timed out waiting for Docker daemon"
18+
exit 1
19+
fi
20+
21+
echo "Docker daemon is ready"
22+
23+
# Get the bacalhau binary path (first argument)
24+
BACALHAU_BIN=$1
25+
shift
26+
27+
# Execute bacalhau with the remaining arguments
28+
exec "$BACALHAU_BIN" "$@"

0 commit comments

Comments
 (0)