Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Bootstrap Container #3

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
improve multiarch support in Makefile
CSHieuV committed Aug 8, 2024
commit aa1478a0af02e1daec2168fbf633ed46d21dd25f
43 changes: 31 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
IMAGE_NAME = bottlerocket-bootstrap-container:latest
# IMAGE_NAME is the full name of the container image being built.
IMAGE_NAME ?= $(notdir $(shell pwd -P))$(IMAGE_ARCH_SUFFIX):$(IMAGE_VERSION)$(addprefix -,$(SHORT_SHA))
# IMAGE_VERSION is the semver version that's tagged on the image.
IMAGE_VERSION = $(shell cat VERSION)
# SHORT_SHA is the revision that the container image was built with.
SHORT_SHA ?= $(shell git describe --abbrev=8 --always --dirty='-dev' --exclude '*' || echo "unknown")
# IMAGE_ARCH_SUFFIX is the runtime architecture designator for the container
# image, it is appended to the IMAGE_NAME unless the name is specified.
IMAGE_ARCH_SUFFIX ?= $(addprefix -,$(ARCH))
# DESTDIR is where the release artifacts will be written.
DESTDIR ?= .
# DISTFILE is the path to the dist target's output file - the container image
# tarball.
DISTFILE ?= $(subst /,,$(DESTDIR))/$(subst /,_,$(IMAGE_NAME)).tar.gz

.PHONY: all build clean
UNAME_ARCH = $(shell uname -m)
ARCH ?= $(lastword $(subst :, ,$(filter $(UNAME_ARCH):%,x86_64:amd64 aarch64:arm64)))

# Run all build tasks for this container image
all: build_amd64 build_arm64
.PHONY: all build dist clean

# Build the container image for the amd64 architecture
build_amd64:
docker build --tag $(IMAGE_NAME)-amd64 -f Dockerfile .
# Run all build tasks for this container image.
all: build

# Build the container image for the arm64 architecture
build_arm64:
docker build --tag $(IMAGE_NAME)-arm64 -f Dockerfile .
# Create a distribution container image tarball for release.
dist: all
@mkdir -p $(dir $(DISTFILE))
docker save $(IMAGE_NAME) | gzip > $(DISTFILE)

# Build the container image.
build:
DOCKER_BUILDKIT=1 docker build $(DOCKER_BUILD_FLAGS) \
--tag $(IMAGE_NAME) \
--build-arg IMAGE_VERSION="$(IMAGE_VERSION)" \
-f Dockerfile . >&2

# Clean up the build artifacts (if there are any to clean)
clean:
rm -f $(IMAGE_NAME)
rm -f $(DISTFILE)