Skip to content

Commit

Permalink
Speed up Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlgo11 committed Dec 2, 2021
1 parent 0163335 commit 1447818
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ source 'https://rubygems.org'

gem 'color-converter'
gem 'oga'
gem 'json'
8 changes: 4 additions & 4 deletions main.rb
Original file line number Diff line number Diff line change
@@ -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')
Expand Down

0 comments on commit 1447818

Please sign in to comment.