Skip to content

Commit

Permalink
Update to Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Keller committed Sep 17, 2020
1 parent 6d252f6 commit 7b41e4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ FROM ruby:2.5-slim
COPY Gemfile Gemfile.lock /usr/src/app/
WORKDIR /usr/src/app

RUN apt-get update && apt-get -y install iproute2 curl jq libgmp3-dev ruby-dev build-essential sqlite libsqlite3-dev && \
RUN apt-get update && apt-get -y install iproute2 curl jq libgmp3-dev ruby-dev build-essential sqlite libsqlite3-dev python3 python3-pip && \
bundle install && \
pip3 install awscli && \
apt-get autoremove -y --purge && \
apt-get remove -y --auto-remove --purge ruby-dev libgmp3-dev build-essential libsqlite3-dev && \
apt-get clean && \
rm -rvf /root/* /root/.gem* /var/cache/*

COPY . /usr/src/app
RUN chmod +x /usr/src/app/startup.sh
RUN chmod +x /usr/src/app/startup-cdk.sh

# helpful when trying to update gems -> bundle update, remove the Gemfile.lock, start ruby
# RUN bundle update
Expand All @@ -20,4 +21,4 @@ RUN chmod +x /usr/src/app/startup.sh
HEALTHCHECK --interval=10s --timeout=3s \
CMD curl -f -s http:https://localhost:3000/health/ || exit 1
EXPOSE 3000
ENTRYPOINT ["bash","/usr/src/app/startup.sh"]
ENTRYPOINT ["bash","/usr/src/app/startup-cdk.sh"]
5 changes: 4 additions & 1 deletion startup-cdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ if [[ -z ${zone} ]]; then
declare -a subnets=( $(aws ec2 describe-subnets | jq .Subnets[].CidrBlock| sed ':a;N;$!ba;s/\n/ /g') )
for sub in "${subnets[@]}"; do
if $(ruby -e "puts(IPAddr.new($sub.to_s).include? $ip_addr.to_s)") == 'true'; then
zone=$(aws ec2 describe-subnets | jq -r ".Subnets[] | select(.CidrBlock==$sub) | .AvailabilityZone" | grep -o .$)
details=$(aws ec2 describe-subnets | jq -r ".Subnets[] | select(.CidrBlock==$sub)")
if [[ $(echo $details | jq .Tags) != "null" ]]; then
zone=$(echo $details | jq -r 'select(.Tags[].Value=="ecsworkshop") | .AvailabilityZone' | sort -u | grep -o .$)
fi
fi
done
fi
Expand Down

0 comments on commit 7b41e4e

Please sign in to comment.