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

improvements for docker build #5

Merged
merged 5 commits into from
Jul 11, 2016
Merged
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
22 changes: 13 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
FROM ubuntu:14.04
# direct debian works too but is bigger by 40MiB
#FROM debian:jessie
FROM philcryer/min-jessie

# Prevent docker's default encoding of ASCII.
# # https://oncletom.io/2015/docker-encoding/
ENV LANG C.UTF-8
ENV LANGUAGE en_US:C
ENV LC_ALL C.UTF-8

# PPA for Ruby 2.1
RUN apt-get update
RUN apt-get install -y python3-software-properties software-properties-common
RUN add-apt-repository ppa:chris-lea/redis-server
RUN apt-add-repository ppa:brightbox/ruby-ng
RUN apt-get update
RUN apt-get install -y ruby2.1 redis-tools git
RUN echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list && \
apt-get update && \
apt-get install -y ruby2.1 git curl && \
apt-get install -t jessie-backports -y redis-tools && \
rm -rf /var/lib/apt/lists/*

RUN gem install bundler
RUN gem2.1 install bundler

ADD . /qless
WORKDIR /qless

RUN bundle install

# make jquery local, can be removed once https://github.com/seomoz/qless/issues/244 is resolved
RUN curl -o "$(find /var/lib/gems/ -wholename */lib/qless/server/static/js -type d)/jquery.min.js" https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js && \
patch -d "$(find /var/lib/gems/ -wholename */lib/qless/server -type d)" -p4 < /qless/local_js.patch
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ application.
When you want to run the container, you'll need to pass two environment
variables to `docker run ...` to successfully start the container:

1. `REDIS_HOST`: The host which is running the redis instance you want
to connect to. E.g. `www.example.com`
2. `REDIS_PORT`: The port on the host which is running redis. E.g.
`6379`.
3. `HTTP_PATH`: The path that the web app will be listening on. E.g.
1. `REDIS_URL`: e.g. `redis://some-host:7000/3`
or alternative those 3:
1. `REDIS_HOST`: The host which is running the redis instance you want
to connect to. E.g. `www.example.com`
1. `REDIS_PORT`: The port on the host which is running redis. E.g.
`6379`.
1. `DB_NUM`: The redis DB number that the app will connect to. Defaults
to 0.
1. `HTTP_PATH`: Optional, the path that the web app will be listening on. default
`/qless`
4. `DB_NUM`: The redis DB number that the app will connect to. Defaults
to 0.

You will then run `bundle exec rackup qless.ru -o0.0.0.0 -p 9001` on the
docker container to run a the qless web app and expose it on port 9001.
Expand All @@ -37,6 +39,8 @@ An example way of running the docker container is to run:

```bash
docker run -d --net="host" -e "REDIS_HOST=localhost" -e "REDIS_PORT=6379" -e "HTTP_PATH=\/qless" <docker_image> bundle exec rackup qless.ru -o0.0.0.0 -p 9001
# or
docker run -e REDIS_URL="redis://127.0.0.1:6379/0" <docker_image> bundle exec rackup qless.ru -o0.0.0.0 -p 5678
```

To run the docker container connecting to a specific redis database use:
Expand Down
13 changes: 13 additions & 0 deletions local_js.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/qless/server/views/layout.erb b/lib/qless/server/views/layout.erb
Copy link
Contributor

@weiser weiser May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this change should happen in seomoz/qless, not here. Qless, here, can be bumped once seomoz/qless has updated.

index cb41fb6..9ac8747 100644
--- a/lib/qless/server/views/layout.erb
+++ b/lib/qless/server/views/layout.erb
@@ -12,7 +12,7 @@
<link href="<%= u '/css/docs.css' %>" rel="stylesheet">
<link href="<%= u '/css/jquery.noty.css' %>" rel="stylesheet">
<link href="<%= u '/css/noty_theme_twitter.css' %>" rel="stylesheet">
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
+ <script src="<%= u '/js/jquery.min.js' %>" type="text/javascript"></script>

<style type="text/css">
body {
12 changes: 10 additions & 2 deletions qless.ru
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
require 'qless'
require 'qless/server'

client = Qless::Client.new(:host => ENV['REDIS_HOST'], :port => ENV['REDIS_PORT'].to_i, :db => ENV['DB_NUM'].to_i )
# use REDIS_URL="redis://some-host:7000/3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the README.md to specify it is using REDIS_URL instead of these other variables.


if ENV['REDIS_URL']
client = Qless::Client.new
else
client = Qless::Client.new(:host => ENV['REDIS_HOST'], :port => ENV['REDIS_PORT'].to_i, :db => ENV['DB_NUM'].to_i )
end

QlessServer = Rack::Builder.app do
if ENV['QLESS_BASIC_AUTH_USER'] && ENV['QLESS_BASIC_AUTH_PASSWORD']
Expand All @@ -10,7 +16,9 @@ QlessServer = Rack::Builder.app do
end
end

map(ENV['HTTP_PATH']) { run Qless::Server.new(client) }
gui_path = ENV.fetch('HTTP_PATH', '/qless')

map(gui_path) { run Qless::Server.new(client) }
end

run QlessServer