Skip to content

Commit 095c9a2

Browse files
committed
Setup for elastic beanstalk
1 parent 3f20116 commit 095c9a2

File tree

8 files changed

+253
-0
lines changed

8 files changed

+253
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
branch-defaults:
2+
master:
3+
environment: cakeredux-prod
4+
environment-defaults:
5+
cakeredux-prod:
6+
branch: null
7+
repository: null
8+
global:
9+
application_name: cakeredux
10+
default_platform: java-8
11+
default_ec2_keyname: javabin
12+
default_platform: 64bit Amazon Linux 2016.09 v2.2.0 running Java 8
13+
default_region: eu-central-1
14+
profile: javabin
15+
sc: git
16+
deploy:
17+
artifact: app.zip

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: java -jar -Xmx512m -Dserver.port=5000 -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -Djava.security.egd=file:///dev/urandom app.jar /var/app/current/config.properties
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
30663937316136633731323837303232333662353736656464626366666530613866316536366265
3+
3334313434386664653037356265666339376337373135340a303964663063653664356632373762
4+
63636638333536346136323638383661613838333964613131313761336135646433346539363931
5+
6137376563613734300a353237316433366564633661306133613835623137623162306537356136
6+
35333239616263653937373962343632633534636336353265363434353861306235326566303865
7+
65396439323837643833303662393335313035373662373061326564336564333639306239373130
8+
34383531336439643539396334623264663765386437333438656435613261363238366439323463
9+
34306639303865396233346632643261626633626533633661376134326236313638333638666333
10+
31633830333138663063353739363031386537633961656362646636376235393466356132633537
11+
34386564643638386435363636643065323736633363353532623766616232626635656632616234
12+
38343036633862663634616131333338643232366233396339393630613562633330626535336562
13+
37363464643530303335376534306433393062363965623161646136663938653838336236313839
14+
30326161366439616533616336646632636566343366333661643939626565313534643162353062
15+
30306661363133353337613339393663363331386662633764306462323963306335313761326132
16+
34376235613837386463646466376266333138373365303536633036656232323665643461646138
17+
62316161656532353164663465366539623638326439643064643766373765393635353766663437
18+
38636365373461613130656630626539323863656338333666333132646561633633326337623238
19+
32643839346232363139306138643766623735343338356661623938633338353362616437396636
20+
65356131393266346466663066323234373332313431306339643131366565356237343966363133
21+
36383630643863336435653565666332393834383165643866343161346330346562346332316265
22+
65373436623437663739313861363264613062666638326530623262653363663230336462643938
23+
34313962653365376137666563376535326136663138306664366536643366633039323130666538
24+
63333334313038646563333266386230333133363561383031393861326130366233623831666137
25+
39633632366631343866326264643339643630633235633330386164316437393937383539396637
26+
65616465666430616534323234353432326335313630373633376363643033393439323963383966
27+
65613530323366643534663239393662303633663666343662363765633261636235306134396462
28+
64643063656133363364323832313032653835313935653764393664326665613236363162666364
29+
38333561393434386431343038396161303762623636316361343535633239643237633637616230
30+
30376461383836616130323736303730626162663464643334613437363862643737356365363538
31+
39386139386132636562656136306134333830363836396364396235333034393532663933363266
32+
37663261383731306632623063366361343133633065346161613765663664333864376363653334
33+
64373437333831363933316237636166626333633839316632623731343766643631653064663434
34+
30356562333062653465383633343566393833656130643237343537316562316364373034346438
35+
35386463623830373233303731303765633733303364656639633561393063386462363734356661
36+
65326237333339623132313138636462396237393833666261653934386661373137393735396330
37+
35316363613163333330653339316235323239663733313431303265363032656566363364373163
38+
64623133343838626334373836306230656361666163373035333865653137366633396563663032
39+
39623539316331383733373264663266346666346562666333396263656437393037623635623962
40+
32353064333837623831656337323665613863366462343636663631366231353165636235336261
41+
66393866323339333834636133626663343833393236326330333464326537303234663833623139
42+
64383239636335353231373364346135653734646634643765363438393763333665623663396332
43+
34623234633132303363623161393066646462336161636663313538363763396364316535376237
44+
63633637313039643830383737353935643231626435636666363639616538393563616434663233
45+
32303732343462663664356638373838653362386637666664376665323463376238616430633131
46+
35633739663062646265653036343766336434346664393865646533306638316561613538393139
47+
36373662346635313532373733323134643339616430356362393433663837623833656336343862
48+
34373334343161653230343831333864303435376566346231323934626132636162353062613032
49+
32376333343439343537623161633661306664653939336665636436663034396430353861383037
50+
32376434636438653236336663313234613735656238363435366361333732396134316265313663
51+
66356134613135373262623038363230663938336232323835633730346361383063326564366566
52+
33313836643632366336373466653263353166633839343935396262356332643166363061353033
53+
32653264393231643137653137613961623936376533373036626132383864336166636661633037
54+
66393833323033396662396535336462306639336435623466616262376537383736336638623737
55+
61623263303031343465366632623830613038366465626265306365316130633532363464383137
56+
34366634373531613534373133306538626334633237383230363938303163323034303735646233
57+
61376530376265626332376666363030393164376663353664373334656435663830313139323134
58+
64363535383762306531356665396165306331613535636661313830333635616364306633356465
59+
31306232303165323836646638303735353035616631373462646164303962316164346430386338
60+
63363131326135323334303234353834303363323766366233613064313531336131366337393733
61+
37303866636366393230656166383832366562633536363534626165343236323762663436366563
62+
35656134646361613162323232396339353163396139633232323332633264333631346133656636
63+
66346533366364376430343966313764313431363731353035333637346139346537313633343735
64+
61626433343037373535653238313336643330316438633638336335333439656361393334626334
65+
62343036656239316335313738346238663439396433383831396164656131326437353037646437
66+
64333733663934633832353836303234616130623362613934383735616433306637653531356462
67+
3963393230346131356265373764653866393365643665363263

