Skip to content

Commit

Permalink
Do not use docker images for build and release
Browse files Browse the repository at this point in the history
Previously, we used a custom docker image with `helm` and `aws-cli`
installed in order to generate Helm charts and to sync the generated
files to S3. This docker image is very outdated and hosted on Docker
Hub.

To simplify local development, remove docker dependency and keep the
dependencies fresher, in this PR:

* Removed custom docker image and the wrapper script
* `helm` is installed run-time
* Use `aws-cli` installed system-wide
* Simplified docs

Epic: RE-539
  • Loading branch information
rail committed Jan 9, 2024
1 parent 628ef25 commit 0dde094
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 121 deletions.
28 changes: 3 additions & 25 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
# Building, Testing and Releasing

The scripts and docker images used for testing, building and deploying.

Installing docker is a prerequisite. The instructions differ depending on the
environment. Docker is comprised of two parts: the daemon server which runs on
Linux and accepts commands, and the client which is a Go program capable of
running on MacOS, all Unix variants and Windows.


## Docker Installation

Follow the [Docker install
instructions](https://docs.docker.com/engine/installation/).


## Available Images
The scripts is used for testing, building and deploying.

### Building

The build image is a basic image containing Helm. To use it:

```
/.../helm-charts $ ./build/builder.sh helm package cockroachdb
/.../helm-charts $ helm package cockroachdb
```


## Upgrading / Extending the Builder Image

- Edit `build/builder/Dockerfile` as desired
- Run `build/builder.sh init` to test -- this will build the image locally. The result of `init` is a docker image version which you can subsequently stick into the `version` variable inside the `builder.sh` script for testing locally.
- Once you are happy with the result, run `build/builder.sh push` which pushes your image towards Docker hub, so that it becomes available to others. The result is again a version number, which you then *must* copy back into `build/builder.sh`. Then commit the change to both Dockerfile and `build/builder.sh` and submit a PR.


## Building Catalog Images for helm chart operator

- Export the following environment while running locally:
QUAY_DOCKER_USERNAME, QUAY_DOCKER_TOKEN
- Run `make prepare_bundle` to prepare the bundle to be pushed on community-operators. The `/bundle` directory at the root folder contains the template for the bundle which will get updated after executing the above command. The same directory can then be used to manually place under the new version in the community-operators repo. NOTE: This will not build the helm chart operator or the catalog bundle image
- Run `make build-and-release-olm-operator` to prepare the bundle as well as build and push the helm chart operator image and catalog bundle image to the registry provided above as environment variables.
- Run `make build-and-release-olm-operator` to prepare the bundle as well as build and push the helm chart operator image and catalog bundle image to the registry provided above as environment variables.
62 changes: 0 additions & 62 deletions build/builder.sh

This file was deleted.

15 changes: 0 additions & 15 deletions build/builder/Dockerfile

This file was deleted.

22 changes: 13 additions & 9 deletions build/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

set -euxo pipefail

# Absolute path to the toplevel helm-charts directory.
helm_charts_toplevel="$(dirname "$(cd "$(dirname "${0}")"; pwd)")/"
relative_artifacts_dir="build/artifacts/"
artifacts_dir="/charts/${relative_artifacts_dir}"
builder="${helm_charts_toplevel}/build/builder.sh"
charts_hostname="${CHARTS_HOSTNAME:-charts.cockroachdb.com}"

mkdir -p "${helm_charts_toplevel}${relative_artifacts_dir}"
HELM_INSTALL_DIR=$PWD/bin
mkdir -p "$HELM_INSTALL_DIR"
curl -fsSL -o "$HELM_INSTALL_DIR/get_helm.sh" https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 "$HELM_INSTALL_DIR/get_helm.sh"
export PATH="$HELM_INSTALL_DIR":$PATH
HELM_INSTALL_DIR="$HELM_INSTALL_DIR" "$HELM_INSTALL_DIR/get_helm.sh" --no-sudo --version v3.13.3

artifacts_dir="build/artifacts/"
mkdir -p "$artifacts_dir"

# Grab the current index.yaml to merge into the new index.yaml.
curl "https://s3.amazonaws.com/${charts_hostname}/index.yaml" > "${relative_artifacts_dir}/old-index.yaml"
curl -fsSL "https://s3.amazonaws.com/${charts_hostname}/index.yaml" > "${artifacts_dir}/old-index.yaml"

# Build the charts
"${builder}" helm package cockroachdb --destination "${artifacts_dir}"
"${builder}" helm repo index "${artifacts_dir}" --url "https://${charts_hostname}" --merge "${artifacts_dir}/old-index.yaml"
$HELM_INSTALL_DIR/helm package cockroachdb --destination "${artifacts_dir}"
$HELM_INSTALL_DIR/helm repo index "${artifacts_dir}" --url "https://${charts_hostname}" --merge "${artifacts_dir}/old-index.yaml"
diff -u "${artifacts_dir}/old-index.yaml" "${artifacts_dir}/index.yaml"
15 changes: 5 additions & 10 deletions build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -euo pipefail

helm_charts_toplevel="$(dirname "$(cd "$(dirname "${0}")"; pwd)")/"
builder="${helm_charts_toplevel}/build/builder.sh"
charts_hostname="${CHARTS_HOSTNAME:-charts.cockroachdb.com}"

if [ -n "${DISTRIBUTION_ID-}" ] ; then
Expand All @@ -15,15 +13,12 @@ elif [ "${charts_hostname-}" = "charts-test.cockroachdb.com" ] ; then
fi

# Push the new chart file and updated index.yaml file to S3
"${builder}" env \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
aws s3 sync "build/artifacts/" "s3://${charts_hostname}" --exclude old-index.yaml
# We rely on the aws-cli version installed system-wide.
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
aws s3 sync "build/artifacts/" "s3://${charts_hostname}" --exclude old-index.yaml

# Invalidate any cached version of index.yaml (so this version is immediately available)
if [ -n "${distribution_id}" ] ; then
"${builder}" env \
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
aws cloudfront create-invalidation --distribution-id "${distribution_id}" --paths /index.yaml
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
aws cloudfront create-invalidation --distribution-id "${distribution_id}" --paths /index.yaml
fi

0 comments on commit 0dde094

Please sign in to comment.