-
Notifications
You must be signed in to change notification settings - Fork 2
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 #183 from wri/develop
Develop to master
- Loading branch information
Showing
5 changed files
with
96 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This is the same build script as in gfw-lambda-layers/terraform/modules/lambda_layer/scripts/build.sh | ||
# It builds and runs a docker as specified in ${1}/Dockerfile to create a layer.zip. | ||
|
||
set -e | ||
|
||
LAYER_PATH="${1}" | ||
IMAGE="globalforestwatch/${2}" | ||
|
||
echo -n "${LAYER_PATH}" > "${LAYER_PATH}/foo.txt" | ||
date >> "${LAYER_PATH}/foo.txt" | ||
CONTAINER_NAME="container_$(sha1sum ${LAYER_PATH}/foo.txt |cut -c 1-8)" | ||
|
||
pushd "${LAYER_PATH}" | ||
|
||
echo "BUILD image ${IMAGE}" | ||
docker build --no-cache -t "${IMAGE}" . | ||
|
||
echo "CREATE container ${CONTAINER_NAME}" | ||
docker run -itd --name "${CONTAINER_NAME}" "${IMAGE}" /bin/bash | ||
|
||
echo "COPY ZIP package to host" | ||
docker cp "${CONTAINER_NAME}":"/opt/layer.zip" layer.zip | ||
|
||
echo "STOP container" | ||
docker stop "${CONTAINER_NAME}" | ||
docker wait "${CONTAINER_NAME}" | ||
|
||
echo "REMOVE container" | ||
docker rm -f "${CONTAINER_NAME}" | ||
|
||
popd |
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,10 @@ | ||
#!/bin/bash | ||
|
||
# This does a hash of the zip file, but that includes all the modified times of the | ||
# files, which keep changing, even when the file names and contents are the same. I | ||
# tried generating a hash using only filenames and contents, but terraform seems to | ||
# create its own hash of the layer.zip file as well, so basically we're always going | ||
# to update the layer.zip no matter what, which seems fine. | ||
hash=$(sha256sum $1 | cut -d' ' -f1) | ||
|
||
echo '{ "hash": "'"$hash"'" }' |