config/prod.properties.encrypted

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
65343263646363323032366632353035346566316166663039343038623239616538356164643831
3+
3833323433636462383265656130306266656630643566320a333964376435333735613962306665
4+
66373732623064393038656231353035666534356534623365623431336566396438326365643533
5+
3434666139336362300a626133616362646562653636626633313632336531376138643732346166
6+
32373430626433306139393535373134313463343636363963343932346632323837616137343361
7+
39383663636461613532363563633437623262303631343763613965313137326462386635343433
8+
65303837646232626332643731613235633436353037613865323461363865343738376265373233
9+
62623639363136363037383337333837656432653138353930633834343933353331613033303733
10+
33333431613137353332343062356162663636383064633330613031393533393230386262626634
11+
32626531353162623433306639366562613563336630616266386163356239393738633962666432
12+
37363862643038623131663537333763353433623639626162373565633731333930353037396264
13+
38653735626231616136393061643734353564666332666133316564393762626137336662613666
14+
37313638353331663237366439633464643466343066313932376466376633356462653061336330
15+
37393435343566643736376261326630666132323865643139663339643236633539613530646465
16+
34653230393636626637303239663436613730373661383730323838376164303666383631333062
17+
30656266303365303161333739333030666461333065333263386563393336326636373037656631
18+
34633165646164343035616436653261343639653838323535633532393061643162666138653261
19+
63326462346436656163363439316439376461306636383133663934623062303730653032303764
20+
62616131383133366433653434616531643666623231643762623437346636323862646230303661
21+
39616639363138656532393933356537396166366363393939373637656361663065356361356238
22+
39376536323539383633616536346462363239393435356162376230386666323464343763666661
23+
38373865393636363438663339393339646432313039626634306636363065313634373233343730
24+
35303966653136313635643062343537353266373537366530376435393961633661343731393830
25+
31616139346561643462363434393465313766333533653061303335613132396231363733616263
26+
64333762373564643339386138343235666161643033393561646166313437383166333266346465
27+
32353435386164653236333233363761313861366662663366333462346466653939623331323234
28+
32633337653161663936356464666562623839313730333462303633356535643338363736653231
29+
32306362613233383335613830343230616635623161646136323066656538366466393536323066
30+
64633035303839356662356134666335323364613861373765393463653636386532636264636132
31+
32306431633037383130383466636631396330396435666532616337383564313631626137613231
32+
37326561363261333437323365333866356534323338393537313063323438393763346533373662
33+
32643233316163396261663139653736383465653033383665663632366664326533373832303037
34+
37636332663836353339663362366239393932363962303333353565363432333631363031646661
35+
38653266366462393234336263653239633163613761333861663630346266306566623361353365
36+
34383066343530383135613433656438386634363163393637353830336464343366353631323936
37+
33396337613561666561623564373538373138623335336136656432646565643335373666386439
38+
36616133653937333232386139656531353434376265366539343765653161376230363562323130
39+
32383438346363663838363564363135393434323566623665303634653631653361626532313339
40+
30313036326263633531303963653235666364356564393938623761633736646237303537313264
41+
61376430646530373530356566353138623135616237306336383734636631613764646438653033
42+
61633964323162366262653237383332383062396135353730303533613134663635373864363831
43+
34346365396563396433326466313031363163643639343066653565333533643132373630623337
44+
37633431316665323765323662383234613533623433386262643239616264383838356365643161
45+
33646465313262626136613631653330623364623034373766666365363939656163633135343065
46+
37363266346633633766613766316633636436623234633930303231643862383661383961353038
47+
3563663832623463616663636430346632626166353634323866

