diff --git a/Dockerfile b/Dockerfile index d740c7d..d36aef4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,14 @@ -FROM ruby:3-alpine -RUN apk add --no-cache make gcc libc-dev -RUN echo -e "#!/bin/sh\ncd /nanoleaf;./main.rb >> /var/log/nanoleaf" > /etc/periodic/15min/nanoleaf -RUN chmod +x /etc/periodic/15min/nanoleaf -RUN adduser -DHu 1001 nanoleaf -RUN touch /var/log/nanoleaf; chown 1001 /var/log/nanoleaf +FROM alpine +RUN apk add --no-cache make gcc libc-dev ruby-dev ruby-bundler && \ + echo -e "#!/bin/sh\ncd /nanoleaf;./main.rb >> /var/log/nanoleaf" > /etc/periodic/15min/nanoleaf && \ + chmod +x /etc/periodic/15min/nanoleaf && \ + adduser -DHu 1001 nanoleaf && \ + touch /var/log/nanoleaf; chown 1001 /var/log/nanoleaf WORKDIR /nanoleaf RUN chown 1001 . USER 1001 COPY --chown=1001 ["main.rb", "Gemfile", "effect.json", "/nanoleaf/"] ENV HOME="/tmp/" ENV GEM_HOME="/nanoleaf/vendor/bundle" -ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH -RUN bundle install +RUN bundle install --jobs=4 CMD ./main.rb >> /var/log/nanoleaf & tail -F /var/log/nanoleaf diff --git a/Gemfile b/Gemfile index 1d932d8..5208ca2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,3 +4,4 @@ source 'https://rubygems.org' gem 'color-converter' gem 'oga' +gem 'json' diff --git a/main.rb b/main.rb index 8db22d0..7d8268f 100755 --- a/main.rb +++ b/main.rb @@ -1,13 +1,13 @@ #! /usr/bin/env ruby # frozen_string_literal: true -require 'json' -require 'uri' -require 'net/http' require 'color_converter' require 'date' -require 'open-uri' +require 'json' +require 'net/http' require 'oga' +require 'open-uri' +require 'uri' def colors case Date.today.strftime('%m%d')