diff --git a/.env.development.example b/.env.development.example index 1534908c..1b408790 100644 --- a/.env.development.example +++ b/.env.development.example @@ -1,4 +1,3 @@ -APP_NAME=Coyote DATABASE_NAME=coyote_dev DATABASE_USERNAME= DATABASE_PASSWORD= diff --git a/.env.example b/.env.example index 3f1aaa69..eda4ddeb 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,3 @@ -#per site in .env REPO_NAME=coyote REPO_URL=https://github.com/coyote-team/coyote.git SUPPORT_EMAIL="coyote_admin@seeread.info" @@ -8,11 +7,9 @@ ASSET_SYNC_MANIFEST=true ROLLBAR_ACCESS_TOKEN= FLOWDOCK_PROJECT_NAME="" FLOWDOCK_API_TOKEN="" -SERVER_USER="" +SERVER_USER="coyote" PRODUCTION_IP="" STAGING_IP="" BOOKMARKLET="false" WEBSITE_URL="" WEBSITE_TITLE="" - - diff --git a/.env.production.example b/.env.production.example index 0e73d02d..8916cbd4 100644 --- a/.env.production.example +++ b/.env.production.example @@ -1,4 +1,3 @@ -APP_NAME= GOOGLE_ANALYTICS_ID= DATABASE_NAME= DATABASE_USERNAME= diff --git a/.env.test.example b/.env.test.example index c9b94932..ba37cd41 100644 --- a/.env.test.example +++ b/.env.test.example @@ -1,4 +1,3 @@ -APP_NAME=Coyote TENON_KEY= SECRET_KEY_BASE= DATABASE_NAME= diff --git a/README.md b/README.md index 7947d41d..eb4ecabd 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,13 @@ COYOTE [![Code Climate](https://codeclimate.com/github/coyote-team/coyote/badges/gpa.svg)](https://codeclimate.com/github/coyote-team/coyote) [![Test Coverage](https://codeclimate.com/github/coyote-team/coyote/badges/coverage.svg)](https://codeclimate.com/github/coyote-team/coyote/coverage) +An open source image annotation app and API to enable the distributed annotation of museum images. Coyote is built on RubyOnRails with MySQL (via MariaDB). -Image annotation site and API to enable the distributed annotation of museum images built on RubyOnRails with MySQL (via MariaDB). - -- [Coyote Repo](http://github.com/coyote-team/coyote) +- [Coyote repo](http://github.com/coyote-team/coyote) - [Coyote.pics](https://coyote.pics/) - [Museum of Contemporary Art Chicago's Coyote](http://coyote.mcachicago.org) -## Setup +## Developer Setup ```bash bundle install @@ -24,9 +23,10 @@ bundle install bin/rake db:create db:migrate db:seed RAILS_ENV=test bin/rake db:create db:migrate ``` -See [bin/install.sh](https://github.com/coyote-team/coyote/blob/master/bin/install.sh) if you need some help on managing your ruby versions, etc. -Secure creds are kept untracked in `.env` +For more information on environment or setup, see [bin/install.sh](https://github.com/coyote-team/coyote/blob/master/bin/install.sh) or the `Vagrantfile`. + +Secure credentials are kept untracked in `.env` and `.env.[development, test, staging, production]`. ## Usage @@ -47,7 +47,7 @@ bin/rails c ## Test -Lint the [FactoryGirls](https://github.com/thoughtbot/factory_girl) +Lint the model factories ([more info](https://github.com/thoughtbot/factory_girl)): ```bash bin/rake factory_girl:lint @@ -62,15 +62,15 @@ bin/rspec # Or dynamically via the guard daemon guard -# Leave that running while you develop -# Then press enter or update a page and the test suite will run +# Leave that running while your server is running and +# then press enter or update a page and the test suite will run ``` ## Deploy ```bash -# Copy the .env.production from the server +# This command will also copy your .env and .env.production to the server bundle exec cap production deploy ``` @@ -107,17 +107,17 @@ Assuming you are logged into an Ubuntu 16.04 LTS as a root... You will need to set the domain name to the new IP and then to prepare the following -1. A new Google Analytics UA identifier (for coyote UAs, click [here](https://analytics.google.com/analytics/web/#management/Settings/a86309615w128502418p132251424/)). +1. The production IP address, e.g. `173.255.234.50` 2. The new domain for coyote, e.g. `coyote.warhol.org`. -3. The name of the client institution. -4. The main website address. -5. The access token from previous project in `.env.production` -6. The production IP. +3. The name of the hostinginstitution, e.g. The Warhol. +4. The main website address, e.g. `http://www.warhol.ora` +5. (Optional) A new Google Analytics UA identifier (for coyote UAs, click [here](https://analytics.google.com/analytics/web/#management/Settings/a86309615w128502418p132251424/)). +6. (Optional) The Rollbar access token from previous project in `.env.production` Then you can run... ```bash -wget -qO- https://raw.githubusercontent.com/coyote/coyote/bin/install.sh | bash +wget -qO- https://raw.githubusercontent.com/coyote-team/coyote/master/bin/install.sh | bash ``` ## API @@ -151,13 +151,13 @@ For use on [nomnoml](http://www.nomnoml.com/) [Description | id: int | locale:str(en) | text: text | license:str(cc0-1.0)] [Website | id: int | url: string | title: string | strategy: string ] [Status | id: int | title: string | description: text] - [Meta| id: int| title: string | instructions: text] + [Metum| id: int| title: string | instructions: text] [Assignment]->[Image] [Assignment]->[User] [Description]->[User] - [Description]->[Meta] + [Description]->[Metum] [Description]->[Status] [Image]->[Group] diff --git a/bin/conf_creator.sh b/bin/conf_creator.sh index 5a264203..0bb4e777 100755 --- a/bin/conf_creator.sh +++ b/bin/conf_creator.sh @@ -2,7 +2,6 @@ # usage: # bin/conf_creator.sh .env.production -exec 3<> /dev/stdin IFS="=" TIMESTAMP=$(date) @@ -12,15 +11,21 @@ function populate { echo "#Created ${TIMESTAMP}" > $FILE while read -r NAME VALUE do - read -u 3 -p "$NAME? (default: $VALUE): " ANSWER - if [ ${#ANSWER} -eq 0 ] + if [ ${$NAME} -eq SECRET_KEY_BASE ] then - RESULT="$VALUE" + SECRET="$(bin/rake secret)" + echo "$NAME=$SECRET" >> $FILE else - RESULT="$ANSWER" + read -u 3 -p "$NAME? (default: $VALUE): " ANSWER + if [ ${#ANSWER} -eq 0 ] + then + RESULT="$VALUE" + else + RESULT="$ANSWER" + fi + echo "$NAME=$RESULT" >> $FILE fi - echo "$NAME=$RESULT" >> $FILE done < $SOURCE -} +} 3<&0 -populate .env +populate $1 diff --git a/bin/install.sh b/bin/install.sh index b76b5d00..ecf582fa 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -1,15 +1,15 @@ #!/bin/bash # Installs coyote on 16.04 ubuntu given a root login # usage: -# wget -qO- https://raw.githubusercontent.com/coyote/coyote/bin/install.sh | bash` +# wget -qO- https://raw.githubusercontent.com/coyote-team/coyote/master/bin/install.sh | bash -# aptitude +# aptitude update, upgrade, requirements, auto-upgrade apt update -y -apt-get upgrade -y +export DEBIAN_FRONTEND=noninteractive +apt-get upgrade -y -q # NOTE grub conflict on linode so keep current grub conf apt install software-properties-common -y add-apt-repository 'deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu xenial main' -export DEBIAN_FRONTEND=noninteractive apt-get install -q -y --allow-unauthenticated graphviz git libpq-dev gawk build-essential libreadline6-dev \ zlib1g-dev libssl-dev libyaml-dev autoconf libgdbm-dev libncurses5-dev automake libtool \ bison pkg-config libffi-dev mariadb-server libmariadb-client-lgpl-dev git make gcc zlib1g-dev \ @@ -22,18 +22,17 @@ mariadb-client letsencrypt unattended-upgrades echo -e "APT::Periodic::Update-Package-Lists \"1\";\nAPT::Periodic::Unattended-Upgrade \"1\";\n" > /etc/apt/apt.conf.d/20auto-upgrades /etc/init.d/unattended-upgrades restart - -# user +# setup user useradd coyote -m cp .ssh/authorized_keys /home/coyote/.ssh/ chown coyote:coyote /home/coyote/.ssh/authorized_keys su coyote; cd -# can self ssh for deploy +# setup ssh for self deploys ssh-keygen -f ~/.ssh/id_rsa -t rsa -N '' cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys -# for capistrano +# create directory for capistrano deploys cd mkdir data @@ -45,18 +44,13 @@ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-buil echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profile -# for deploys +# create directory for self deploys mkdir code cd code git clone https://github.com/coyote-team/coyote.git - -# ruby and gem install +# install ruby and gems cd coyote -bin/conf_creator.sh .env -bin/conf_creator.sh .env.production -source .env -source .env.production RUBY_VERSION=$(cat .ruby_version) rbenv install -v $RUBY_VERSION rbenv global $RUBY_VERSION @@ -64,9 +58,14 @@ echo "gem: --no-document" > ~/.gemrc gem install bundler bundle install +# create .env files +bin/conf_creator.sh .env +bin/conf_creator.sh .env.production + # back to root exit +# read env vars source /home/coyote/code/coyote/.env source /home/coyote/code/coyote/.env.production @@ -74,7 +73,7 @@ source /home/coyote/code/coyote/.env.production 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 -# ssl +# setup ssl service nginx stop # TODO ask if ready for this step letsencrypt certonly --standalone -d $HOST -t --email $SUPPORT_EMAIL --agree-tos @@ -100,6 +99,7 @@ LOG_CONFIG= << EOF } EOF echo $LOG_CONFIG > /etc/logrotate.conf +echo "Install completed!" # deploy su coyote @@ -113,4 +113,4 @@ 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 "Install completed!" +echo "Deploy and seed completed!" diff --git a/datamodel.png b/datamodel.png index 0483335e..5e5566a9 100644 Binary files a/datamodel.png and b/datamodel.png differ