Resolved comments
This commit is contained in:
parent
0ba941624e
commit
6500b770cf
8 changed files with 166 additions and 106 deletions
20
hack/README.md
Executable file
20
hack/README.md
Executable file
|
@ -0,0 +1,20 @@
|
||||||
|
## `hack/`
|
||||||
|
|
||||||
|
This directory provides scripts for building and pushing Docker images, and tagging new demo
|
||||||
|
releases.
|
||||||
|
|
||||||
|
### env variables
|
||||||
|
|
||||||
|
- `TAG` - git release tag / Docker tag.
|
||||||
|
- `REPO_PREFIX` - Docker repo prefix to push images. Format: `$user/$project`. Resulting images will be of the
|
||||||
|
format `$user/$project/$svcname:$tag` (where `svcname` = `adservice`, `cartservice`,
|
||||||
|
etc.)
|
||||||
|
|
||||||
|
### scripts
|
||||||
|
|
||||||
|
1. `./make-docker-images.sh`: builds and pushes images to the specified Docker repository.
|
||||||
|
2. `./make-release-artifacts.sh`: injects updated images/tag into
|
||||||
|
`./release/kubernetes-manifests/demo.yaml`.
|
||||||
|
3. `./restore-release-artifacts.sh`: restores image names/tags in `demo.yaml` to defaults
|
||||||
|
(`adservice`, `cartservice`, etc.)
|
||||||
|
4. `./make-release.sh`: runs scripts 1 and 2, then runs `git tag` / pushes updated manifests to master.
|
|
@ -1,29 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# set vars
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
DOCKER_REPO=$1
|
|
||||||
else
|
|
||||||
echo "Must provide a docker repo"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$2" ]; then
|
|
||||||
TAG=$2
|
|
||||||
else
|
|
||||||
echo "Must provide a version tag."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
for dir in ./src/*/
|
|
||||||
do
|
|
||||||
# build image
|
|
||||||
svcname=$(basename $dir)
|
|
||||||
image="$DOCKER_REPO/$svcname:$TAG"
|
|
||||||
echo "Building and pushing $image..."
|
|
||||||
docker build -t $image -f $dir/Dockerfile $dir
|
|
||||||
|
|
||||||
# push image
|
|
||||||
docker push $image
|
|
||||||
done
|
|
|
@ -1,29 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# set vars
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
DOCKER_REPO=$1
|
|
||||||
else
|
|
||||||
echo "Must provide a docker repo"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$2" ]; then
|
|
||||||
TAG=$2
|
|
||||||
else
|
|
||||||
echo "Must provide a version tag."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# inject new tag into the relevant k8s manifest
|
|
||||||
manifestfile="./release/kubernetes-manifests/demo.yaml"
|
|
||||||
|
|
||||||
for dir in ./src/*/
|
|
||||||
do
|
|
||||||
svcname=$(basename $dir)
|
|
||||||
image="$DOCKER_REPO/$svcname:$TAG"
|
|
||||||
|
|
||||||
pattern=".*image:.*$svcname.*"
|
|
||||||
replace=" image: $image"
|
|
||||||
sed -i '' "s|$pattern|$replace|g" $manifestfile
|
|
||||||
done
|
|
39
hack/make-docker-images.sh
Executable file
39
hack/make-docker-images.sh
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
# Copyright 2019 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Builds and pushes docker image for each demo microservice.
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
log() { echo "$1" >&2; }
|
||||||
|
fail() { log "$1"; exit 1; }
|
||||||
|
|
||||||
|
TAG="${TAG?TAG env variable must be specified}"
|
||||||
|
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}"
|
||||||
|
|
||||||
|
|
||||||
|
for dir in ./src/*/
|
||||||
|
do
|
||||||
|
# build image
|
||||||
|
svcname="$(basename $dir)"
|
||||||
|
image="$REPO_PREFIX/$svcname:$TAG"
|
||||||
|
echo "Building and pushing $image..."
|
||||||
|
docker build -t $image -f $dir/Dockerfile $dir
|
||||||
|
|
||||||
|
# push image
|
||||||
|
docker push $image
|
||||||
|
done
|
||||||
|
|
||||||
|
log "Successfully built and pushed images."
|
41
hack/make-release-artifacts.sh
Executable file
41
hack/make-release-artifacts.sh
Executable file
|
@ -0,0 +1,41 @@
|
||||||
|
# Copyright 2019 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# injects new image/tag into the images in ./release/kubernetes-manifests/demo.yaml
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
log() { echo "$1" >&2; }
|
||||||
|
fail() { log "$1"; exit 1; }
|
||||||
|
|
||||||
|
TAG="${TAG?TAG env variable must be specified}"
|
||||||
|
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}"
|
||||||
|
|
||||||
|
|
||||||
|
# inject new tag into the relevant k8s manifest
|
||||||
|
manifestfile="./release/kubernetes-manifests/demo.yaml"
|
||||||
|
|
||||||
|
for dir in ./src/*/
|
||||||
|
do
|
||||||
|
svcname="$(basename $dir)"
|
||||||
|
image="$REPO_PREFIX/$svcname:$TAG"
|
||||||
|
|
||||||
|
pattern=".*image:.*$svcname.*"
|
||||||
|
replace=" image: $image"
|
||||||
|
sed -i '' "s|$pattern|$replace|g" $manifestfile
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
log "Successfully injected image tag into demo.yaml".
|
|
@ -1,44 +1,41 @@
|
||||||
#!/bin/bash
|
# Copyright 2019 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
# set vars
|
# Creates a new release by 1) building/pushing images, 2) injecting tag into YAML,
|
||||||
if [ -n "$1" ]; then
|
# 3) creating a new git tag, and 4) pushing tags/updated YAML to $BRANCH.
|
||||||
DOCKER_REPO=$1
|
|
||||||
else
|
|
||||||
echo "Must provide a docker repo"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$2" ]; then
|
#!/usr/bin/env bash
|
||||||
TAG=$2
|
set -euo pipefail
|
||||||
else
|
|
||||||
echo "Must provide a version tag."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$3" ]; then
|
log() { echo "$1" >&2; }
|
||||||
BRANCH=$3
|
fail() { log "$1"; exit 1; }
|
||||||
else
|
|
||||||
echo "Must provide a git branch."
|
TAG="${TAG?TAG env variable must be specified}"
|
||||||
exit
|
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}"
|
||||||
fi
|
|
||||||
|
|
||||||
# build and push images
|
# build and push images
|
||||||
./build-push.sh $DOCKER_REPO $TAG
|
./hack/make-docker-images.sh
|
||||||
|
|
||||||
|
|
||||||
# update yaml
|
# update yaml
|
||||||
./inject-yaml.sh $DOCKER_REPO $TAG
|
./hack/make-release-artifacts.sh
|
||||||
|
|
||||||
|
# create git release / push to master
|
||||||
# git tag
|
log "Pushing k8s manifests to master..."
|
||||||
echo "Pushing git tag..."
|
git tag "$TAG"
|
||||||
git tag $TAG
|
git add release/
|
||||||
|
git commit --allow-empty -m "Release $TAG"
|
||||||
git push --tags
|
git push --tags
|
||||||
|
git push origin master
|
||||||
|
|
||||||
# push updated manifests
|
log "Successfully tagged release $TAG."
|
||||||
echo "Commiting to $BRANCH..."
|
|
||||||
git add .
|
|
||||||
git commit -m "Tagged release $TAG"
|
|
||||||
git push origin $BRANCH
|
|
||||||
|
|
||||||
echo "✅ Successfully tagged release $TAG"
|
|
||||||
|
|
35
hack/restore-release-artifacts.sh
Executable file
35
hack/restore-release-artifacts.sh
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
# Copyright 2019 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
|
# Restores images ./release/kubernetes-manifests/demo.yaml to match ./kubernetes-manifests
|
||||||
|
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
log() { echo "$1" >&2; }
|
||||||
|
fail() { log "$1"; exit 1; }
|
||||||
|
|
||||||
|
manifestfile="./release/kubernetes-manifests/demo.yaml"
|
||||||
|
|
||||||
|
# restore release/ manifest images to skaffold default, eg. "adservice"
|
||||||
|
for dir in ./src/*/
|
||||||
|
do
|
||||||
|
svcname=$(basename $dir)
|
||||||
|
pattern=".*image:.*$svcname.*"
|
||||||
|
replace=" image: $svcname"
|
||||||
|
sed -i '' "s|$pattern|$replace|g" $manifestfile
|
||||||
|
done
|
||||||
|
|
||||||
|
log "Restored demo.yaml."
|
|
@ -1,14 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
manifestfile="./release/kubernetes-manifests/demo.yaml"
|
|
||||||
|
|
||||||
# restore release/ manifest images to skaffold default, eg. "adservice"
|
|
||||||
for dir in ./src/*/
|
|
||||||
do
|
|
||||||
svcname=$(basename $dir)
|
|
||||||
image="$DOCKER_REPO/$svcname:$TAG"
|
|
||||||
|
|
||||||
pattern=".*image:.*$svcname.*"
|
|
||||||
replace=" image: $svcname"
|
|
||||||
sed -i '' "s|$pattern|$replace|g" $manifestfile
|
|
||||||
done
|
|
Loading…
Add table
Add a link
Reference in a new issue