diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 2a6af60..df1af30 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [ 3.8, 3.9 ] + python-version: [ "3.10" ] steps: - uses: actions/checkout@v1 diff --git a/Dockerfile b/Dockerfile index ea29662..46cdad1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,19 @@ # Docker image for barcode-server -FROM python:3.10 +# dont use alpine for python builds: https://pythonspeed.com/articles/alpine-docker-python/ +FROM python:3.10-slim-buster WORKDIR /app COPY . . RUN apt-get update \ - && apt-get -y install sudo + && apt-get -y install sudo python3-pip python3-evdev \ + && apt-get clean && rm -rf /var/lib/apt/lists/* RUN pip install --upgrade pip;\ + pip3 install evdev;\ pip install pipenv;\ - pipenv install --system --deploy;\ + PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy;\ pip install . ENV PUID=1000 PGID=1000 diff --git a/Makefile b/Makefile index 1e8a77d..affe31e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ PROJECT=barcode_server +docker-image: + docker build . --file Dockerfile --tag markusressel/barcode-server:latest --no-cache + current-version: set -ex @echo "Current version is `cat ${PROJECT}/__init__.py | grep '__version__' | cut -d ' ' -f3 | sed s/\\\"//g`" diff --git a/Pipfile.lock b/Pipfile.lock index f17b2a6..3c1d6dd 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -114,7 +114,7 @@ "sha256:26e62109036cd181df6e6ad646f91f0dcfd05fe16d0cb924138ff2ab75d64e3a", "sha256:78ed67db6c7b7ced4f98e495e572106d5c432a93e1ddd1bf475e1dc05f5b7df2" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==1.2.0" }, "async-timeout": { @@ -122,16 +122,16 @@ "sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15", "sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==4.0.2" }, "asyncio-mqtt": { "hashes": [ - "sha256:6dbf85a45f94d26e7465411680ada3947b50546e98208d5d52e7a0a7ed7a7c38", - "sha256:cfa32fbd3a2d727ac74fa17ccafd30830a2a66f9e5e6ac7eee5458a9c7a6a832" + "sha256:438842f57e27b85e3daf65a4d4001460ba6d46ed3b85923c44a1bd75e56d5d53", + "sha256:f3bee8dfdd080524e93feccec562c644786314ae4bb47ef6d2bd9a667970b825" ], "index": "pypi", - "version": "==0.12.1" + "version": "==0.13.0" }, "attrs": { "hashes": [ @@ -146,7 +146,7 @@ "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845", "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==2.1.1" }, "click": { @@ -704,7 +704,7 @@ "sha256:26e62109036cd181df6e6ad646f91f0dcfd05fe16d0cb924138ff2ab75d64e3a", "sha256:78ed67db6c7b7ced4f98e495e572106d5c432a93e1ddd1bf475e1dc05f5b7df2" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==1.2.0" }, "async-timeout": { @@ -712,7 +712,7 @@ "sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15", "sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==4.0.2" }, "attrs": { @@ -728,7 +728,7 @@ "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845", "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f" ], - "markers": "python_version >= '3.6'", + "markers": "python_full_version >= '3.6.0'", "version": "==2.1.1" }, "frozenlist": { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..47df585 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.8' + +services: + barcode-server: + # build: . + image: markusressel/barcode-server:latest + environment: + - PUID=0 + - PGID=0 + devices: + - "/dev/input" + volumes: + # mount a YAML configuration file into /app/barcode_server.yaml: + - "./barcode_server.yaml:/app/barcode_server.yaml" + networks: + - docker-elk + ports: + - "8000:8000" + restart: on-failure +networks: + docker-elk: + driver: bridge \ No newline at end of file diff --git a/tests/barcode_server.yaml b/tests/barcode_server.yaml index 9d973d7..95ebdd8 100644 --- a/tests/barcode_server.yaml +++ b/tests/barcode_server.yaml @@ -4,6 +4,6 @@ barcode_server: port: 9654 api_token: "EmUSqjXGfnQwn5wn6CpzJRZgoazMTRbMNgH7CXwkQG7Ph7stex" devices: - - "Barcode/i" + - "Barcode" stats: port: diff --git a/tests/websocket_notifier_test.py b/tests/websocket_notifier_test.py index a614d9f..f38c7c4 100644 --- a/tests/websocket_notifier_test.py +++ b/tests/websocket_notifier_test.py @@ -3,7 +3,7 @@ from unittest.mock import MagicMock import aiohttp -from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop +from aiohttp.test_utils import AioHTTPTestCase from barcode_server import const from barcode_server.barcode import BarcodeEvent @@ -58,10 +58,6 @@ async def get_application(self): await site.start() return app - # the unittest_run_loop decorator can be used in tandem with - # the AioHTTPTestCase to simplify running - # tests that are asynchronous - @unittest_run_loop async def test_ws_connect_and_event(self): sample_event = create_barcode_event_mock("abcdefg") server_id = self.config.INSTANCE_ID.value @@ -88,7 +84,6 @@ async def test_ws_connect_and_event(self): assert False - @unittest_run_loop async def test_ws_reconnect_event_catchup(self): server_id = self.config.INSTANCE_ID.value missed_event = create_barcode_event_mock("abcdefg") @@ -144,7 +139,6 @@ async def test_ws_reconnect_event_catchup(self): assert False - @unittest_run_loop async def test_ws_reconnect_drop_queue(self): server_id = self.config.INSTANCE_ID.value missed_event = create_barcode_event_mock("abcdefg")