being containerizing

This commit is contained in:
stryan 2022-08-15 22:52:41 -04:00
parent 4f85d58a77
commit 5c2ab0eed4
2 changed files with 42 additions and 1 deletions

27
Containerfile Normal file
View File

@ -0,0 +1,27 @@
FROM ruby:3.1.2-alpine
RUN apk upgrade --update && \
apk add --no-cache \
bash \
ca-certificates \
curl \
less \
libstdc++ \
libressl-dev \
g++ \
tzdata \
make \
shared-mime-info \
zlib-dev && \
rm -rf /var/cache/apk/*
RUN mkdir /srv/stevetunes
WORKDIR /srv/stevetunes
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY main.rb mpc_shim.rb util.rb ./
ENTRYPOINT ["ruby", "main.rb"]

16
main.rb
View File

@ -7,17 +7,31 @@ require 'shellwords'
require './mpc_shim' require './mpc_shim'
require './util' require './util'
mpc = MpcShim.new
options = {} options = {}
OptionParser.new do |opt| OptionParser.new do |opt|
opt.on("-t", "--token DISCORD_BOT_TOKEN") {|o| options[:bot_token] = o} opt.on("-t", "--token DISCORD_BOT_TOKEN") {|o| options[:bot_token] = o}
opt.on("-c", "--channel CHANNEL_ID") {|o| options[:channel_id] = Integer(o)} opt.on("-c", "--channel CHANNEL_ID") {|o| options[:channel_id] = Integer(o)}
opt.on("-h", "--host MPD_HOST") {|o| options[:host] = o}
end.parse! end.parse!
if ENV.has_key? "DISCORD_BOT_TOKEN"
options[:bot_token] = ENV["DISCORD_BOT_TOKEN"]
end
if ENV.has_key? "CHANNEL_ID"
options[:channel_id] = Integer(ENV["CHANNEL_ID"])
end
if ENV.has_key? "MPD_HOST"
options[:host] = ENV["MPD_HOST"]
end
if options.length == 0 if options.length == 0
puts "Need to specifiy token and channel" puts "Need to specifiy token and channel"
exit exit
end end
mpc = MpcShim.new(options[:host])
puts "creating spool and tracks directories" puts "creating spool and tracks directories"
`mkdir -p spool` `mkdir -p spool`