Skip to content

Commit

Permalink
Cache from master & reduce noise
Browse files Browse the repository at this point in the history
  • Loading branch information
noodl committed Jan 23, 2024
1 parent 59fcfc0 commit 4aa8ff0
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ setup() {
exit 1
fi

echo "Setting up variables for $1"

# Setup the env that contains the application name and repo name
export APP=$(cat .buildkite/.application)
export REPO=$1/$APP
Expand All @@ -35,7 +33,6 @@ setup() {

# convert --<switch> to a variable
switches() {
echo "Processing switches"
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
v="${1/--/}"
Expand All @@ -48,8 +45,6 @@ switches() {

# validate list of switch names exist as a set variable
validate_switches() {
echo "Validating switches"

arr=("$@")

set +u
Expand All @@ -66,9 +61,9 @@ validate_switches() {
}

# target => (Optional) set the target build stage to build
# tag => tag for the docker image
# file => source docker file to build from
# cache_id => cache identifier from where it was built from. Typically GH branch name
# tag => variant of the docker image e.g. app or database
# file => source Dockerfile
# cache_id => typically the git branch name
buildx() {
target=
switches "$@"
Expand All @@ -84,14 +79,15 @@ buildx() {

docker buildx build \
-f $file \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg CI_BRANCH \
--build-arg CI_STRING_TIME \
--cache-to mode=max,image-manifest=true,oci-mediatypes=true,type=registry,ref=$BK_CACHE:$APP-$tag-$cache_id \
--cache-from $BK_CACHE:$APP-$tag-$cache_id \
--cache-from $BK_CACHE:$APP-$tag-master \
--secret id=railslts,env=BUNDLE_GEMS__RAILSLTS__COM \
--secret id=jfrog,env=BUNDLE_SAGEONEGEMS__JFROG__IO \
--ssh default $OPTIONAL_TARGET \
--ssh default \
$OPTIONAL_TARGET \
--load \
-t $REPO:$tag \
.
Expand Down

0 comments on commit 4aa8ff0

Please sign in to comment.