Build: Move final build artifact to dist/ directory

This commit is contained in:
Mike Salvatore 2021-07-28 07:53:33 -04:00
parent 5de6a562ba
commit 6aff4a16b2
4 changed files with 26 additions and 4 deletions

View File

@ -22,7 +22,7 @@ remove build artifacts by running `appimage/clean.sh`
### Running the AppImage
The build script will produce an AppImage executable named
`Infection_Monkey-x86_64.AppImage`. Simply execute this file and you're off to
`./dist/Infection_Monkey-x86_64.AppImage`. Simply execute this file and you're off to
the races.
A new directory, `$HOME/.monkey_island` will be created to store runtime
@ -42,4 +42,5 @@ NOTE: This script is intended to be run from a clean VM. You can also manually
remove build artifacts by running `docker/clean.sh`
### Running the Docker Image
See `docker/DOCKER_README.md` for instructions on running the docker image.
The build script will produce a `.tgz` file in `./dist/`. See
`docker/DOCKER_README.md` for instructions on running the docker image.

View File

@ -122,11 +122,15 @@ add_apprun() {
}
build_package() {
local version=$1
local dist_dir=$2
log_message "Building AppImage"
pushd "$APPIMAGE_DIR"
ARCH="x86_64" appimagetool "$APPIMAGE_DIR/squashfs-root"
apply_version_to_appimage "$1"
apply_version_to_appimage "$version"
move_package_to_dist_dir $dist_dir
popd
}
@ -135,3 +139,7 @@ apply_version_to_appimage() {
log_message "Renaming Infection_Monkey-x86_64.AppImage -> Infection_Monkey-$1-x86_64.AppImage"
mv "Infection_Monkey-x86_64.AppImage" "Infection_Monkey-$1-x86_64.AppImage"
}
move_package_to_dist_dir() {
mv Infection_Monkey*.AppImage "$1/"
}

View File

@ -2,6 +2,8 @@ WORKSPACE=${WORKSPACE:-$HOME}
DEFAULT_REPO_MONKEY_HOME=$WORKSPACE/git/monkey
MONKEY_ORIGIN_URL="https://github.com/guardicore/monkey.git"
NODE_SRC=https://deb.nodesource.com/setup_12.x
BUILD_SCRIPTS_DIR="$(realpath $(dirname $BASH_SOURCE[0]))"
DIST_DIR="$BUILD_SCRIPTS_DIR/dist"
log_message() {
echo -e "\n\n"
@ -187,12 +189,16 @@ if ! is_valid_git_repo "$monkey_repo"; then
clone_monkey_repo "$monkey_repo" "$branch"
fi
if [ ! -d "$DIST_DIR" ]; then
mkdir "$DIST_DIR"
fi
install_build_prereqs
install_package_specific_build_prereqs "$WORKSPACE"
setup_build_dir "$agent_binary_dir" "$monkey_repo"
build_package "$monkey_version"
build_package "$monkey_version" "$DIST_DIR"
log_message "Finished building package: $package"
exit 0

View File

@ -36,6 +36,7 @@ copy_server_config_to_build_dir() {
build_package() {
local version=$1
local dist_dir=$2
pushd ./docker
docker_image_name="guardicore/monkey-island:$version"
@ -44,6 +45,8 @@ build_package() {
build_docker_image_tar "$docker_image_name" "$tar_name"
build_docker_image_tgz "$tar_name" "$version"
move_package_to_dist_dir $dist_dir
popd
}
@ -58,3 +61,7 @@ build_docker_image_tgz() {
cp ./DOCKER_README.md ./tgz/README.md
tar -C ./tgz -cvf "$OUTPUT_NAME_TGZ" --gzip .
}
move_package_to_dist_dir() {
mv $OUTPUT_NAME_TGZ "$1/"
}