dockerify
parent
794b5b501b
commit
9993a6b7d9
|
@ -0,0 +1,18 @@
|
|||
FROM ruby:2.7
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y cups-ipp-utils && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# throw errors if Gemfile has been modified since Gemfile.lock
|
||||
RUN bundle config --global frozen 1
|
||||
RUN gem install bundler:1.17.2
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY Gemfile Gemfile.lock ./
|
||||
RUN bundle install
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD bundle exec ruby main.rb
|
|
@ -19,3 +19,4 @@ to test without spejstore running locally, pass:
|
|||
LABELMAKER_DEBUG_JSON='{"short_id":"abcdef","name":"Some long test item","owner":"testowner"}' bundle exec ruby main.rb
|
||||
```
|
||||
|
||||
Make sure to pass either `LABELMAKER_LOCAL_PRINTER_NAME` or `LABELMAKER_IPP_PRINTER_URL`. See top of `main.rb` for all env variables available.
|
||||
|
|
4
main.rb
4
main.rb
|
@ -98,9 +98,9 @@ post '/api/1/print/:id' do
|
|||
temp.close
|
||||
|
||||
if not LOCAL_PRINTER_NAME.empty?
|
||||
system("lpr -P #{LOCAL_PRINTER_NAME.shellescape} #{temp.path.shellescape}")
|
||||
system("lpr -P #{LOCAL_PRINTER_NAME.shellescape} #{temp.path.shellescape}", exception: true)
|
||||
elsif not IPP_PRINTER_URL.empty?
|
||||
system("ipptool -v -tf #{temp.path.shellescape} -d filetype=application/octet-stream -I #{IPP_PRINTER_URL.shellescape} ipptool-print-job.test")
|
||||
system("ipptool -v -tf #{temp.path.shellescape} -d filetype=application/octet-stream -I #{IPP_PRINTER_URL.shellescape} ipptool-print-job.test", exception: true)
|
||||
else
|
||||
status 404
|
||||
return "No printer configured"
|
||||
|
|
Loading…
Reference in New Issue