|
a |
|
b/deployment/build-s3-dist.sh |
|
|
1 |
#!/bin/bash |
|
|
2 |
# |
|
|
3 |
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned |
|
|
4 |
# |
|
|
5 |
# This script should be run from the repo's deployment directory |
|
|
6 |
# cd deployment |
|
|
7 |
# ./build-s3-dist.sh source-bucket-base-name solution-name version-code |
|
|
8 |
# |
|
|
9 |
# Paramenters: |
|
|
10 |
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda |
|
|
11 |
# code from. The template will append '-[region_name]' to this bucket name. |
|
|
12 |
# For example: ./build-s3-dist.sh solutions my-solution v1.0.0 |
|
|
13 |
# The template will then expect the source code to be located in the solutions-[region_name] bucket |
|
|
14 |
# |
|
|
15 |
# - solution-name: name of the solution for consistency |
|
|
16 |
# |
|
|
17 |
# - version-code: version of the package |
|
|
18 |
|
|
|
19 |
# Check to see if input has been provided: |
|
|
20 |
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then |
|
|
21 |
echo "Please provide the base source bucket name, trademark approved solution name and version where the lambda code will eventually reside." |
|
|
22 |
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.0" |
|
|
23 |
exit 1 |
|
|
24 |
fi |
|
|
25 |
|
|
|
26 |
# Get reference for all important folders |
|
|
27 |
template_dir="$PWD" |
|
|
28 |
template_dist_dir="$template_dir/global-s3-assets" |
|
|
29 |
build_dist_dir="$template_dir/regional-s3-assets" |
|
|
30 |
source_dir="$template_dir/../source" |
|
|
31 |
|
|
|
32 |
cp $source_dir/setup_cfn.yml $template_dir/guidance-for-multi-omics-and-multi-modal-data-integration-and-analysis-on-aws.template |
|
|
33 |
cp $source_dir/setup_cfn.yml $template_dir/$SOLUTION_NAME.template |
|
|
34 |
|
|
|
35 |
echo "------------------------------------------------------------------------------" |
|
|
36 |
echo "[Init] Clean old dist" |
|
|
37 |
echo "------------------------------------------------------------------------------" |
|
|
38 |
echo "rm -rf $template_dist_dir" |
|
|
39 |
rm -rf $template_dist_dir |
|
|
40 |
echo "mkdir -p $template_dist_dir" |
|
|
41 |
mkdir -p $template_dist_dir |
|
|
42 |
#echo "rm -rf $build_dist_dir" |
|
|
43 |
#rm -rf $build_dist_dir |
|
|
44 |
echo "mkdir -p $build_dist_dir" |
|
|
45 |
mkdir -p $build_dist_dir |
|
|
46 |
|
|
|
47 |
echo "------------------------------------------------------------------------------" |
|
|
48 |
echo "[Packing] Templates" |
|
|
49 |
echo "------------------------------------------------------------------------------" |
|
|
50 |
echo "cp $template_dir/*.template $template_dist_dir/" |
|
|
51 |
cp $template_dir/*.template $template_dist_dir/ |
|
|
52 |
echo "copy yaml templates and rename" |
|
|
53 |
#cp $template_dir/*.yml $template_dist_dir/ |
|
|
54 |
#cd $template_dist_dir |
|
|
55 |
# Rename all *.yaml to *.template |
|
|
56 |
#for f in *.yml; do |
|
|
57 |
# mv -- "$f" "${f%.yml}.template" |
|
|
58 |
#done |
|
|
59 |
|
|
|
60 |
#cd .. |
|
|
61 |
echo "Updating code source bucket in template with $1" |
|
|
62 |
replace="s/%%BUCKET_NAME%%/$1/g" |
|
|
63 |
echo "sed -i '' -e $replace $template_dist_dir/*.template" |
|
|
64 |
sed -i '' -e $replace $template_dist_dir/*.template |
|
|
65 |
replace="s/%%SOLUTION_NAME%%/$2/g" |
|
|
66 |
echo "sed -i '' -e $replace $template_dist_dir/*.template" |
|
|
67 |
sed -i '' -e $replace $template_dist_dir/*.template |
|
|
68 |
replace="s/%%VERSION%%/$3/g" |
|
|
69 |
echo "sed -i '' -e $replace $template_dist_dir/*.template" |
|
|
70 |
sed -i '' -e $replace $template_dist_dir/*.template |
|
|
71 |
|
|
|
72 |
mkdir -p $build_dist_dir/references/hg38 |
|
|
73 |
mkdir -p $build_dist_dir/variants/1kg/ |
|
|
74 |
mkdir $build_dist_dir/variants/vcf/ |
|
|
75 |
mkdir -p $build_dist_dir/annotation/clinvar/ |
|
|
76 |
mkdir $build_dist_dir/tcga/ |
|
|
77 |
|
|
|
78 |
echo "------------------------------------------------------------------------------" |
|
|
79 |
echo "[Rebuild] Solution" |
|
|
80 |
echo "------------------------------------------------------------------------------" |
|
|
81 |
|
|
|
82 |
cd $source_dir |
|
|
83 |
|
|
|
84 |
bundle_dir="$source_dir/../bundle" |
|
|
85 |
mkdir -p $bundle_dir |
|
|
86 |
|
|
|
87 |
# create the lambda function deployment pacakage for the solution setup |
|
|
88 |
cd $source_dir/GenomicsAnalysisCode/setup |
|
|
89 |
pip install -t . crhelper |
|
|
90 |
zip -r $bundle_dir/SolutionSetup.zip . |
|
|
91 |
|
|
|
92 |
# package the solution |
|
|
93 |
cd $source_dir |
|
|
94 |
zip -r $bundle_dir/Solution.zip . |
|
|
95 |
|
|
|
96 |
# package new lambdas here |
|
|
97 |
|
|
|
98 |
# upload zips here |
|
|
99 |
|
|
|
100 |
cd $bundle_dir |
|
|
101 |
cp Solution.zip $template_dist_dir/ |
|
|
102 |
cp SolutionSetup.zip $template_dist_dir/ |
|
|
103 |
cp Solution.zip $build_dist_dir/ |
|
|
104 |
cp SolutionSetup.zip $build_dist_dir/ |