Skip to content

Commit 86bfb7f

Browse files
committed
Use netlify build container
This makes the build container much closer to the real netlify environment. We use their official build container and install mdbook the same way we do when publishing the site. - Use official netlify build container - Bump go version or building mdbook-releasetags - Simplify variables (remove MDBOOK_VERSION) - Download mdbook binary directly in container instead of building, same as netlify - Set user/group ID for container mounts to avoid issues with file permissions Signed-off-by: Lennart Jern <[email protected]>
1 parent 1563af0 commit 86bfb7f

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
MDBOOK_VERSION ?= 0.4.37
2-
MDBOOK_BIN_VERSION ?= v$(MDBOOK_VERSION)
1+
MDBOOK_BIN_VERSION ?= v0.4.37
32
SOURCE_PATH := docs/user-guide
4-
CONTAINER_RUNTIME ?= sudo docker
3+
CONTAINER_RUNTIME ?= docker
54
IMAGE_NAME := quay.io/metal3-io/mdbook
65
IMAGE_TAG ?= latest
76
HOST_PORT ?= 3000
@@ -43,13 +42,14 @@ netlify-build: $(RELEASETAGS) $(MDBOOK_BIN)
4342

4443
.PHONY: build
4544
docker-build: # Build the mdbook container image
46-
$(CONTAINER_RUNTIME) build --build-arg MDBOOK_VERSION=$(MDBOOK_VERSION) \
45+
$(CONTAINER_RUNTIME) build --build-arg MDBOOK_RELEASE_URL=$(MDBOOK_RELEASE_URL) \
4746
--tag $(IMAGE_NAME):$(IMAGE_TAG) -f docs/Dockerfile .
4847

4948
.PHONY: build
5049
build:# Build the user guide
5150
$(CONTAINER_RUNTIME) run \
5251
--rm -it --name metal3 \
52+
--user $$(id -u):$$(id -g) \
5353
-v "$$(pwd):/workdir" \
5454
$(IMAGE_NAME):$(IMAGE_TAG) \
5555
mdbook build $(SOURCE_PATH)
@@ -58,6 +58,7 @@ build:# Build the user guide
5858
serve:# Serve the user-guide on localhost:3000 (by default)
5959
$(CONTAINER_RUNTIME) run \
6060
--rm -it --init --name metal3 \
61+
--user $$(id -u):$$(id -g) \
6162
-v "$$(pwd):/workdir" \
6263
-p $(HOST_PORT):3000 \
6364
$(IMAGE_NAME):$(IMAGE_TAG) \

docs/Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ARG BUILD_IMAGE=docker.io/golang:1.21.9@sha256:7d0dcbe5807b1ad7272a598fbf9d7af15b5e2bed4fd6c4c2b5b3684df0b317dd
2-
FROM $BUILD_IMAGE as builder
1+
ARG BUILD_IMAGE=docker.io/golang:1.25.2@sha256:1c91b4f4391774a73d6489576878ad3ff3161ebc8c78466ec26e83474855bfcf
2+
FROM $BUILD_IMAGE AS builder
33
WORKDIR /workspace
44

55
# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
@@ -22,10 +22,10 @@ ARG ARCH=amd64
2222
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
2323
go build -tags=tools -a -ldflags '-extldflags "-static"' \
2424
-o mdbook-releasetags ./releasetags
25+
ARG MDBOOK_RELEASE_URL="https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz"
26+
RUN curl -L "${MDBOOK_RELEASE_URL}" \
27+
| tar xvz -C /workspace
2528

26-
FROM rust:1.78.0-slim@sha256:517c6272b328bc51c87e099ef4adfbc7ab4558af2d757e8d423c7c3f1cbbf9d5
27-
ARG MDBOOK_VERSION="0.4.37"
28-
RUN cargo install mdbook --vers ${MDBOOK_VERSION}
29-
RUN cp /usr/local/cargo/bin/mdbook /usr/bin/mdbook
30-
COPY --from=builder /workspace/mdbook-releasetags /usr/bin/mdbook-releasetags
29+
FROM netlify/build:focal
3130
WORKDIR /workdir
31+
COPY --from=builder /workspace/mdbook-releasetags /workspace/mdbook /usr/bin/

0 commit comments

Comments
 (0)