Forceu / barcodebuddy-docker

Docker image for BarcodeBuddy
MIT License
28 stars 16 forks source link

Problem mapping barcode scanner into docker container #22

Closed mikedolx closed 1 year ago

mikedolx commented 1 year ago

Hi,

i just setup barcodebuddy on my raspberry pi 4 using docker. Here is my docker-compose.yml

ersion: '3.5'

services:
  barcode-buddy:
    image: f0rc3/barcodebuddy-docker:arm32v7-latest
    restart: unless-stopped
    volumes:
      - bbconfig:/config
    devices:
      - /dev/input/event0:/dev/input/event0
    ports:
      - 50000:80
    environment:
      - ATTACH_BARCODESCANNER=true
      - BBUDDY_EXTERNAL_GROCY_URL=http://grocy.mydomain.local

volumes:
  bbconfig:

when i run the container with docker-compose i see the following log:

barcode-buddy_1  | [cont-init.d] 10-adduser: executing... 
barcode-buddy_1  | usermod: no changes
barcode-buddy_1  | 
barcode-buddy_1  | ----------------------------------------------------------------------------
barcode-buddy_1  | 
barcode-buddy_1  |  ______                            _       ______            _     _       
barcode-buddy_1  | (____  \                          | |     (____  \          | |   | |      
barcode-buddy_1  |  ____)  ) ____  ____ ____ ___   _ | | ____ ____)  )_   _  _ | | _ | |_   _ 
barcode-buddy_1  | |  __  ( / _  |/ ___) ___) _ \ / || |/ _  )  __  (| | | |/ || |/ || | | | |
barcode-buddy_1  | | |__)  | ( | | |  ( (__| |_| ( (_| ( (/ /| |__)  ) |_| ( (_| ( (_| | |_| |
barcode-buddy_1  | |______/ \_||_|_|   \____)___/ \____|\____)______/ \____|\____|\____|\__  |
barcode-buddy_1  |                                                                     (____/ 
barcode-buddy_1  | 
barcode-buddy_1  |                    Thank you for using our Docker image! 
barcode-buddy_1  | 
barcode-buddy_1  |                   https://github.com/Forceu/barcodebuddy
barcode-buddy_1  |                https://github.com/Forceu/barcodebuddy-docker
barcode-buddy_1  | ---------------------------------------------------------------------------
barcode-buddy_1  | 
barcode-buddy_1  | [cont-init.d] 10-adduser: exited 0.
barcode-buddy_1  | [cont-init.d] 10-migration: executing... 
barcode-buddy_1  | [cont-init.d] 10-migration: exited 0.
barcode-buddy_1  | [cont-init.d] 20-config: executing... 
barcode-buddy_1  | [cont-init.d] 20-config: exited 0.
barcode-buddy_1  | [cont-init.d] 30-keygen: executing... 
barcode-buddy_1  | using keys found in /config/keys
barcode-buddy_1  | [cont-init.d] 30-keygen: exited 0.
barcode-buddy_1  | [cont-init.d] 50-config: executing... 
barcode-buddy_1  | [cont-init.d] 50-config: exited 0.
barcode-buddy_1  | [cont-init.d] 60-savearguments: executing... 
barcode-buddy_1  | [EnvParser] Parsing environment variables
barcode-buddy_1  | [EnvParser] ATTACH_BARCODESCANNER set, enabling input grabber
barcode-buddy_1  | [cont-init.d] 60-savearguments: exited 0.
barcode-buddy_1  | [cont-init.d] 90-custom-folders: executing... 
barcode-buddy_1  | [cont-init.d] 90-custom-folders: exited 0.
barcode-buddy_1  | [cont-init.d] 99-custom-files: executing... 
barcode-buddy_1  | [custom-init] no custom files found exiting...
barcode-buddy_1  | [cont-init.d] 99-custom-files: exited 0.
barcode-buddy_1  | [cont-init.d] done.
barcode-buddy_1  | [services.d] starting services
barcode-buddy_1  | [services.d] done.
barcode-buddy_1  | [ScannerConnection] Waiting for scanner input
barcode-buddy_1  | [info] Starting socket server on 127.0.0.1:47631

As it seems barcode buddy recognises my barcode scanner and the environment variable ATTACH_BARCODESCANNER. But when i got to the "screen" page and scan a grocy-known package of salt nothing is happening. No code is scanned, i get no logs whatsoever.

On the raspberry pi host, i can use evtest successfully using the device /dev/input/event0. But when i enter the container and try evtest i get the following message:

***********************************************
  This device is grabbed by another process.
  No events are available to evtest while the
  other grab is active.
  In most cases, this is caused by an X driver,
  try VT-switching and re-run evtest again.
  Run the following command to see processes with
  an open fd on this device
 "fuser -v /dev/input/event0"
***********************************************

I have googled a bit but couldn't find a solution for that. I guess that it's something special with the docker container?

can you help me?

mikedolx commented 1 year ago

Just fixed my issue. The problem was, that i had the ATTACH_BARCODESCANNER set to true, which basically means, that barcode buddy grabs the device and uses it. After removing ATTACH_BARCODESCANNER from my docker-compose.yaml i was able to successfully test the barcode scanner within the docker container.

But to get the input device working in the container, i had to change the group of the device to docker using

sudo chgrp docker /dev/input/event0

Afterwards, i restarted my container, and the barcodes were working! Of cource i had to set ATTACH_BARCODESCANNER=true in my docker-compose.yaml.

Forceu commented 1 year ago

Great to hear it is working now and thank you for the explanation!