Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21 from newrelic/cloud9-setup
Browse files Browse the repository at this point in the history
Create deployment script for AWS Cloud9
  • Loading branch information
qryuu authored Feb 26, 2020
2 parents 1be4a39 + 2056f2d commit 61c96b5
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cloud9/Kata-Setup/1.kata-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

git clone https://github.com/newrelic/newrelic-ruby-kata /home/ec2-user/newrelic-ruby-kata
13 changes: 13 additions & 0 deletions cloud9/Kata-Setup/2.kata-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
curl -sSL https://get.rvm.io | bash -s stable
source /home/ec2-user/.rvm/scripts/rvm

cd /home/ec2-user/newrelic-ruby-kata

rvm rvmrc warning ignore allGemfiles
rvm install "ruby-2.2.2"

bundle install
6 changes: 6 additions & 0 deletions cloud9/Kata-Setup/3.kata-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cd /home/ec2-user/newrelic-ruby-kata

bundle exec rake db:create
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U $USER -d newrelic-ruby-kata_development public/sample-data.dump
37 changes: 37 additions & 0 deletions cloud9/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# new-relic-kata-setup

## English
### Script to set up the kata training environment

Enter the following script in Amazon Linux 2 EC2 Userdata.

```sh: Userdata
#! / bin / bash
  
curl -L https://raw.githubusercontent.com/newrelic/newrelic-ruby-kata/master/cloud9/userdata.sh | bash
```

Connect Cloud9 to the started Instance,
1.kata-download.sh,
2.kata-install.sh,
3.kata-setup.sh
Ruby-kata is set up by executing the above in order.
Running kata-start.sh starts the Kata environment.

## Japanise
### kataトレーニング環境をセットアップするスクリプト

Amazon Linux 2 EC2 Userdataに以下のスクリプトを入力します。

``` sh:Userdata
#!/bin/bash
curl -L https://raw.githubusercontent.com/newrelic/newrelic-ruby-kata/master/cloud9/userdata.sh | bash
```

起動したInstanceにCloud9を接続し、
1.kata-download.sh、
2.kata-install.sh、
3.kata-setup.sh
上記を順番に実行するとRuby-kataがセットアップされます。
kata-start.sh を実行するとKata環境がスタートします。
5 changes: 5 additions & 0 deletions cloud9/kata-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

cd /home/ec2-user/newrelic-ruby-kata

bundle exec rails server -b 0.0.0.0
29 changes: 29 additions & 0 deletions cloud9/userdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

yum update -y
amazon-linux-extras install -y epel
yum install -y python3
yum install -y gcc-c++ openssl-devel git readline-devel
yum install -y openssl-devel readline-devel zlib-devel curl-devel libyaml-devel libffi-devel
yum install -y node.js npm
yum install -y postgresql postgresql-devel postgresql-server postgresql-contrib postgresql-docs

chmod 755 /home/ec2-user

sudo -u ec2-user curl -L https://raw.githubusercontent.com/c9/install/master/install.sh | bash

systemctl enable postgresql.service
postgresql-setup initdb
systemctl start postgresql.service

sudo -u postgres createuser -s ec2-user
sudo -u postgres createdb ec2-user
sudo -u postgres psql -c "ALTER USER \"ec2-user\" WITH SUPERUSER;"

sed -i -e "s/host all all 127.0.0.1\/32 ident/host all all 127.0.0.1\/32 trust/g" /var/lib/pgsql/data/pg_hba.conf

systemctl restart postgresql.service

git clone https://github.com/qryuu/new-relic-kata-setup.git /home/ec2-user/new-relic-kata-setup

chown ec2-user.ec2-user -R /home/ec2-user/new-relic-kata-setup

0 comments on commit 61c96b5

Please sign in to comment.