Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
nevalla committed Mar 10, 2016
1 parent ac037e1 commit 6602aba
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ADD Gemfile /app/
ADD Gemfile.lock /app/

RUN apk --update add --virtual build-dependencies build-base ruby-dev openssl-dev libxml2-dev libxslt-dev \
postgresql-dev libc-dev linux-headers nodejs tzdata && \
postgresql-dev libc-dev linux-headers nodejs tzdata && \
gem install bundler && \
cd /app ; bundle config build.nokogiri --use-system-libraries && bundle install --without development test

Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## README
# Rails on Kontena
![](http://rubyonrails.org/images/rails-logo.svg)

#
## Usage

1. Setup Kontena: [Quick Start](http://kontena.io/docs/getting-started/quick-start)

2. Write secrets to Kontena Vault

`$ kontena vault write POSTGRES_PASSWORD <password>`

`$ kontena vault write RAILS_SECRET_KEY_BASE <key_base>`

`$ kontena vault write RAILS_GITHUB_CLIENT_ID <client_id>`

`$ kontena vault write RAILS_GITHUB_CLIENT_SECRET <client_secret>`

`$ kontena vault write RAILS_GITHUB_TOKEN <access_token>`

`$ kontena vault write RAILS_POSTGRE_URL <postgres_url>`

3. Deploy app

`$ kontena app deploy`

## About Kontena

Kontena is a new open source Docker platform including orchestration, service discovery, overlay networking and all the tools required to run your containerized workloads. Kontena is built to maximize developer happiness. It works on any cloud, it's easy to setup and super simple to use. [Give it a try]((http://kontena.io/docs/getting-started/quick-start))! If you like it, please star it on [GitHub](https://github.com/kontena/kontena) and follow us on [Twitter]()!
3 changes: 1 addition & 2 deletions app/assets/javascripts/channels/channel.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
App.cable.subscriptions.create "WebSocketChannel",
received: (data) ->
console.log(data)
received: (data) ->
if data.type == 'stargazers_count'
$("#count").html(data.result)
else if data.type == 'starring'
Expand Down
4 changes: 2 additions & 2 deletions app/services/git_hub_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def stargazers_count
end

def star
@client.star('kontena/kontena-loadbalancer')
@client.star(ENV['GITHUB_REPO'])
end

def starred?
@client.starred?('kontena/kontena-loadbalancer')
@client.starred?(ENV['GITHUB_REPO'])
end

end
5 changes: 2 additions & 3 deletions app/services/git_hub_streamer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ class GitHubStreamer

def self.run
github_service = GitHubService.new(:access_token => ENV['GITHUB_ACCESS_TOKEN'])
stargazers_count = github_service.stargazers_count rescue 0

stargazers_count = github_service.stargazers_count rescue 0
task = Concurrent::TimerTask.new(execution_interval: 10) do
new_count = github_service.stargazers_count rescue 0
new_count = github_service.stargazers_count
if new_count != stargazers_count
ActionCable.server.broadcast "github", {type: 'stargazers_count', result: new_count}
stargazers_count = new_count
Expand Down
12 changes: 5 additions & 7 deletions app/views/welcome/index.html.erb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Action Cable uses Redis by default to administer connections, channels, and sending/receiving messages over the WebSocket.
production:
adapter: redis
url: ENV['REDIS_URI']
url: <%= ENV['CABLE_REDIS_URL'] %>

development:
adapter: async
Expand Down
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
# Action Cable endpoint configuration
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
Rails.application.config.action_cable.disable_request_forgery_protection = true

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
Expand Down
15 changes: 10 additions & 5 deletions kontena.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ db:
image: postgres:latest
stateful: true
secrets:
- secret: POSTGRES_PASSWORD
name: POSTGRES_PASSWORD
- secret: POSTGRE_PASSWORD
name: POSTGRE_PASSWORD
type: env
app:
image: registry.kontena.local/docker_rails5:latest
build: .
secrets:
- secret: RAILS_POSTGRE_URL
- secret: RAILS_POSTGRES_URL
name: DATABASE_URL
type: env
- secret: RAILS_SECRET_KEY_BASE
Expand All @@ -32,12 +32,14 @@ app:
name: GITHUB_CLIENT_SECRET
type: env
- secret: RAILS_GITHUB_TOKEN
name: GITHUB_TOKEN
name: GITHUB_ACCESS_TOKEN
type: env
environment:
- KONTENA_LB_INTERNAL_PORT=8080
- KONTENA_LB_VIRTUAL_HOSTS=rails-on-docker.kontena.io
- GITHUB_REPO=kontena/kontena
- CABLE_REDIS_URL=redis://%{project}-redis:6379/1
- REDIS_URL=redis://%{project}-redis:6379/2
hooks:
post_start:
- name: db_setup
Expand All @@ -53,12 +55,15 @@ app:
sidekiq:
image: registry.kontena.local/docker_rails5:latest
secrets:
- secret: RAILS_POSTGRE_URL
- secret: RAILS_POSTGRES_URL
name: DATABASE_URL
type: env
- secret: RAILS_SECRET_KEY_BASE
name: SECRET_KEY_BASE
type: env
environment:
- REDIS_URL=redis://%{project}-redis:6379/2
- GITHUB_REPO=kontena/kontena
volumes_from:
- %{project}-app-%%s
command: bundle exec sidekiq

0 comments on commit 6602aba

Please sign in to comment.