From 5c2ab0eed4ad25a6dc0441477b275748cdac9070 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 15 Aug 2022 22:52:41 -0400 Subject: [PATCH] being containerizing --- Containerfile | 27 +++++++++++++++++++++++++++ main.rb | 16 +++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Containerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..252e371 --- /dev/null +++ b/Containerfile @@ -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"] diff --git a/main.rb b/main.rb index 31ac187..548a508 100644 --- a/main.rb +++ b/main.rb @@ -7,17 +7,31 @@ require 'shellwords' require './mpc_shim' require './util' -mpc = MpcShim.new + options = {} OptionParser.new do |opt| 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("-h", "--host MPD_HOST") {|o| options[:host] = o} 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 puts "Need to specifiy token and channel" exit end +mpc = MpcShim.new(options[:host]) puts "creating spool and tracks directories" `mkdir -p spool`