brand new docker container and updated readme

This commit is contained in:
Mark Moser 2016-08-12 00:24:15 -05:00
parent ccd287491d
commit fc3b27f0b9
9 changed files with 101 additions and 115 deletions

2
.gitignore vendored
View File

@ -12,6 +12,7 @@
/tmp/* /tmp/*
!/log/.keep !/log/.keep
!/tmp/.keep !/tmp/.keep
tmux*log
### Ruby ### ### Ruby ###
*.gem *.gem
@ -60,3 +61,4 @@ application.yml
# Ignore application configuration # Ignore application configuration
/config/application.yml /config/application.yml
.container-setup

View File

@ -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

View File

@ -1,43 +0,0 @@
FROM mysql:5.7
MAINTAINER Mark Moser <markamoser@gmail.com>
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

View File

@ -2,34 +2,58 @@
This application manages quizzes intended to be used as pre-interview skill assessments. 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 ### Setup
* you can dev native, or in docker * clone
* use guard * checkout develop
* honor RuboCop * bundle
* keep tests green * npm install
* pull --rebase !always `git config --global pull.rebase true` * bower install
* cd vendor/assets/ && bitters install && cd ../.. * 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 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.
- 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
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
---- ## TODOs and notes
# Question creation
* attachments: http://dev.perficientxd.com/skill_assets/
* Question attachment path: http://dev.perficientxd.com/skill_assets/
* clean code / [Confident Ruby](http://www.confidentruby.com/)

View File

@ -1,18 +1,11 @@
{ {
"name": "skill-assessment-app", "name": "rails-dev",
"authors": [ "authors": [""],
"Harish Bhavanichikar",
"Jennifer Siegfried",
"Derek Montgomery",
"Mark Moser"
],
"private": true, "private": true,
"dependencies": { "dependencies": {
"jquery": "1.9.1", "jquery": "1.9.1",
"handlebars": "3.0.2",
"jquery-validate": "", "jquery-validate": "",
"tota11y": "", "tota11y": "",
"jquery-mockjax": "^2.1.1",
"modernizr-lite": "*" "modernizr-lite": "*"
}, },
"ignore": [ "ignore": [

View File

@ -1,7 +1,7 @@
{ {
"name": "skill-assessment-app", "name": "rails-dev",
"version": "1.0.0", "version": "1.0.0",
"description": "This application manages quizzes intended to be used as pre-interview skill assessments.", "description": "rails-dev assets",
"dependencies": { "dependencies": {
"bower": "^1.7.9", "bower": "^1.7.9",
"eslint": "^3.2.2" "eslint": "^3.2.2"
@ -9,7 +9,7 @@
"devDependencies": {}, "devDependencies": {},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git@gitlab.perficientxd.com:pdr/skill-assessment-app.git" "url": ""
}, },
"license": "ISC" "license": "ISC"
} }

View File

@ -1,20 +1,29 @@
#!/bin/bash #!/bin/bash
if [ -d '/usr/app' ]; then if [ -d '/usr/app' ]; then
cd /usr/app if [ ! -f 'config/application.yml' ]; then
bundle echo ''
npm install echo -e "\E[1;31m###################################"
bower install echo "Missing application.yml"
cd vendor/assets/ && bitters install && cd /usr/app echo -e "\E[1;32m cp config/application.yml.sample config/application.yml"
tput sgr0
service mysql start echo "edit and update proper values"
rails db:setup echo ''
rails db:migrate else
rails db:fixtures:load if [ ! -f '~/.container-setup' ]; then
bundle
tmux new-session -d -s 'rails-dev' 'rails s -b 0.0.0.0' npm install
tmux split-window -p 85 -v 'bundle exec guard' bower install --allow-root
tmux split-window -p 20 -v cd vendor/assets/ && bitters install && cd /usr/app
tmux attach -t rails-dev 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 else
echo "Are you in docker container?" echo "Are you in docker container?"
fi fi

View File

@ -1,16 +1,12 @@
#!/bin/bash #!/bin/bash
IMAGE=markamoser/deb-mysql-rails IMAGE=markamoser/rails-dev-mysql:latest
CONTAINER=`basename ${PWD}` 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) STATUS=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null)
if [ $? -eq 1 ]; then 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 exit
fi fi

View File

@ -1,17 +1,27 @@
#!/bin/bash #!/bin/bash
if [ -d '/usr/app' ]; then if [ -d '/usr/app' ]; then
cd /usr/app if [ ! -f 'config/application.yml' ]; then
bundle echo ''
npm install echo -e "\E[1;31m###################################"
bower install echo "Missing application.yml"
cd vendor/assets/ && bitters install && cd /usr/app echo -e "\E[1;32m cp config/application.yml.sample config/application.yml"
tput sgr0
service mysql start echo "edit and update proper values"
rails db:setup echo ''
rails db:migrate else
rails db:fixtures:load if [ ! -f '~/.container-setup' ]; then
bundle
rails s -b 0.0.0.0 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 else
echo "Are you in docker container?" echo "Are you in docker container?"
fi fi