Skip to content

Commit c78644c

Browse files
committed
Introduce compact build, configured by MOD setting in .env
1 parent 534e1ea commit c78644c

4 files changed

Lines changed: 35 additions & 19 deletions

File tree

.env

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ fi
2626
## AWS_REGION - will be set to AWS_DEFAULT_REGION if not set externally.
2727
export AWS_DEFAULT_REGION=us-west-2
2828
export AWS_REGION=$(aws configure get region)
29-
#export AWS_REGION=$(aws ec2 describe-availability-zones --output text --query 'AvailabilityZones[0].[RegionName]')
3029
if [ "${AWS_REGION}" == "" ]; then
3130
export AWS_REGION=$AWS_DEFAULT_REGION
3231
fi
@@ -35,8 +34,8 @@ fi
3534
## If REGISTRY==default, then the default elastic container registry in the account for the current region will be used
3635
export REGISTRY=default
3736
## Set default registry if needed
37+
export REGION=${AWS_REGION}
3838
if [ "$REGISTRY" == "default" ]; then
39-
export REGION=${AWS_REGION}
4039
export ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
4140
if [ "$ACCOUNT" == "" ]; then
4241
export REGISTRY=""
@@ -53,12 +52,17 @@ fi
5352

5453
## IMAGE: <required> - Docker image name for this project. Example: myapp
5554
export IMAGE=aws-do-hyperpod
55+
## MOD: [optional] - modifier of image build that controls whether certain non-essential components are installed
56+
## this is done to control image size. If MOD="" then everything is included, if MOD="compact" then only required components are included.
57+
#export MOD=compact
58+
export MOD=""
59+
export MOD_TAG=$(if [ "$MOD" == "" ]; then echo ""; else echo "-${MOD}"; fi)
5660
## VERSION: [optional] - Version tag for this Docker image. Example: v20180302
5761
#export VERSION=v$(date +%Y%m%d)
5862
export VERSION=v20240910
59-
export TAG=$(if [ -z "${VERSION}" ]; then echo ""; else echo ":${VERSION}"; fi)
63+
export TAG=$(if [ -z "${VERSION}" ]; then echo ":latest${MOD_TAG}"; else echo ":${VERSION}${MOD_TAG}"; fi)
6064
## BUILD_OPTS: [optional] - arguments for the docker image build command
61-
export BUILD_OPTS="--progress plain --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxy=${no_proxy}"
65+
export BUILD_OPTS="--progress plain --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxy=${no_proxy} --build-arg MOD=${MOD}"
6266

6367
# Docker container runtime settings
6468
## CONTAINER_NAME: [optional] - Name of the Docker container including the --name switch. Example --name myapp
@@ -71,7 +75,7 @@ export VOL_MAP="-v ${HOME}/.aws:/root/.aws -v ${HOME}/.kube:/root/.kube -v $(pwd
7175
## Network [optional] - Network name including the --net switch. Example --net mynet
7276
#export NETWORK=
7377
## RUN_OPTS [optional] - additional options to specify with the run comman. Example -e POSTGRES_DB=dbname
74-
export RUN_OPTS="-e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e REGION=$REGION -e AWS_DEFAULT_REGION=$REGION"
78+
export RUN_OPTS="-e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e REGION=$REGION -e AWS_REGION=$REGION -e AWS_DEFAULT_REGION=$REGION"
7579
if [ -f ${HOME}/.aws/credentials ]; then
7680
export RUN_OPTS="${RUN_OPTS} -e AWS_PROFILE=$AWS_PROFILE"
7781
fi

Container-Root/hyperpod/impl/eks/hyperpod-create.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ if [ "$CREATE_EKS_CLUSTER" == "" ]; then
2222
export CREATE_EKS_CLUSTER=true
2323
fi
2424

25+
export REGION_OPT=""
26+
if [ ! "${AWS_REGION}" == "" ]; then
27+
export REGION_OPT="--region ${AWS_REGION}"
28+
fi
29+
2530
pushd ${ENV_HOME}impl/eks/src
2631

2732
# Create cfn stack if it does not exist
28-
CMD="aws cloudformation list-stacks --query 'StackSummaries[?StackStatus==\`CREATE_COMPLETE\`].StackName' | grep \\\"${STACK_ID}\\\" | wc -l | tr -d ' '"
33+
CMD="aws cloudformation list-stacks --query 'StackSummaries[?StackStatus==\`CREATE_COMPLETE\`].StackName' ${REGION_OPT} | grep \\\"${STACK_ID}\\\" | wc -l | tr -d ' '"
2934
if [ ! "$VERBOSE" == "false" ]; then echo -e "\n${CMD}\n"; fi
3035
STACK_COUNT=$(eval $CMD)
3136
echo "STACK_COUNT=$STACK_COUNT"

Container-Root/setup.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,40 @@ popd
4141
# Install helm
4242
./hyperpod/setup/eks/install-helm.sh
4343

44-
# Install docker
45-
./hyperpod/setup/install-docker.sh
46-
47-
# Install golang
48-
./hyperpod/setup/install-go.sh
49-
5044
# Install python
5145
./hyperpod/setup/install-python.sh
5246
python -m pip install torchx[kubernetes]
5347

54-
# Install monitui
55-
./hyperpod/setup/eks/install-monitui.sh
56-
5748
# Install kubeps1 and configure bashrc aliases
5849
./hyperpod/setup/eks/install-kubeps1.sh
5950

6051
# Install bash customizations
6152
./hyperpod/setup/install-bashrc.sh
6253

63-
# Install k9s
64-
./hyperpod/setup/eks/install-k9s.sh
65-
6654
# Install hyperpod-eks
6755
./hyperpod/setup/eks/install-hyperpod-eks.sh
6856

6957
# Install sbom utilities
7058
./hyperpod/setup/install-sbom-utils.sh
7159

60+
if [ ! "$MOD" == "compact" ]; then
61+
# Install docker
62+
./hyperpod/setup/install-docker.sh
63+
64+
# Install golang
65+
./hyperpod/setup/install-go.sh
66+
67+
# Install monitui
68+
./hyperpod/setup/eks/install-monitui.sh
69+
70+
# Install k9s
71+
./hyperpod/setup/eks/install-k9s.sh
72+
73+
apt clean
74+
75+
pip cache purge
76+
fi
77+
7278
# Generate SBOM and store it in the root of the container image
7379
./sbom.sh
7480

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ FROM public.ecr.aws/ubuntu/ubuntu:22.04
33
ARG http_proxy
44
ARG https_proxy
55
ARG no_proxy
6+
ARG MOD
67

78
ENV DEBIAN_FRONTEND=noninteractive
89
ENV AWS_PAGER=""
910
ENV VERBOSE="true"
1011

1112
ADD Container-Root /
1213

13-
RUN export http_proxy=$http_proxy; export https_proxy=$https_proxy; export no_proxy=$no_proxy; /setup.sh; rm -f /setup.sh
14+
RUN export http_proxy=$http_proxy; export https_proxy=$https_proxy; export no_proxy=$no_proxy; export MOD=$MOD; /setup.sh; rm -f /setup.sh
1415

1516
WORKDIR /hyperpod
1617

0 commit comments

Comments
 (0)