Update user-data and rearange requirements installation

This commit is contained in:
Dustin Pianalto 2019-12-25 23:41:16 -09:00
parent 83cd5046f4
commit bdaea8040a
2 changed files with 11 additions and 8 deletions

View File

@ -33,9 +33,9 @@ WORKDIR /code
COPY requirements/base.txt .
COPY requirements/production.txt .
COPY requirements/geeksbot.txt .
RUN pip install -r production.txt
COPY requirements/geeksbot.txt .
RUN pip install -r geeksbot.txt
ENV REDIS_DB 0

View File

@ -1,12 +1,15 @@
#!/bin/bash
yum update -y
export AWS_DEFAULT_REGION='us-east-1'
instance_id=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 associate-address --instance-id $instance_id --public-ip "34.238.62.161"
mkdir /code || exit
cd /code || exit
git clone git@github.com:dustinpianalto/geeksbot_v2.git
cd geeksbot_v2 || exit
role=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$instance_id" | grep -2 role | grep Value | tr -d ' ' | cut -f2 -d: | tr -d '"' | tr -d ',')
if [ "$role" = "development" ]; then
aws ec2 associate-address --instance-id "$instance_id" --public-ip "3.211.100.13"
git checkout development
else
aws ec2 associate-address --instance-id "$instance_id" --public-ip "34.238.62.161"
git checkout master
fi
docker build . -t geeksbot || exit
docker run -d -v /code/geeksbot_v2:/code -v /root/.ssh:/root/.ssh:ro --name geeksbot --restart always geeksbot:latest || exit