/
ami-build.sh
57 lines (47 loc) · 1.77 KB
/
ami-build.sh
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
#!/bin/bash
exec > /var/log/openemr-launch.log 2>&1
REPOBRANCH=master
DOCKERLABEL=:6.0.0
while getopts "b:d:" opt; do
case $opt in
b)
REPOBRANCH=$OPTARG
;;
d)
DOCKERLABEL=$OPTARG
;;
\?)
echo "Invalid option: -$opt" >&2
exit 1
;;
esac
done
# pull in all updates
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes
# grab packages
apt-get install -y apt-transport-https ca-certificates git jq duplicity awscli python-boto python-pip
# CloudFormation hooks
pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
# get production Docker pages
apt-get update
apt-get install jq git duplicity -y
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
# apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-compose -y
# grab our Docker instance
docker pull openemr/openemr${DOCKERLABEL}
# get the rest of the devops repo and docker-tools
cd /root
if [[ $REPOBRANCH == master ]]; then
git clone --single-branch https://github.com/openemr/openemr-devops.git && cd openemr-devops/packages/standard
else
git clone --single-branch --branch $REPOBRANCH https://github.com/openemr/openemr-devops.git && cd openemr-devops/packages/standard
fi
chmod +x ami/*.sh scripts/*.sh
curl -L https://github.com/docker/compose/releases/download/1.15.0/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
echo ami-build.sh: done