From fc3b27f0b9bb3e2aabe9ad9c19d5fd3a84320ae5 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Fri, 12 Aug 2016 00:24:15 -0500 Subject: [PATCH] brand new docker container and updated readme --- .gitignore | 2 ++ .tmux.conf | 5 ---- Dockerfile | 43 ------------------------------- README.md | 68 +++++++++++++++++++++++++++++++++---------------- bower.json | 11 ++------ package.json | 6 ++--- start-dev.sh | 39 +++++++++++++++++----------- start-docker.sh | 8 ++---- start-server.sh | 34 ++++++++++++++++--------- 9 files changed, 101 insertions(+), 115 deletions(-) delete mode 100644 .tmux.conf delete mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index f0faec8..eca05bb 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /tmp/* !/log/.keep !/tmp/.keep +tmux*log ### Ruby ### *.gem @@ -60,3 +61,4 @@ application.yml # Ignore application configuration /config/application.yml +.container-setup diff --git a/.tmux.conf b/.tmux.conf deleted file mode 100644 index 2b3df9b..0000000 --- a/.tmux.conf +++ /dev/null @@ -1,5 +0,0 @@ -set -g mode-mouse on -set -g mouse-resize-pane on -set -g mouse-select-pane on -set -g mouse-select-window on -set -g history-limit 30000 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e744705..0000000 --- a/Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -FROM mysql:5.7 -MAINTAINER Mark Moser - -WORKDIR ~/ - -ENV MYSQL_ROOT_PASSWORD=root -ENV BUILD_PACKAGES="build-essential libmysqlclient-dev openssl graphviz nodejs curl wget zlib1g-dev tmux" - -RUN apt-get update \ - && apt-get install --fix-missing -y $BUILD_PACKAGES \ - && /usr/sbin/mysqld --initialize --user=mysql \ - && service mysql start \ - && echo 'gem: --no-document' >> ~/.gemrc \ - && cp ~/.gemrc /etc/gemrc \ - && chmod uog+r /etc/gemrc \ - && mkdir -p /usr/app \ - && ln -s /usr/bin/nodejs /usr/bin/node \ - && echo "alias ll='ls -Ahl'" >> /root/.bashrc \ - && echo "alias la='ls -ahl'" >> /root/.bashrc \ - && echo "export HISTCONTROL=ignoredups" >> /root/.bashrc - -# RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - -# RUN apt-get update\ -# && apt-get install --yes nodejs - -# install current Ruby -RUN curl -L --progress https://github.com/postmodern/ruby-install/archive/v0.6.0.tar.gz | tar xz \ - && cd ruby-install-0.6.0 \ - && make install \ - && cd ../ \ - && ruby-install --system ruby \ - && gem install bundler - -COPY .tmux.conf /root/ -COPY Gemfile* /root/ -RUN cd /root \ - && bundle install \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -EXPOSE 3000 3306 35729 -WORKDIR /usr/app -CMD /bin/bash diff --git a/README.md b/README.md index 41f6171..1b2b020 100644 --- a/README.md +++ b/README.md @@ -2,34 +2,58 @@ This application manages quizzes intended to be used as pre-interview skill assessments. +## Development +* Please use Guard when you are developing + * `bundle exec guard` +* Honor RuboCop warnings +* Keep tests green +* Write tests around new development +* Always pull with rebase! + * `git config --global pull.rebase true` +* Make sure to include any new development data needs in the fixture files + * test/fixtures/... +* feature branches are nice, but never merge develop down to them. Instead rebase feature branches onto develop. -# dev -* you can dev native, or in docker -* use guard - * honor RuboCop - * keep tests green -* pull --rebase !always `git config --global pull.rebase true` +### Setup +* clone +* checkout develop +* bundle +* npm install +* bower install * cd vendor/assets/ && bitters install && cd ../.. -* place all required dev seed data in fixtures for rails db:fixtures:load +* cp config/application.yml.sample config/application.yml +* edit and update proper values to application.yml +* rake db:setup +* rake db:migrate +* rake db:fixtures:load -# Docker +## Docker -* ./start-docker.sh - - will build source image, it not exist - - created contaier and starts -* ./start-dev.sh - - after connected to container, run this to spin up a dev session - - edit files from host in favorite editor -* ./start-server.sh - - starts up simple server for viewing/demo sans guard +You can develop in this app with a native rails install, if you prefer. However, there is also a docker image setup if you do not want to install all the supporting gems and libraries. -visit http://localhost:3000 +To use the docker container, you need to install and launch docker, which can be found here: +https://www.docker.com/products/docker + +Once the container is started, you can still edit files from your host project directory. + +visit http://localhost:3000 like normal + +There are some convenience scripts included to make starting the container and rails app easier. + +#### `./start-docker.sh` +* Execute from terminal, on the host machine, in the project directory +- This will pull the image from dockerhub, if needed +- Create and start up container + +#### Once in the container: +* `./start-dev.sh` + * will spin up a dev session with tmux +* `./start-server.sh` + - starts up just rails server for viewing application ----- - -# Question creation - -* attachments: http://dev.perficientxd.com/skill_assets/ +## TODOs and notes +* Question attachment path: http://dev.perficientxd.com/skill_assets/ +* clean code / [Confident Ruby](http://www.confidentruby.com/) diff --git a/bower.json b/bower.json index f607884..11bb5f4 100644 --- a/bower.json +++ b/bower.json @@ -1,18 +1,11 @@ { - "name": "skill-assessment-app", - "authors": [ - "Harish Bhavanichikar", - "Jennifer Siegfried", - "Derek Montgomery", - "Mark Moser" - ], + "name": "rails-dev", + "authors": [""], "private": true, "dependencies": { "jquery": "1.9.1", - "handlebars": "3.0.2", "jquery-validate": "", "tota11y": "", - "jquery-mockjax": "^2.1.1", "modernizr-lite": "*" }, "ignore": [ diff --git a/package.json b/package.json index a5660a3..7ce7fab 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "skill-assessment-app", + "name": "rails-dev", "version": "1.0.0", - "description": "This application manages quizzes intended to be used as pre-interview skill assessments.", + "description": "rails-dev assets", "dependencies": { "bower": "^1.7.9", "eslint": "^3.2.2" @@ -9,7 +9,7 @@ "devDependencies": {}, "repository": { "type": "git", - "url": "git@gitlab.perficientxd.com:pdr/skill-assessment-app.git" + "url": "" }, "license": "ISC" } diff --git a/start-dev.sh b/start-dev.sh index beeef7c..853a113 100755 --- a/start-dev.sh +++ b/start-dev.sh @@ -1,20 +1,29 @@ #!/bin/bash if [ -d '/usr/app' ]; then - cd /usr/app - bundle - npm install - bower install - cd vendor/assets/ && bitters install && cd /usr/app - - service mysql start - rails db:setup - rails db:migrate - rails db:fixtures:load - - tmux new-session -d -s 'rails-dev' 'rails s -b 0.0.0.0' - tmux split-window -p 85 -v 'bundle exec guard' - tmux split-window -p 20 -v - tmux attach -t rails-dev + if [ ! -f 'config/application.yml' ]; then + echo '' + echo -e "\E[1;31m###################################" + echo "Missing application.yml" + echo -e "\E[1;32m cp config/application.yml.sample config/application.yml" + tput sgr0 + echo "edit and update proper values" + echo '' + else + if [ ! -f '~/.container-setup' ]; then + bundle + npm install + bower install --allow-root + cd vendor/assets/ && bitters install && cd /usr/app + rails db:setup + rails db:migrate + rails db:fixtures:load + touch ~/.container-setup + fi + tmux new-session -d -s 'rails-dev' 'rails s -b 0.0.0.0' + tmux split-window -p 15 -v + tmux split-window -p 85 -v 'bundle exec guard' + tmux attach -t rails-dev + fi else echo "Are you in docker container?" fi diff --git a/start-docker.sh b/start-docker.sh index eddb7e4..2c07db6 100755 --- a/start-docker.sh +++ b/start-docker.sh @@ -1,16 +1,12 @@ #!/bin/bash -IMAGE=markamoser/deb-mysql-rails +IMAGE=markamoser/rails-dev-mysql:latest CONTAINER=`basename ${PWD}` -# if [ "$(docker images -q $IMAGE:latest 2> /dev/null)" == "" ]; then -# docker build -t $IMAGE . -# fi - STATUS=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null) if [ $? -eq 1 ]; then - docker run --name $CONTAINER -it -p 3000:3000 -p 35729:35729 -p 3306:3306 -v ${PWD}:/usr/app $IMAGE /bin/bash + docker run --name $CONTAINER -it -p 3000:3000 -p 35729:35729 -v ${PWD}:/usr/app $IMAGE /bin/bash -c "service mysql start; /bin/bash" exit fi diff --git a/start-server.sh b/start-server.sh index aa2a135..72b1b1d 100755 --- a/start-server.sh +++ b/start-server.sh @@ -1,17 +1,27 @@ #!/bin/bash if [ -d '/usr/app' ]; then - cd /usr/app - bundle - npm install - bower install - cd vendor/assets/ && bitters install && cd /usr/app - - service mysql start - rails db:setup - rails db:migrate - rails db:fixtures:load - - rails s -b 0.0.0.0 + if [ ! -f 'config/application.yml' ]; then + echo '' + echo -e "\E[1;31m###################################" + echo "Missing application.yml" + echo -e "\E[1;32m cp config/application.yml.sample config/application.yml" + tput sgr0 + echo "edit and update proper values" + echo '' + else + if [ ! -f '~/.container-setup' ]; then + bundle + npm install + bower install --allow-root + cd vendor/assets/ && bitters install && cd /usr/app + rails db:setup + rails db:migrate + rails db:fixtures:load + touch ~/.container-setup + fi + echo 'Delete ~/.container-setup and re-run startup script to update app.' + rails s -b 0.0.0.0 + fi else echo "Are you in docker container?" fi