forked from ec-europa/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
132 lines (111 loc) · 5.81 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
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Infra" default="help">
<property file="build.properties.local" />
<property file="build.properties" />
<property file="build.properties.dist" />
<property name="sparql.password" value="unsecure" />
<property name="drupal.db.password" value="unsecure" />
<property name="packer.path" value="/usr/bin/env packer" />
<property name="docker.path" value="/usr/bin/env docker" />
<property name="docker.http.port" value="8580" />
<property name="docker.mailcatcher.port" value="8581" />
<property name="application.name" value="unset" />
<property name="self.path" value="vendor/ec-europa/infra" />
<property name="github.ssh.keys" value="gboddin, rvanhoudt" />
<property name="packer.global.settings" value="${packer.args}
--var mysql_password=${drupal.db.password} --var site_type=${infra.type}
--var app_name=${application.name} --var virtuoso_password=${sparql.password}
--var doc_root=/srv/project/${documentroot.path}
--var s3_aws_secret_key=${s3.secret}
--var s3_aws_access_key=${s3.access}" />
<target name="build-cloudformation-ami" description="Create skeleton AMI in EC2">
<!-- Running packer for aws -->
<exec command="AWS_PROFILE=${aws.profile} ${packer.path} build
--var aws_region=${aws.region} ${packer.global.settings} aws.json"
passthru="true" dir="${self.path}/packer"/>
</target>
<target name="build-virtualbox-image" description="Create a deployable OVA from current project">
<!-- Running packer for virtualbox -->
<exec command="${packer.path} build
--var project_root=${project.basedir} ${packer.global.settings} virtualbox.json"
passthru="true" dir="${self.path}/packer"/>
</target>
<target name="docker-create-instance" description="Create a base docker image to run applications">
<!-- Running packer for docker -->
<exec command="${packer.path} build --var project_root=${project.basedir}
${packer.global.settings} docker-create.json"
passthru="true" dir="${self.path}/packer"/>
</target>
<target name="docker-install-app" description="Create a instance from the base docker image">
<!-- Running packer for docker -->
<exec command="${packer.path} build --var deploy_method=install --var project_root=${project.basedir}
${packer.global.settings} docker-update.json"
passthru="true" dir="${self.path}/packer"/>
</target>
<target name="docker-update-app" description="Update the application instance">
<!-- Running packer for docker -->
<exec command="${packer.path} build --var deploy_method=site-update --var project_root=${project.basedir}
${packer.global.settings} --var instance_tag=${application.name}-latest docker-update.json"
passthru="true" dir="${self.path}/packer"/>
</target>
<target name="docker-run-app" description="Run an instance of the application">
<!-- Running packer for docker -->
<exec command="${docker.path} run -t -i -p ${docker.http.port}:80 -p ${docker.mailcatcher.port}:1080 ${infra.type}-dev-instance:${application.name}-latest /start.sh"
passthru="true"
/>
</target>
<target name="setup-aws">
<property name="aws.profile" value="" />
<aws-config region="${aws.region}" profile="${aws.profile}" />
</target>
<target name="delete-deployment-group">
<aws-deploy-delete-deployment-group
name="${deploy.groupName}"
application="${deploy.applicationName}" />
</target>
<target name="delete-stack" depends="delete-deployment-group">
<aws-cf-deletestack name="${cf.stackName}" />
</target>
<target name="run-stack">
<aws-cf-runstack
name="${deploy.applicationName}-${cf.stackName}"
updateOnConflict="true"
capabilities="CAPABILITY_IAM"
templatePath="${self.path}/cloudformation/single-server.template">
<param name="KeyName" value="${cf.KeyName}" />
<param name="ApplicationName" value="${deploy.applicationName}" />
<param name="env" value="${cf.stackName}" />
<param name="SiteType" value="${infra.type}" />
<param name="GithubSSHKeys" value="${github.ssh.keys}"/>
<tag key="env" value="${cf.stackType}" />
</aws-cf-runstack>
</target>
<target name="run-stack-keep">
<aws-cf-runstack
name="${deploy.applicationName}-${cf.stackName}"
updateOnConflict="true"
capabilities="CAPABILITY_IAM"
templatePath="${self.path}/cloudformation/single-server.template">
<param name="KeyName" value="${cf.KeyName}" />
<param name="ApplicationName" value="${deploy.applicationName}" />
<param name="env" value="${cf.stackName}" />
<param name="SiteType" value="${infra.type}" />
<param name="GithubSSHKeys" value="${github.ssh.keys}"/>
<tag key="env" value="keep" />
</aws-cf-runstack>
</target>
<target name="setup-deployment-group">
<aws-deploy-deployment-group
name="${cf.stackName}"
updateOnConflict="true"
deploymentConfigName="CodeDeployDefault.OneAtATime"
serviceRole="${deploy.serviceRole}"
application="${deploy.applicationName}">
<ec2TagFilter key="stack" value="${deploy.applicationName}-${cf.stackName}" />
</aws-deploy-deployment-group>
</target>
<target name="site-update">
<drush command="updb" assume="yes" root="${project.basedir}/${documentroot.path}"
bin="${drush.bin}"/>
</target>
</project>