From 71a16dc1b9d6cbe60c8047f1c2d2abc74420ea07 Mon Sep 17 00:00:00 2001 From: cybcon <42999275+cybcon@users.noreply.github.com> Date: Mon, 23 Jan 2023 10:36:58 +0100 Subject: [PATCH] Optimize container build (#7) * Increase Version * Increase Version * Add new Version * Fixing linter issue * Optimize container image build process Co-authored-by: Michael Oberdorf --- Dockerfile | 11 ++++++----- README.md | 3 ++- app/modbus_client.py | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 991e57a..e1460ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,10 +10,7 @@ RUN apk add --no-cache \ && ln -s /usr/include/locale.h /usr/include/xlocale.h COPY FloatToHex /FloatToHex WORKDIR /FloatToHex -RUN python3 setup.py install \ - && pip3 install --no-cache-dir \ - pandas==1.5.3 \ - 'pymodbus>=2,<3' +RUN python3 setup.py install # Building the docker image with already compiled modules FROM base @@ -25,12 +22,16 @@ LABEL site.local.os.version="3.17" LABEL site.local.runtime.name="Python" LABEL site.local.runtime.version="3.10.9" LABEL site.local.program.name="Python Modbus TCP Client" -LABEL site.local.program.version="1.0.7" +LABEL site.local.program.version="1.0.9" COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages RUN apk add --no-cache \ libstdc++=12.2.1_git20220924-r4 \ + py3-wheel=0.38.4-r0 \ + py3-pandas=1.5.1-r0 \ + && pip3 install --no-cache-dir \ + 'pymodbus>=2,<3' \ && addgroup -g 1000 -S pythonuser \ && adduser -u 1000 -S pythonuser -G pythonuser \ && mkdir -p /app diff --git a/README.md b/README.md index 20cc310..4de440e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Source code: [GitHub](https://github.com/cybcon/modbus-client) # Supported tags and respective `Dockerfile` links -* [`latest`, `1.0.8`](https://github.com/cybcon/modbus-client/blob/v1.0.8/Dockerfile) +* [`latest`, `1.0.9`](https://github.com/cybcon/modbus-client/blob/v1.0.9/Dockerfile) +* [`1.0.8`](https://github.com/cybcon/modbus-client/blob/v1.0.8/Dockerfile) * [`1.0.6`](https://github.com/cybcon/modbus-client/blob/1.0.6/Dockerfile) * [`1.0.5`](https://github.com/cybcon/modbus-client/blob/1.0.5/Dockerfile) * [`1.0.4`](https://github.com/cybcon/modbus-client/blob/1.0.4/dockerfile) diff --git a/app/modbus_client.py b/app/modbus_client.py index 570b5be..56480c3 100644 --- a/app/modbus_client.py +++ b/app/modbus_client.py @@ -1,13 +1,18 @@ # -*- coding: utf-8 -*- -""" *************************************************************************** -Modbus TCP client script for debugging -Author: Michael Oberdorf IT-Consulting -Datum: 2020-05-20 -Last modified by: Michael Oberdorf IT-Consulting -Last modified at: 2023-01-20 -*************************************************************************** """ +""" +############################################################################### +# Modbus TCP client script for debugging +# Author: Michael Oberdorf IT-Consulting +# Datum: 2020-05-20 +# Last modified by: Michael Oberdorf IT-Consulting +# Last modified at: 2023-01-23 +############################################################################### +""" import sys import os +if os.path.isdir('/usr/lib/python3.10/site-packages'): + sys.path.append('/usr/lib/python3.10/site-packages') + from pymodbus.client.sync import ModbusTcpClient as ModbusClient import logging import argparse @@ -16,7 +21,7 @@ import FloatToHex from numpy import little_endian -VERSION='1.0.8' +VERSION='1.0.9' DEBUG=False """ ###############################################################################