tests/tools/Docker/Dockerfile
author Edouard Tisserant <edouard.tisserant@gmail.com>
Thu, 15 Dec 2022 14:45:52 +0100
branchwxPython4
changeset 3696 ea30051326e9
parent 3693 4058140a8757
child 3697 12b6add87876
permissions -rw-r--r--
tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     1
#
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     2
# Dockerfile for Beremiz
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     3
# This container is used to run tests for Beremiz
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     4
#
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     5
FROM ubuntu:focal  
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     6
                                        
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     7
ENV TERM xterm-256color
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     8
    
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     9
ENV LANG en_US.UTF-8
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    10
ENV LANGUAGE en_US:en
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    11
ENV LC_ALL en_US.UTF-8
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    12
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    13
ARG UNAME=testing
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    14
ENV UNAME ${UNAME}
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    15
ARG UID=1000
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    16
ARG GID=1000
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    17
RUN groupadd -g $GID $UNAME
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    18
RUN useradd -m -u $UID -g $GID -s /bin/bash $UNAME
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    19
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    20
RUN set -xe \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    21
    && apt-get update \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    22
    && TZ="America/Paris" \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    23
       DEBIAN_FRONTEND="noninteractive" \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    24
       apt-get install -y --no-install-recommends \
3679
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    25
               `# to run sikuli` \
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
               wget \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    27
               libopencv4.2-java \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
               openjdk-11-jre \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    29
               \
3679
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    30
               `# to run X based tests` \
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    31
               fluxbox \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    32
               wmctrl xdotool xvfb \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    33
               x11vnc xterm xnest \
3679
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    34
               materia-gtk-theme \
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    35
               \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    36
               `# to build tested apps` \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    37
               build-essential automake flex bison mercurial \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
               libgtk-3-dev libgl1-mesa-dev libglu1-mesa-dev \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    39
               libpython2.7-dev libssl-dev \
3549
0af7b6a96c53 CLI: fix fake_wx for OPC-UA in CLI, match with test and requirements
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3542
diff changeset
    40
               python2 virtualenv cmake
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    41
3679
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    42
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    43
# force bigger font and flat theme for GTK in order to make OCR more reliable
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    44
RUN mkdir -p /etc/gtk-3.0
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    45
RUN env echo -e '[Settings]\ngtk-font-name=FreeSans,12\ngtk-theme-name=Materia\n' > /etc/gtk-3.0/settings.ini
b6bca75bf3fa Tests: force bigger fonts and flat theme in GTK to make OCR more reliable.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3549
diff changeset
    46
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    47
# link obtained from https://raiman.github.io/SikuliX1/downloads.html
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    48
RUN set -xe && \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    49
    wget -qP /usr/local/bin \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    50
        https://launchpad.net/sikuli/sikulix/2.0.5/+download/sikulixide-2.0.5.jar && \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    51
    echo 0795f1e0866ee5a7a84e4c89793ea78c /usr/local/bin/sikulixide-2.0.5.jar | md5sum -c && \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
    ( echo '#!/bin/sh' && \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    53
      echo "exec java -jar /usr/local/bin/sikulixide-*.jar \"\$@\"" \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    54
    ) | install /dev/stdin /usr/local/bin/sikulix
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    55
3458
2c712b8c736f Tests: use script rather than alias so that bash doesn't need to be interactive shell with a TTY
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3438
diff changeset
    56
3542
c1d627434cd1 tests: docker: add dependencies for CLI testing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3459
diff changeset
    57
RUN env echo -e '#!/bin/bash\nmake -f /home/testing/src/beremiz/tests/Makefile $*' > /usr/local/bin/do_tests
3458
2c712b8c736f Tests: use script rather than alias so that bash doesn't need to be interactive shell with a TTY
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3438
diff changeset
    58
RUN chmod +x /usr/local/bin/do_tests
2c712b8c736f Tests: use script rather than alias so that bash doesn't need to be interactive shell with a TTY
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3438
diff changeset
    59
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    60
USER $UNAME
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    61
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    62
RUN mkdir /home/$UNAME/build /home/$UNAME/src /home/$UNAME/test
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    63
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    64
RUN virtualenv --python=$(which python2) ~/beremizenv
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    65
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    66
RUN ~/beremizenv/bin/pip install \
3438
24fbd4d1fe80 Tests: Re-introduced pytest based tests. Fixed them a bit, commented-out otherwise. Application tests only runs with logging test, and PLCOpenEditor tests seem broken.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3431
diff changeset
    67
        pytest pytest-timeout ddt \
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    68
        lxml future matplotlib zeroconf2 enum34 pyro sslpsk posix_spawn \
3549
0af7b6a96c53 CLI: fix fake_wx for OPC-UA in CLI, match with test and requirements
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3542
diff changeset
    69
        twisted nevow autobahn click opcua \
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    70
        wxPython==4.1.1
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    71
3696
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    72
RUN set -xe && \
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    73
    cd  /home/$UNAME && mkdir tessdata && \
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    74
    wget -q https://github.com/tesseract-ocr/tessdata/archive/refs/tags/4.1.0.tar.gz \
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    75
         -O tessdata.tar.gz && \
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    76
    echo 89e25c7c40a59be7195422a01f57fcb2 tessdata.tar.gz | md5sum -c && \
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    77
    tar --strip-components=1 -C tessdata -x -v -z -f tessdata.tar.gz && \
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    78
    rm tessdata.tar.gz
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    79
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    80
ENV TESSDATAPATH /home/$UNAME/tessdata
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    81
ea30051326e9 tests: add tesseract training data "tessdata", still trying to enhance OCR reliability in UI tests
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3693
diff changeset
    82
# Points to python binary that test will use
3431
5bcef31e276d Tests: Added BEREMIZPYTHONPATH to point to Python interpreter to use for tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3425
diff changeset
    83
ENV BEREMIZPYTHONPATH /home/$UNAME/beremizenv/bin/python
5bcef31e276d Tests: Added BEREMIZPYTHONPATH to point to Python interpreter to use for tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3425
diff changeset
    84
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    85
# easy to remember 'do_tests' alias to invoke main makefile
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    86
ARG OWNDIRBASENAME=beremiz
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    87
ENV OWNDIRBASENAME ${OWNDIRBASENAME}
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    88
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    89