diff --git a/Dockerfile b/Dockerfile index 29dd437..eac1469 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/user-data.sh b/user-data.sh index ac90d36..6a43560 100644 --- a/user-data.sh +++ b/user-data.sh @@ -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