diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 5e0af64f5..ca149b47d 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -8,10 +8,10 @@ ENV BUILDKIT_FILENAME=buildkit-v${BUILDKIT_VERSION}.linux-amd64.tar.gz USER root # Install dazzle, buildkit and pre-commit -RUN cd /usr \ - && curl -sSL https://github.com/moby/buildkit/releases/download/v${BUILDKIT_VERSION}/${BUILDKIT_FILENAME} | tar -xvz \ - && curl -sSL https://github.com/gitpod-io/dazzle/releases/download/v0.1.8/dazzle_0.1.8_Linux_x86_64.tar.gz | tar -xvz dazzle \ +RUN curl -sSL https://github.com/moby/buildkit/releases/download/v${BUILDKIT_VERSION}/${BUILDKIT_FILENAME} | tar -xvz -C /usr \ + && curl -sSL https://github.com/gitpod-io/dazzle/releases/download/v0.1.8/dazzle_0.1.8_Linux_x86_64.tar.gz | tar -xvz -C /usr/local/bin \ && curl -sSL https://github.com/mvdan/sh/releases/download/v3.4.2/shfmt_v3.4.2_linux_amd64 -o /usr/bin/shfmt \ && chmod +x /usr/bin/shfmt \ && install-packages shellcheck \ - && sudo pip3 install pre-commit + && sudo pip3 install pre-commit \ + && curl -sSL https://github.com/mikefarah/yq/releases/download/v4.22.1/yq_linux_amd64 -o /usr/bin/yq && chmod +x /usr/bin/yq diff --git a/.gitpod.yml b/.gitpod.yml index e4a0eb62e..21b752a70 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -20,8 +20,9 @@ tasks: command: | gp await-port 5000 REPO=localhost:5000/dazzle - echo "To build specific chunks and combinations 'time ./dazzle-up.sh -c chunk1 -c chunk2 -n combo'" - echo "To build all the chunks and combinations 'time ./dazzle-up.sh'" + echo "To build specific chunks and combine them 'time ./build-chunk.sh -c chunk1 -c chunk2:variant1.2.3 -n combo'" + echo "To build all the chunks and combinations 'time ./build-all.sh'" + echo "To build a specific combination 'time ./build-combo.sh combo'" echo "To list image chunks 'dazzle project image-name $REPO'" echo "To list hashes for image chunks 'dazzle project hash $REPO'" echo "To print the combined image maniest 'dazzle project manifest $REPO'" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2877e51cb..5ab6163f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Here is a list of dependencies and tools: ## Locally -We ship a shell script [dazzle-up.sh](dazzle-up.sh) that can be used to build the images locally. See the following sub sections for usage. +We ship a shell script [build-all.sh](build-all.sh) that can be used to build the images locally. See the following sub sections for usage. This script will first build the chunks and run tests followed by creation of container images. It uses `dazzle` to perform these tasks. @@ -45,20 +45,32 @@ where `combo` is the name of the combination defined in [dazzle.yaml](dazzle.yam ### Build Specific Chunks -Often, you would want to test only the chunks that you modify. You can do that by using the `-c` flag. +Often, you would want to test only the chunks that you modify. You can do that with build-chunk.sh using the `-c` flag. ```console -./dazzle-up.sh -c lang-c -c dep-cacert-update -n mychangecombo +./build-chunk.sh -c lang-c -c dep-cacert-update -c lang-go:1.17.5 ``` -Above command will build only chunks `lang-c` and `dep-cacert-update` and combine the created chunks (all variants, if any exists) as a combination with name `mychangecombo`. +Above command will build only chunks `lang-c` and `dep-cacert-update`. + +The next step, is to test your changes with [./build-combo](#build-specific-combination). + +### Build Specific Combination + +Sometimes you only want to build one specific combination e.g. the `postgresql` or the `go` image. You can do that with + +```console +./build-combo.sh e.g. ./build-combo.sh postgresql +``` + +This will build all chunks that are referenced by the `go` combination and then combine them to create the `go` image. ### Build All Chunks Execute the following command to build using the default config `dazzle.yaml` shipped in this repo: ```bash -./dazzle-up.sh +./build-all.sh ``` > **NOTE:** Building images locally consumes a lot of resources and is often slow. diff --git a/build-all.sh b/build-all.sh new file mode 100755 index 000000000..920e6d2e1 --- /dev/null +++ b/build-all.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euo pipefail + +REPO=localhost:5000/dazzle +# First, build chunks without hashes +dazzle build $REPO -v --chunked-without-hash +# Second, build again, but with hashes +dazzle build $REPO -v +# Third, create combinations of chunks +dazzle combine $REPO --all -v diff --git a/dazzle-up.sh b/build-chunk.sh similarity index 55% rename from dazzle-up.sh rename to build-chunk.sh index dd7a2c46b..8ecfb9478 100755 --- a/dazzle-up.sh +++ b/build-chunk.sh @@ -1,39 +1,25 @@ #!/bin/bash set -euo pipefail -trap ctrl_c INT +trap ctrl_c EXIT -readonly YELLOW=$(tput setaf 3) -readonly NC=$(tput sgr0) +# shellcheck source=/dev/null +source build-common.sh -readonly BACKUP_FILE=".dazzle.yaml.orig" readonly TEMP_FILE=".dazzle.yaml.temp" -readonly ORIGINAL_FILE="dazzle.yaml" -readonly AVAILABLE_CHUNKS=$(ls chunks/) readonly REPO="localhost:5000/dazzle" function usage() { cat <