forked from bears4barrett/CloudMux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
152 lines (136 loc) · 6.66 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<project name="CloudMux" basedir="." default="package">
<property name="name" value="CloudMux" />
<property name="env" value="devint" />
<property file="${user.home}/${name}.properties"/>
<property file="${user.home}/build.properties"/>
<property name="config.filename" value="${user.name}.properties"/>
<property file="${config.filename}"/>
<property file="build.properties"/>
<property name="project.base.dir" value="${basedir}" />
<property name="src" value="${project.base.dir}/src" />
<property name="test" value="${project.base.dir}/test" />
<property name="build" value="${project.base.dir}/build" />
<property name="classes" value="${build}/classes" />
<property name="jar.dir" value="${project.base.dir}/build/lib/" />
<property name="lib" value="${build}/lib" />
<property name="external" value="${build}/external" />
<property name="external.jars" value="${build}/external/lib" />
<property name="resources" value="${project.base.dir}/resources" />
<property name="hudson.url" value="jenkins.momentumsoftware.com:8080/" />
<property name="dir.output" value="${basedir}/public/bin" />
<property name="dist" value="${project.base.dir}/dist" />
<property name="package.file" value="cloudmux.tar.gz"/>
<property name="cloudmux.home" value="/home/cloudmux"/>
<property name="dist.suffix" value="" />
<property name="toughresources" value="ToughResources${dist.suffix}" />
<property name="toughresources.dir" value="${project.base.dir}/../${toughresources}"/>
<!--All projects rely on toughresources so just have all property files reside there-->
<property name="env" value="dev"/>
<!-- if not specified before, assume dev. (won't deploy to a remote instance...-->
<property name="env.core.properties" value="${toughresources.dir}/resources/env/${env}.properties"/>
<echo message="env properties is ${env.core.properties}"/>
<property file="${env.core.properties}"/>
<target name="init">
<mkdir dir="${build}" />
<echo message="Base build directory = ${basedir}" />
<mkdir dir="${dist}" />
</target>
<target name="configure.ruby" depends="init">
<copy todir="${build}" overwrite="true">
<fileset dir="${resources}/">
<include name="seed/**"/>
</fileset>
<filterset filtersfile="${env.core.properties}"/>
</copy>
</target>
<target name="bundle">
<exec executable="ruby" failonerror="true">
<arg value="-v" />
</exec>
<exec executable="bundle" failonerror="true">
<arg value="install" />
<arg value="--deployment" />
<arg value="--without" />
<arg value="development" />
<arg value="test" />
</exec>
</target>
<target name="seed" depends="bundle">
<exec executable="which" failonerror="true">
<arg value="bundle" />
</exec>
<exec executable="bundle" failonerror="true">
<env key="STACK_PLACE_SERVICE_ENDPOINT" value="${env.stackplace.endpoint}"/>
<env key="MONGO_URI" value="${env.mongouri}"/>
<env key="RACK_ENV" value="${env.fullname}"/>
<env key="RAILS_ENV" value="${env.fullname}"/>
<arg value="exec" />
<arg value="rake" />
<arg value="db:seed" />
</exec>
</target>
<target name="warble" depends="bundle">
<exec executable="jruby" failonerror="true">
<arg value="-S" />
<arg value="warble" />
<arg value="compiled" />
<arg value="war" />
</exec>
</target>
<target name="make-docs" depends="bundle">
<exec executable="script/docs-gen.sh" failonerror="true">
</exec>
</target>
<target name="deploy" depends="bundle, make-docs, package">
<echo message="Deploying CloudMux to ${deploy.ip}"/>
<exec command="scp ${build}/${package.file} cloudmux@${deploy.ip}:/${cloudmux.home}" failonerror="true"/>
<exec command="ssh cloudmux@${deploy.ip} rm -r ${cloudmux.home}/CloudMux" failonerror="true"/>
<exec command="ssh cloudmux@${deploy.ip} tar xvzf ${cloudmux.home}/${package.file} -C ${cloudmux.home}" failonerror="true"/>
<exec command="ssh cloudmux@${deploy.ip} '. /etc/profile.d/rvm.sh; . /usr/local/etc/stack.env; cd ${cloudmux.home}/CloudMux; bundle install'" failonerror="true"/>
<exec command="ssh cloudmux@${deploy.ip} '. /etc/profile.d/rvm.sh; . /usr/local/etc/stack.env; cd ${cloudmux.home}/CloudMux; bundle exec rake db:seed'" failonerror="true"/>
<exec command="ssh cloudmux@${deploy.ip} sudo service apache2 restart" failonerror="true"/>
</target>
<target name="deployprod" depends="bundle, make-docs, package">
<echo message="Deploying CloudMux to ${deploy.ip}"/>
<exec command="scp ${build}/${package.file} ${deploy.ip}:/${cloudmux.home}" failonerror="true"/>
<exec command="ssh ${deploy.ip} rm -r ${cloudmux.home}/CloudMux" failonerror="true"/>
<exec command="ssh ${deploy.ip} tar xvzf ${cloudmux.home}/${package.file} -C ${cloudmux.home}" failonerror="true"/>
<exec command="ssh ${deploy.ip} '. /etc/profile.d/rvm.sh; . /usr/local/etc/stack.env; cd ${cloudmux.home}/CloudMux; rvm gemset use cloudmux; bundle install'" failonerror="true"/>
<exec command="ssh ${deploy.ip} '. /etc/profile.d/rvm.sh; . /usr/local/etc/stack.env; cd ${cloudmux.home}/CloudMux; rvm gemset use cloudmux; bundle exec rake db:seed'" failonerror="true"/>
<exec command="ssh ${deploy.ip} sudo service apache2 restart" failonerror="true"/>
</target>
<target name="package" depends="clean,init">
<tar destfile="${build}/${package.file}" compression="gzip">
<tarfileset dir="${project.base.dir}" prefix="CloudMux">
<exclude name=".git/**"/>
<exclude name=".bundle/**"/>
<exclude name="resources/**"/>
<exclude name="vendor/**"/>
<exclude name="build/**"/>
<exclude name="dist/**"/>
</tarfileset>
</tar>
</target>
<!-- This target is like package, but includes diff. seed file w/o passwords. -->
<target name="dist" depends="clean,init">
<tar destfile="${dist}/${package.file}" compression="gzip">
<tarfileset dir="${project.base.dir}" prefix="CloudMux">
<exclude name=".git/**"/>
<exclude name=".bundle/**"/>
<exclude name="resources/**"/>
<exclude name="vendor/**"/>
<exclude name="build/**"/>
<exclude name="dist/**"/>
<!-- dist-specific excludes. -->
<exclude name="api-docs/**"/>
<exclude name="seed/*.rb"/>
</tarfileset>
<tarfileset dir="${resources}" prefix="CloudMux">
<include name="seed/**"/>
</tarfileset>
</tar>
</target>
<target name="clean">
<delete dir="${project.base.dir}/build" />
</target>
</project>