-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from CSHieuV/consistency-fixes
Update to Bootstrap Container
- Loading branch information
Showing
4 changed files
with
50 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
set -x | ||
set -xeuo pipefail | ||
|
||
# Full path to the base64-encoded user data | ||
USER_DATA_PATH=/.bottlerocket/bootstrap-containers/current/user-data | ||
USER_DATA_PATH='/.bottlerocket/bootstrap-containers/current/user-data' | ||
|
||
# If the user data file is there, not empty, and not a directory, make it executable | ||
if [ -s "$USER_DATA_PATH" ] && [ ! -d "$USER_DATA_PATH" ]; then | ||
chmod +x "$USER_DATA_PATH" | ||
if [[ -s "${USER_DATA_PATH}" ]] && [[ ! -d "${USER_DATA_PATH}" ]]; then | ||
chmod +x "${USER_DATA_PATH}" | ||
|
||
# If the decoded script is there and executable, then execute it. | ||
if [ -x "$USER_DATA_PATH" ]; then | ||
echo "Executing user bootstrap script: $USER_DATA_PATH" | ||
exec "$USER_DATA_PATH" | ||
if [ -x "${USER_DATA_PATH}" ]; then | ||
exec "${USER_DATA_PATH}" | ||
else | ||
echo "Warning: User bootstrap script not found or not executable: $USER_DATA_PATH" | ||
echo "ERROR: User bootstrap script not found or not executable: ${USER_DATA_PATH}" >&2 | ||
exit 1 | ||
fi | ||
else | ||
echo "Warning: User data not found or is a directory: $USER_DATA_PATH" | ||
echo "ERROR: User data not found or is a directory: ${USER_DATA_PATH}" >&2 | ||
exit 1 | ||
fi |