forked from sciabarra/sites12c-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0-machine-amazon.sh
28 lines (28 loc) · 1.22 KB
/
0-machine-amazon.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
#!/bin/bash
DOCKER_MACHINE_NAME=${1:?machine name}
AWS_KEY=${2:?amazon access key}
AWS_SECRET=${3:?amazon secret key}
AWS_VPC=${4:?amazon vpc id}
MTYPE=t2.large
#${6:?machine type - recommended t2.large for build, t2.medium to run}
echo "eval \$(docker-machine env $DOCKER_MACHINE_NAME)" >_machine.sh
echo "AWS_KEY=$AWS_KEY">>_machine.sh
echo "AWS_SECRET=$AWS_SECRET">>_machine.sh
echo "AWS_VPC=$AWS_VPC">>_machine.sh
# create machine
docker-machine create --driver amazonec2 \
--amazonec2-vpc-id "$AWS_VPC" \
--amazonec2-access-key "$AWS_KEY" \
--amazonec2-secret-key "$AWS_SECRET" \
--amazonec2-root-size 30 \
--amazonec2-instance-type $MTYPE $DOCKER_MACHINE_NAME
# add swap space
docker-machine ssh $DOCKER_MACHINE_NAME "sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=2048"
docker-machine ssh $DOCKER_MACHINE_NAME "sudo /bin/chmod 0600 /var/swap.1"
docker-machine ssh $DOCKER_MACHINE_NAME "sudo /sbin/mkswap /var/swap.1"
docker-machine ssh $DOCKER_MACHINE_NAME "sudo /sbin/swapon /var/swap.1"
docker-machine ssh $DOCKER_MACHINE_NAME "free"
# print info
echo Please create a dns alias to this ip for installing sites:
docker-machine ip $DOCKER_MACHINE_NAME
echo "Either build sites with step 1 or restore an existing image with step 5"