deploy.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
3+
BASEDIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4+
5+
# resolve symlinks
6+
while [ -h "$BASEDIR/$0" ]; do
7+
DIR=$(dirname -- "$BASEDIR/$0")
8+
SYM=$(readlink $BASEDIR/$0)
9+
BASEDIR=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)
10+
done
11+
cd ${BASEDIR}
12+
13+
beanstalk_env=${1}
14+
app=sleepingPillCore
15+
envs=$(eb list | sed 's/^\* //')
16+
17+
if [[ ${beanstalk_env} != ${app}-* ]]; then
18+
echo "Usage: ${0} ${app}-<environment>"
19+
echo
20+
echo "Available environments:"
21+
echo "${envs}"
22+
exit 1
23+
elif [ $(echo "${envs}" | grep "^${beanstalk_env}$" -c) -eq 0 ]; then
24+
echo "Environment not recognized: '${beanstalk_env}'. Use one of the following:"
25+
echo
26+
echo "${envs}"
27+
exit 1
28+
fi
29+
30+
local_version=$( grep -E "<version>[0-9]+(\.[0-9]+).*(SNAPSHOT)?</version>" pom.xml -m1 2> /dev/null | sed 's/.*<version>\(.*\)<\/version>/\1/' )
31+
32+
version_suggestion="[${local_version}] "
33+
read -p "Version? ${version_suggestion}" version
34+
[ -z ${version} ] && version="${local_version}"
35+
36+
env=$(echo ${beanstalk_env} | sed s/${app}-//g)
37+
38+
trap "{ rm -f app.zip app.jar ${secret_properties_file} ; exit 255; }" EXIT
39+
40+
./package.sh ${env} ${version}
41+
if [ $? -ne 0 ]; then
42+
echo "> Package failed!"
43+
exit 1
44+
fi
45+
46+
if [ "${2}" == "debug" ]; then
47+
echo "Debug mode. Skipping deploy."
48+
rm -f app.zip
49+
exit 0
50+
fi
51+
52+
echo "> Deploying sleepingPillCore to ${beanstalk_env}"
53+
eb deploy "${beanstalk_env}"
54+
55+
echo "> Deleting app.zip"
56+
rm -f app.zip
57+
58+
echo "> Deploy complete.'"
59+
exit 0

mavenrelease.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
mvn release:prepare -Darguments="-DskipTests" && mvn release:perform -Darguments="-DskipTests"

package.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
BASEDIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
4+
5+
# resolve symlinks
6+
while [ -h "$BASEDIR/$0" ]; do
7+
DIR=$(dirname -- "$BASEDIR/$0")
8+
SYM=$(readlink $BASEDIR/$0)
9+
BASEDIR=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)
10+
done
11+
cd ${BASEDIR}
12+
13+
if [ -z ${1} ] || [ -z ${2} ]; then
14+
echo "Usage: ${0} <env> <version>"
15+
exit 1
16+
fi
17+
18+
app=cake-redux
19+
env=${1}
20+
version=${2}
21+
22+
echo "> Assembling files"
23+
secret_properties_file="config.properties"
24+
25+
ansible-vault decrypt "config/${env}.properties.encrypted" --output=${secret_properties_file}
26+
if [ ! -f ${secret_properties_file} ]; then
27+
echo "Something went wrong with decrypting secret properties. File ${secret_properties_file} is missing. Can't deploy..."
28+
exit 1
29+
fi
30+
31+
authorization_file=cakeauthorized.txt
32+
33+
ansible-vault decrypt "config/cakeauthorized.${env}.encrypted" --output=${authorization_file}
34+
if [ ! -f ${secret_properties_file} ]; then
35+
echo "Something went wrong with decrypting secret properties. File ${authorization_file} is missing. Can't deploy..."
36+
exit 1
37+
fi
38+
39+
40+
cp ~/.m2/repository/no/java/${app}/${version}/${app}-${version}-jar-with-dependencies.jar ./app.jar
41+
if [ $? -ne 0 ]; then
42+
rm -f ${secret_properties_file}
43+
exit 1
44+
fi
45+
46+
echo "> Packaging app"
47+
chmod 644 ${secret_properties_file}
48+
zip -r app.zip app.jar .ebextensions Procfile ${secret_properties_file} ${authorization_file}
49+
if [ $? -ne 0 ]; then
50+
rm -f app.jar ${secret_properties_file}
51+
echo "> Package failed!"
52+
exit 1
53+
fi
54+
rm -f app.jar ${secret_properties_file}
55+
echo "> Done packaging app"

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,8 @@
172172
<url>https://repository.jboss.org/nexus/content/repositories/public-jboss/</url>
173173
</repository>
174174
</repositories>
175+
<scm>
176+
<developerConnection>scm:git:[email protected]:javabin/cake-redux.git</developerConnection>
177+
<tag>HEAD</tag>
178+
</scm>
175179
</project>

0 commit comments

Comments
 (0)