Skip to content

Commit

Permalink
Add working Dockerised nerve, yay
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie0 committed Jul 13, 2018
1 parent 1f603f2 commit 55a2c16
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source 'https://rubygems.org'

gem 'rspec'
gem 'oauth2'
gem 'dig_rb'
gem 'sinatra', require: 'sinatra/base'
gem 'sinatra-reloader'
gem 'sinatra-xsendfile'
Expand All @@ -14,7 +15,7 @@ gem 'rack-test'
gem 'resque'
gem 'resque-status'
gem 'thin'
gem 'mysql2'
gem 'mysql2', '0.4.10'
gem 'unidecode'
gem 'rack-proxy'
gem 'rack-rewrite'
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ You'll also need to mount your playout drives on the "master" node
This project is a part of the [Insanity Tech Masterplan](https://wiki.insanityradio.com/wiki/Technical_Masterplan).


## Docker Volumes

To mount your AudioWall in Docker, run the following command on the host.

sudo docker volume create --driver local --opt type=cifs --opt device=//10.32.0.222/AudioWall --opt o=username=Nerve,password=password,_netdev,uid=999,gid=999 audiowall

You'll also want to load the database schema, as this isn't done automatically. (Do this after building)

docker-compose run --rm worker sh -c "bundle exec rake db:schema:load db:migrate"

To run database migrations, after building but before launching, run:

docker-compose run --rm worker sh -c "bundle exec rake db:migrate"


## Quick Tasks / To-do

- Create recall button on interface that invokes Nerve::Job::Recall
Expand Down
6 changes: 4 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
require_relative 'modules'

Bundler.require
$config = YAML::load(File.read(File.join(File.dirname(__FILE__), "config.yml")))
$genres = YAML::load(File.read(File.join(File.dirname(__FILE__), "genres.yml")))

$config = YAML::load(ERB.new(File.read(File.join(File.dirname(__FILE__), "config.yml"))).result(binding))
$genres = YAML::load(ERB.new(File.read(File.join(File.dirname(__FILE__), "genres.yml"))).result(binding))

$env = {:slave => false}

require_relative 'database'
Expand Down
9 changes: 6 additions & 3 deletions app/models/track.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,19 @@ def why_unsafe
end

def delete! soft = false

_local_path = $config["export"]["directory"] + "/" + local_path
File.unlink(_local_path) rescue nil
File.unlink(_local_path) rescue puts "Failed to delete #{id}: #{$!}"

if soft
self.status = 6
self.save
else
File.unlink(_local_path + ".ogg") rescue nil
File.unlink(_local_path + ".dat") rescue nil
File.unlink(_local_path + ".ogg") rescue puts "Failed to delete #{id} preview: #{$!}"
File.unlink(_local_path + ".dat") rescue puts "Failed to delete #{id} form: #{$!}"
destroy
end

end

def get_json extended = false
Expand Down
5 changes: 3 additions & 2 deletions database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
require 'sinatra'
require 'sinatra/activerecord'

set :database, $config['database']['development']
set :database, $config['database'][ENV['RACK_ENV'] || 'development']
Resque.redis = $config['database']['redis']

module Nerve
module Database
Expand All @@ -16,4 +17,4 @@ def self.last_id
end

end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20180713103629_add_times.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddTimes < ActiveRecord::Migration
def change

execute 'ALTER TABLE albums ALTER COLUMN creation_date SET DEFAULT NOW()'
execute 'ALTER TABLE artists ALTER COLUMN creation_date SET DEFAULT NOW()'
execute 'ALTER TABLE nerve_cache ALTER COLUMN creation_date SET DEFAULT NOW()'
execute 'ALTER TABLE tracks ALTER COLUMN creation_date SET DEFAULT NOW()'

end
end
58 changes: 56 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ services:
- MYSQL_DATABASE=nerve
volumes:
- ./config:/config
redis:
image: redis

http:
restart: always
build:
Expand All @@ -19,12 +22,63 @@ services:
- https_proxy
- RESOLVER=8.8.8.8
ports:
- "6100:80"
- "9292:80"
links:
- redis
- mariadb
secrets:
- source: "nerve_root_pw"
target: "nerve_root_pw"
uid: "9999"
gid: "9999"
mode: 0400
environment:
- http_proxy
- https_proxy
volumes:
- tmp:/tmp
- music:/music
- ./config:/config
worker:
restart: always
build:
context: .
dockerfile: docker/Dockerfile.worker
args:
- http_proxy
- https_proxy
- RESOLVER=8.8.8.8
links:
- redis
- mariadb
secrets:
- source: "nerve_root_pw"
target: "nerve_root_pw"
uid: "9999"
gid: "9999"
mode: 0400
environment:
- http_proxy
- https_proxy
volumes:
- tmp:/tmp
- music:/music
- audiowall:/audiowall
- ./config:/config
volume_own:
restart: "no"
image: alpine
command: "chown -R 999:999 /music"
volumes:
- music:/music
- audiowall:/audiowall
secrets:
nerve_root_pw:
file: ./root.txt
file: ./config/root.txt

volumes:
music:
tmp:
audiowall:
external:
name: audiowall
1 change: 1 addition & 0 deletions docker/Dockerfile.http
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN ln -s /config/config.yml ./config.yml

COPY ./ ./
RUN rm config/root.txt
RUN chown -R app: .

CMD ["/sbin/my_init"]

Loading

0 comments on commit 55a2c16

Please sign in to comment.