Skip to content

Commit

Permalink
Testing pull request with squashing (#91)
Browse files Browse the repository at this point in the history
* web based deploy uses master, debug message for deploy process ref #78
* nginx with ssl ref, nginx restart moved, bash_profile src'ed correctly ref #79
* contributing guide with better env and contribution info
  • Loading branch information
seeReadCode committed Apr 5, 2017
1 parent f5c8106 commit 838e4ba
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .env.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ GOOGLE_ANALYTICS_ID=
DATABASE_NAME=
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_HOST=
DATABASE_HOST=localhost
SECRET_KEY_BASE=
HOST=
MAIL_USER=
MAIL_USER=[email protected]
MAIL_PASSWORD=
MAIL_DOMAIN=
MAIL_ADDRESS=
MAIL_DOMAIN=gmail.com
MAIL_ADDRESS=smtp.gmail.com
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing

## Setup
Fork, then clone the repo:

```
git clone [email protected]:your-username/coyote.git
```

Push to your fork, refer to our issues, and submit a [pull request](https://github.com/coyote-team/coyote/compare/develop...) to develop when you have changes rebased into a clean set of commits.

## Before you pull

No merge bubbles please.

```
git pull --rebase
# or default rebase instead of merge
git config branch.autosetuprebase always # Force all new branches to automatically use rebase
git config branch.*branch-name*.rebase true # Force existing branches to use rebase.
```

## Before you push

Clean up your local commits.

```
git pull
git rebase -i
git push
```


## Making changes
The `master` branch is used for our auto-deploy process and should be deploy-ready. Minor changes should target or be made on the `develop` branch. Substantial, feature-related changes should be made on a corresponding feature branch based off of `develop` branch. Commits should be rebased for conciseness and clarity before pull requests are made and within the `develop` branch and feature branches.

Changes are merged into `master` with a sauash:

```
git merge --squash develop
```
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ An open source image annotation app and API to enable the distributed annotation
```bash
bundle install

# Copy the top block of .env.example to .env and populate
# Copy the bottom block of .env.example to .env.development
# Copy the bottom block of .env.example to .env.test
# Populate .env files
bin/conf_creator.sh .env # Copy this and the next one from other developers if working on an existing project
bin/conf_creator.sh .env.production
bin/conf_creator.sh .env.development
bin/conf_creator.sh .env.test

# Create the DBs for dev and test
bin/rake db:create db:migrate db:seed
RAILS_ENV=test bin/rake db:create db:migrate
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def index
def deploy
@deployed_at = Rails.cache.fetch("deployed_at", expires_in: 5.minutes) do
pid = spawn("bin/deploy_self.sh #{Rails.env}")
Rails.logger.info("Deploying with pid #{pid.to_s}")
Process.detach(pid)
Time.now
end
Expand All @@ -77,7 +78,7 @@ def check_commit
@latest_commit = Rails.cache.fetch("latest_commit", expires_in: 5.minutes) do
require 'open-uri'
builds = JSON.load(open("https://api.travis-ci.org/repos/coyote-team/coyote/builds.json"))
builds = builds.map{|b| b if b["result"]==0}.compact
builds = builds.map{|b| b if b["branch"]=="master" && b["result"]==0}.compact
builds[0]["commit"].first(7)
end
@deployed_at = Rails.cache.read("deployed_at")
Expand Down
42 changes: 17 additions & 25 deletions app/views/home/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -148,31 +148,16 @@
%h2 Deploy Status
- if @latest_commit
- if @latest_commit != @current_commit
- if !Rails.env.development?
- if @deployed_at.nil?
-disable_with = "<i id='disable-me' class='fa fa-spinner fa-spin fa-fw'></i>"
- klass= 'btn btn-primary'
- form_klass = "inline-form deploy"
- disabled = false
= button_to deploy_path, params: {},
form_class: form_klass, class: klass, disabled: disabled, method: :post, remote: true,
data: {disable_with: disable_with} do
Update
.sr-only
Latest commit:
= link_to "https://github.com/coyote-team/coyote/commit/" + @latest_commit, target: "_blank" do
=@latest_commit
%br
Current commit:
= link_to "https://github.com/coyote-team/coyote/commit/" + @current_commit, target: "_blank" do
=@current_commit
- else
- if @deployed_at + 5.minutes >= Time.now
Deploying...
- else
Redeploy run at:
= @deployed_at
-else
- if @deployed_at.nil?
-disable_with = "<i id='disable-me' class='fa fa-spinner fa-spin fa-fw'></i>"
- klass= 'btn btn-primary'
- form_klass = "inline-form deploy"
- disabled = false
= button_to deploy_path, params: {},
form_class: form_klass, class: klass, disabled: disabled, method: :post, remote: true,
data: {disable_with: disable_with} do
Update
%br
%p
Latest commit:
= link_to "https://github.com/coyote-team/coyote/commit/" + @latest_commit, target: "_blank" do
Expand All @@ -181,6 +166,13 @@
Current commit:
= link_to "https://github.com/coyote-team/coyote/commit/" + @current_commit, target: "_blank" do
=@current_commit
- else
%p
- if @deployed_at + 5.minutes >= Time.now
Deploying...
- else
Redeploy run at:
= @deployed_at
- else
%p
Up to date at:
Expand Down
15 changes: 8 additions & 7 deletions bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,17 @@ source /home/coyote/code/coyote/.env
source /home/coyote/code/coyote/.env.production

# create database
export SQL="create database " $DATABASE_NAME "; ALTER DATABASE " $DATABASE_NAME " charset=utf8; CREATE USER " $DATABASE_USERNAME " @localhost IDENTIFIED BY '" $DATABASE_PASSWORD "'; grant all on " $DATABASE_NAME ".* to " $DATABASE_USERNAME "@localhost; use mysql; flush privileges;"
mysql -uroot -p -e $SQL
SQL="create database ${DATABASE_NAME}; ALTER DATABASE ${DATABASE_NAME} charset=utf8; CREATE USER ${DATABASE_USERNAME}@${DATABASE_HOST} IDENTIFIED BY '${DATABASE_PASSWORD}'; grant all on ${DATABASE_NAME}.* to ${DATABASE_USERNAME}@${DATABASE_HOST}; use mysql; flush privileges;"
mysql -uroot -e "${SQL}"

# setup ssl
service nginx stop
# TODO ask if ready for this step
letsencrypt certonly --standalone -d $HOST -t --email $SUPPORT_EMAIL --agree-tos

# nginx
sed s/HOST/$HOST/g /home/coyote/code/coyote/config/nginx.coyote.conf > /etc/nginx/sites-available/nginx.coyote.conf
ln -s /etc/nginx/sites-available/nginx.coyote.conf /etc/nginx/sites-enabled/
rm /etc/nginx/sites-available/default

service nginx restart
echo "127.0.0.1 " $HOST >> /etc/hosts

#logrotate
Expand All @@ -103,14 +100,18 @@ echo "Install completed!"

# deploy
su coyote
cd
source ~/.bash_profile
cd ~/code/coyote
bundle exec cap production deploy

# seed
source /home/coyote/code/coyote/.env
source /home/coyote/code/coyote/.env.production
# TODO sed to change the default user and admin credentials first in db/seeds.rb
TASK="db:seed" bundle exec cap production rake
exit
echo "Deploy and seed completed!"

# nginx restart
service nginx restart

echo "Install, deploy and seed completed! Please open a browser and check your site"
4 changes: 2 additions & 2 deletions config/nginx.coyote.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ server {
listen [::]:80 default ipv6only=on;
listen 443 default ssl;

#ssl_certificate /etc/ssl/HOST.pem;
#ssl_certificate_key /etc/ssl/HOST.pem;
ssl_certificate /etc/letsencrypt/live/HOST/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/HOST/privkey.pem

access_log /home/coyote/data/coyote/current/log/access.log;
error_log /home/coyote/data/coyote/current/log/error.log;
Expand Down

0 comments on commit 838e4ba

Please sign in to comment.