dockerify

master
radex 2024-01-30 20:20:21 +01:00
parent 794b5b501b
commit 9993a6b7d9
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
3 changed files with 21 additions and 2 deletions

18
Dockerfile Normal file
View File

@ -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

View File

@ -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.

View File

@ -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"