codex-factory/scripts/bee-docker-build.sh
nugaon b8e451e57e
feat: bee 1.0.0 (#41)
* feat: new Price Oracle bytecode

* refactor: remove file smth.txt

* feat: new PostageStamp contract

* feat: change contract deploy workflow

* feat: bee-1.0.0-rc2 compatible runner

* feat: build from source (#47)

* feat: extend build-envrionment.sh with building bee image from source

* ci: new workflow option parameter - beeVersionAsCommitHash

* fix(ci): try to overwrite BEE_VERSION sys variable

* fix: do not export BEE_VERSION after env build

* fix(ci): run build-environment without source command

* fix(ci): try to retrieve built BEE_VERSION value

* fix: save build BEE_VERSION value

* fix(ci): retrieve built image tag in the last step

* refactor: echoerr

* refactor(ci): export sys variables

* feat: disable warmup time (#46)

* feat: disable warmup time

* fix: place warmup-time to the correct place

* fix: put quote back where it truly belongs

* feat: state commit (#45)

* refactor: remove payment treshold option because it causes performance issues

* docs: design planned parameters for the new build workflow

* feat: build environment with traffic gen option

* fix(log): rephrase traffic gen log

* feat: special bee version tagging when state commit happens

* build: new env variable STATE_COMMIT

* ci: STATE_COMMIT

* feat: state commit scripts

* refactor: destroy containers after state producing

* refactor: remove unnecessary echo

* fix: blockchain version at state commit

* build: bumo bee-js version

* build: update package-lock

* fix: fixes

* ci: build environment workflow with state commit

* refactor: buy larger stamp

* fix: publish workflow

* refactor: increase stamp depth

* fix: bee version fetch at commit

* refactor: start containers normally instead of ephemeral for debugging

* fix(ci): add chown for bee user on bee-data-dirs in order to write bee state

* fix: try out the permission on bee data dir with 777 chmod

* fix(ci): give folder permission in the build environment phrase

* refactor(ci): raise sleep between uploads in order to generate cheques

* refactor: wait 11 secs after batch purchase

* fix: commit version tag string true instead of boolean

* fix: add state commit check for set COMMIT_VERSION_TAG

* chore: bump bee version

Co-authored-by: Cafe137 <77121044+Cafe137@users.noreply.github.com>
2021-06-21 16:10:55 +02:00

65 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
dockerfile() {
cat << DOCKERFILE > "$1"
FROM ethersphere/bee:$2
# Sample docker file
COPY --chown=bee:bee . /home/bee/.bee
DOCKERFILE
}
dockerbuild() {
IMAGE_NAME=$(basename "$1")
IMAGE_NAME="$4/$IMAGE_NAME"
docker build "$1" --no-cache -f "$2" -t "$IMAGE_NAME:$3"
}
MY_PATH=$(dirname "$0")
MY_PATH=$( cd "$MY_PATH" && pwd )
BEE_DIRS=$(ls -d "$MY_PATH"/bee-data-dirs/*/)
BEE_VERSION=$("$MY_PATH/utils/env-variable-value.sh" BEE_VERSION)
BEE_IMAGE_PREFIX=$("$MY_PATH/utils/env-variable-value.sh" BEE_IMAGE_PREFIX)
STATE_COMMIT=$("$MY_PATH/utils/env-variable-value.sh" STATE_COMMIT)
OFFICIAL_BEE_IMAGE="ethersphere/bee:$BEE_VERSION"
# Make sure we the user has permission all the files
echo "Build Bee Docker images..."
echo "You may need to pass your password for sudo permission to give the right permission to the bee-data folders"
sudo chmod 777 -R "$MY_PATH/bee-data-dirs"
echo "Update common dockerfile"
dockerfile "$MY_PATH/bee-data-dirs/Dockerfile" "$BEE_VERSION"
### BEE_VERSION ALTERNATIONS START
# If the user has been set the COMMIT_VERSION_TAG env variable
# The image will be built with the tag that is the bee version string
COMMIT_VERSION_TAG="$("$MY_PATH/utils/env-variable-value.sh" COMMIT_VERSION_TAG)"
if [ "$COMMIT_VERSION_TAG" == "true" ] ; then
echo "Image version tag will be extracted from the bee version command..."
docker pull $OFFICIAL_BEE_IMAGE
# somehow the version command's output goes to the stderr
BEE_VERSION=$(docker run --rm $OFFICIAL_BEE_IMAGE version 2>&1)
echo "Extracted Bee version: $BEE_VERSION"
"$MY_PATH/utils/build-image-tag.sh" set "$BEE_VERSION"
fi
if [ "$STATE_COMMIT" == 'true' ] ; then
echo "The bee image will be built with their state"
BEE_VERSION+="-stateful"
"$MY_PATH/utils/build-image-tag.sh" set "$BEE_VERSION"
echo "Stateful Bee version: $BEE_VERSION"
fi
### BEE_VERSION ALERNATIONS END
echo "Build Dockerfiles"
for BEE_DIR in $BEE_DIRS
do
echo "Build Bee version $BEE_VERSION on $BEE_DIR"
dockerbuild "$BEE_DIR" "$MY_PATH/bee-data-dirs/Dockerfile" "$BEE_VERSION" "$BEE_IMAGE_PREFIX"
done
echo "Docker image builds were successful!"