-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from cristim/self-contained
Self contained execution, without any dependencies
- Loading branch information
Showing
10 changed files
with
74 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
build | ||
autospotting | ||
coverage.out | ||
lambda/GIT_SHA | ||
lambda/autospotting_lambda | ||
lambda/instances.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,46 @@ | ||
BINARY=autospotting | ||
LAMBDA_BINARY=autospotting_lambda | ||
LOCAL_PATH=build/s3/dv | ||
BUCKET_NAME=cloudprowess | ||
|
||
# upstream data | ||
#INSTANCES_URL="https://raw.githubusercontent.com/powdahound/ec2instances.info/master/www/instances.json" | ||
# my Github fork | ||
INSTANCES_URL="https://raw.githubusercontent.com/cristim/ec2instances.info/master/www/instances.json" | ||
|
||
all: build_local | ||
|
||
release: upload | ||
|
||
build_local: | ||
check_deps: | ||
./check_deps.sh | ||
|
||
build_local: check_deps | ||
go build $(GOFLAGS) | ||
|
||
build_lambda: | ||
build_lambda_binary: check_deps | ||
GOOS=linux GOARCH=amd64 go build -o ${LAMBDA_BINARY} | ||
|
||
strip: build_lambda | ||
strip: build_lambda_binary | ||
strip ${LAMBDA_BINARY} | ||
upx --lzma --best ${LAMBDA_BINARY} | ||
|
||
install: strip | ||
CHECKSUM=$$(sha256sum ${LAMBDA_BINARY} | cut -f1 -d " " ); \ | ||
FILENAME=${BINARY}_$$CHECKSUM ; \ | ||
mkdir -p ${LOCAL_PATH} ; \ | ||
mv ${LAMBDA_BINARY} ${LOCAL_PATH}/$$FILENAME ; \ | ||
echo $$FILENAME > ${LOCAL_PATH}/latest_agent | ||
lambda: strip | ||
git rev-parse HEAD | cut -c 1-8 > lambda/GIT_SHA | ||
mv ${LAMBDA_BINARY} lambda/ | ||
curl ${INSTANCES_URL} --output lambda/instances.json | ||
zip -9 -v -j lambda lambda/* | ||
rm -rf ${LOCAL_PATH} | ||
mkdir -p ${LOCAL_PATH} | ||
mv lambda.zip ${LOCAL_PATH} | ||
|
||
install: lambda | ||
|
||
upload: install | ||
aws s3 sync build/s3/ s3://cloudprowess/ | ||
aws s3 sync build/s3/ s3://${BUCKET_NAME}/ | ||
|
||
test: build_local | ||
./autospotting -e core/test_data/event.json -c core/test_data/context.json | ||
./autospotting core/test_data/json_instance/instances.json | ||
|
||
cover: | ||
go test -covermode=count -coverprofile=coverage.out ./core && go tool cover -html=coverage.out | ||
go test -covermode=count -coverprofile=coverage.out ./core | ||
go tool cover -html=coverage.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
function check_dep { | ||
command -v $1 >/dev/null 2>&1 || { | ||
echo >&2 "The required dependency program '$1' is not installed. Aborting." | ||
exit 1 | ||
} | ||
} | ||
|
||
DEPS="aws curl git go strip zip" | ||
|
||
echo "Checking for the presence of the following dependencies: ${DEPS}" | ||
|
||
for DEP in $DEPS | ||
do | ||
check_dep $DEP && echo "Found ${DEP}" | ||
done | ||
echo "All dependencies were successfully found, we're good to go!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters