-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add targets and rename stack -> base image where appropriate
Signed-off-by: Natalie Arellano <[email protected]>
- Loading branch information
1 parent
64cbf95
commit 37ce19a
Showing
51 changed files
with
550 additions
and
398 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
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM --platform=linux/amd64 alpine:3 | ||
|
||
# Install packages that we want to make available at both build and run time | ||
RUN apk add --update --no-cache bash ca-certificates | ||
|
||
# Create user and group | ||
ARG cnb_uid=1000 | ||
ARG cnb_gid=1001 | ||
RUN addgroup -g ${cnb_gid} cnb && \ | ||
adduser -u ${cnb_uid} -G cnb -s /bin/bash -D cnb | ||
|
||
# Set user and group | ||
USER ${cnb_uid}:${cnb_gid} | ||
|
||
# Set required CNB target information | ||
ARG distro_name | ||
LABEL io.buildpacks.base.distro.name=${distro_name} | ||
ARG distro_version | ||
LABEL io.buildpacks.base.distro.version=${distro_version} | ||
|
||
# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) | ||
ARG stack_id | ||
LABEL io.buildpacks.stack.id="${stack_id}" |
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ARG base_image | ||
FROM ${base_image} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM curlimages/curl | ||
|
||
COPY ./Dockerfile /home/curl_user/Dockerfile | ||
|
||
RUN curl --version | ||
|
||
# Create user and group | ||
ARG cnb_uid=1000 | ||
ARG cnb_gid=1001 | ||
USER root | ||
RUN addgroup -g ${cnb_gid} cnb && \ | ||
adduser -u ${cnb_uid} -G cnb -s /bin/bash -D cnb | ||
|
||
# Set user and group | ||
USER ${cnb_uid}:${cnb_gid} | ||
|
||
# Set required CNB target information | ||
LABEL io.buildpacks.base.distro.name=alpine | ||
LABEL io.buildpacks.base.distro.version=3.18.2 | ||
|
||
# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) | ||
LABEL io.buildpacks.stack.id=io.buildpacks.samples.stacks.alpine |
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
ID_PREFIX="io.buildpacks.samples.stacks" | ||
|
||
DEFAULT_PREFIX=cnbs/sample-base | ||
DEFAULT_PLATFORM=amd64 | ||
|
||
REPO_PREFIX=${DEFAULT_PREFIX} | ||
PLATFORM=${DEFAULT_PLATFORM} | ||
|
||
usage() { | ||
echo "Usage: " | ||
echo " $0 [-f <prefix>] [-p <platform>] <dir>" | ||
echo " -f prefix to use for images (default: ${DEFAULT_PREFIX})" | ||
echo " -p prefix to use for images (default: ${DEFAULT_PLATFORM})" | ||
echo " <dir> directory to build" | ||
exit 1; | ||
} | ||
|
||
while getopts "v:p:" o; do | ||
case "${o}" in | ||
f) | ||
REPO_PREFIX=${OPTARG} | ||
;; | ||
p) | ||
PLATFORM=${OPTARG} | ||
;; | ||
\?) | ||
echo "Invalid option: -$OPTARG" 1>&2 | ||
usage | ||
;; | ||
:) | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
BASE_DIR=${@:$OPTIND:1} | ||
|
||
if [[ -z ${REPO_PREFIX} ]]; then | ||
echo "Prefix cannot be empty" | ||
echo | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ -z ${BASE_DIR} ]]; then | ||
echo "Must specify directory" | ||
echo | ||
usage | ||
exit 1 | ||
fi | ||
|
||
cd $(dirname $0) | ||
|
||
IMAGE_DIR=$(realpath "${BASE_DIR}") | ||
TAG=$(basename "${IMAGE_DIR}") | ||
STACK_ID="${ID_PREFIX}.$(basename "${IMAGE_DIR}")" | ||
BASE_IMAGE=${REPO_PREFIX}:${TAG} | ||
RUN_IMAGE=${REPO_PREFIX}-run:${TAG} | ||
BUILD_IMAGE=${REPO_PREFIX}-build:${TAG} | ||
|
||
if [[ -d "${IMAGE_DIR}/base" ]]; then | ||
docker build --platform=${PLATFORM} \ | ||
--build-arg "distro_name=${DISTRO_NAME}" \ | ||
--build-arg "distro_version=${DISTRO_VERSION}" \ | ||
--build-arg "stack_id=${STACK_ID}" \ | ||
-t "${BASE_IMAGE}" \ | ||
"${IMAGE_DIR}/base" | ||
fi | ||
|
||
# Get target distro information | ||
if cmd /c ver; then | ||
DISTRO_NAME="" | ||
DISTRO_VERSION=$(docker run --rm --entrypoint bash "${BASE_IMAGE}" cmd /c ver | sed 's/Microsoft Windows //' | sed 's/[][]//g' | cut -d' ' -f2) | ||
else | ||
DISTRO_NAME=$(docker run --rm "${BASE_IMAGE}" cat /etc/os-release | grep '^ID=' | cut -d'=' -f2) | ||
DISTRO_VERSION=$(docker run --rm "${BASE_IMAGE}" cat /etc/os-release | grep '^VERSION_ID=' | cut -d'=' -f2) | ||
fi | ||
|
||
echo "BUILDING ${BUILD_IMAGE}..." | ||
docker build --platform=${PLATFORM} \ | ||
--build-arg "base_image=${BASE_IMAGE}" \ | ||
--build-arg "stack_id=${STACK_ID}" \ | ||
-t "${BUILD_IMAGE}" \ | ||
"${IMAGE_DIR}/build" | ||
|
||
echo "BUILDING ${RUN_IMAGE}..." | ||
docker build --platform=${PLATFORM} \ | ||
--build-arg "base_image=${BASE_IMAGE}" \ | ||
--build-arg "stack_id=${STACK_ID}" \ | ||
-t "${RUN_IMAGE}" \ | ||
"${IMAGE_DIR}/run" | ||
|
||
echo | ||
echo "BASE IMAGES BUILT!" | ||
echo | ||
echo "Images:" | ||
for IMAGE in "${BASE_IMAGE}" "${BUILD_IMAGE}" "${RUN_IMAGE}"; do | ||
echo " ${IMAGE}" | ||
done |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 | ||
|
||
# Set user | ||
USER ContainerAdministrator | ||
|
||
# Set required CNB target information | ||
ARG distro_name | ||
LABEL io.buildpacks.base.distro.name=${distro_name} | ||
ARG distro_version | ||
LABEL io.buildpacks.base.distro.version=${distro_version} | ||
|
||
# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) | ||
ARG stack_id | ||
LABEL io.buildpacks.stack.id=${stack_id} |
Oops, something went wrong.