Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Scumblr docker configuration #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
FROM ubuntu:14.04

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update &&\
apt-get -y install \
wget &&\
wget --quiet -O - https://deb.nodesource.com/setup_4.x | /bin/bash &&\
apt-get update &&\
apt-get -y install \
build-essential \
git-core \
imagemagick \
imagemagick-common \
libcurl4-openssl-dev \
libffi-dev \
libmagickcore-dev \
libmagickwand-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
libyaml-dev \
nodejs \
postgresql-client \
python-dev \
python-pip \
python-software-properties \
rlwrap \
sqlite3 \
supervisor \
zlib1g-dev &&\
pip install bandit

RUN apt-get clean &&\
rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/*

ADD docker-entrypoint.sh /docker-entrypoint.sh
ADD docker-entrypoint-init.d /docker-entrypoint-init.d

RUN useradd -c 'scumblr' -m -d /home/scumblr -s /bin/bash scumblr
USER scumblr
ENV RBENV_ROOT /home/scumblr/usr/local/rbenv
ENV PATH $RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV BUNDLE_GEMFILE /home/scumblr/Scumblr/Gemfile

RUN git clone https://github.com/sstephenson/rbenv.git /home/scumblr/usr/local/rbenv &&\
git clone https://github.com/sstephenson/ruby-build.git /home/scumblr/usr/local/rbenv/plugins/ruby-build &&\
rbenv install 2.3.1 &&\
rbenv global 2.3.1 &&\
gem install bundler --no-ri --no-rdoc &&\
gem install sidekiq --no-ri --no-rdoc &&\
gem install rails -v 4.2.6 --no-ri --no-rdoc &&\
rbenv rehash

RUN git clone https://github.com/Netflix/Scumblr.git /home/scumblr/Scumblr &&\
bundle install --gemfile=/home/scumblr/Scumblr/Gemfile --no-cache

RUN sed -i '0,/localhost/{s/localhost/postgres/}' /home/scumblr/Scumblr/config/database.yml
RUN cp /home/scumblr/Scumblr/config/initializers/scumblr.rb.sample /home/scumblr/Scumblr/config/initializers/scumblr.rb
ADD supervisord.conf /home/scumblr/supervisord.conf

WORKDIR /home/scumblr/Scumblr
EXPOSE 3000
ENTRYPOINT ["/docker-entrypoint.sh"]
15 changes: 15 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Docker environment for Scumblr 2.0

This is a docker configuration for Scumblr 2.0 suitable for non-production use

## Quick start

1. Add API keys and configure the admin user account name and password in `scumblr-vars.env`
2. Run `docker-compose up` from the directory of `Dockerfile`
3. After rails and sidekiq are started on the scumblr container visit `http://localhost:3000`

## Advanced

The default docker compose configuration passes the `init` argument to the Scumblr container's entrypoint. This will cause the scumblr container to attempt initializion of the scumblr database on the postgres container. If the postgres container's volumes are to be persisted consider removing this argument after a successful initialization.

Bash or ruby scripts added to the `/docker-init.d` folder will be run at the start of the scumblr container when `init` is passed to the entrypoint. If they are dependent on each other ensure they execute in the correct order.
26 changes: 26 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "2"
services:
scumblr:
build: .
ports:
- "3000:3000"
depends_on:
- "postgres"
- "redis"
links:
- "postgres"
- "redis"
environment:
- REDIS_URL=redis://redis:6379
env_file:
- scumblr-vars.env
entrypoint:
- /docker-entrypoint.sh
- init
postgres:
image: postgres:9.5
environment:
- POSTGRES_USER=scumblr
- POSTGRES_PASSWORD=scumblr
redis:
image: redis:latest
6 changes: 6 additions & 0 deletions docker/docker-entrypoint-init.d/configure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
user = User.new
user.email = ENV["admin_user_name"]
user.password = ENV["admin_user_pass"]
user.password_confirmation = ENV["admin_user_pass"]
user.admin = true
user.save
19 changes: 19 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

if [ $1 == "init" ]; then

rake db:create
rake db:structure:load

for f in /docker-entrypoint-init.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.rb) echo "$0: running $f"; rails r "$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done

fi

exec /usr/bin/supervisord -c /home/scumblr/supervisord.conf
41 changes: 41 additions & 0 deletions docker/scumblr-vars.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
db_user_name=scumblr
db_user_pass=scumblr
admin_user_name=
admin_user_pass=

# Sketchy
#sketchy_url=
#sketchy_use_ssl=
#sketchy_verify_ssl=
#sketchy_tag_status_code=
#sketchy_access_token=

# Google
#google_application_name=
#google_application_version=
#google_developer_key=
#google_cx=

# YouTube
#youtube_application_name=
#youtube_application_version=
#youtube_developer_key=

# eBay
#ebay_access_key=

# Facebook
#facebook_app_id=
#facebook_app_secret=

# Twitter
#twitter_consumer_key=
#twitter_consumer_secret=
#twitter_access_token=
#twitter_access_token_secret=

# Github
#github_oauth_token=

#OpenGrok
#opengrok_url=
13 changes: 13 additions & 0 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[supervisord]
user=scumblr
loglevel=info
logfile=/home/scumblr/supervisor.log
nodaemon=true

[program:sidekiq]
user=scumblr
command=/bin/bash -c "/home/scumblr/usr/local/rbenv/shims/bundle exec sidekiq -l /home/scumblr/sidekiq.log"

[program:rails]
user=scumblr
command=/bin/bash -c "/home/scumblr/usr/local/rbenv/shims/bundle exec rails s -b 0.0.0.0"