tests/tools/Docker/Dockerfile
author Edouard Tisserant <edouard@beremiz.fr>
Tue, 20 Feb 2024 11:34:28 +0100
changeset 3891 0f375805097a
parent 3862 ef434ea0bcec
permissions -rw-r--r--
SVGHMI: Fix warning with WxPython > 4.x
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
#
3815
56f08ab3a491 Tests: Fix dockerfile for python3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3724
diff changeset
     5
FROM ubuntu:jammy  
3425
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
3715
961903c0b76d Tests: Fix dockerfile not finding locales.
etisserant <edouard.tisserant@gmail.com>
parents: 3710
diff changeset
    20
RUN set -xe \
961903c0b76d Tests: Fix dockerfile not finding locales.
etisserant <edouard.tisserant@gmail.com>
parents: 3710
diff changeset
    21
    && apt-get update \
961903c0b76d Tests: Fix dockerfile not finding locales.
etisserant <edouard.tisserant@gmail.com>
parents: 3710
diff changeset
    22
    && apt-get install locales \
961903c0b76d Tests: Fix dockerfile not finding locales.
etisserant <edouard.tisserant@gmail.com>
parents: 3710
diff changeset
    23
    && locale-gen en_US.UTF-8 \
961903c0b76d Tests: Fix dockerfile not finding locales.
etisserant <edouard.tisserant@gmail.com>
parents: 3710
diff changeset
    24
    && update-locale LANG=en_US.UTF-8
3710
51c2d434e10e tests: IDE: own text matching logic for OCR reliability, enhanced ihtml report
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3697
diff changeset
    25
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
RUN set -xe \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    27
    && TZ="America/Paris" \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
       DEBIAN_FRONTEND="noninteractive" \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    29
       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
    30
               `# 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
    31
               wget \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    32
               openjdk-11-jre \
3724
ad3a05cf2066 Tests: docker image needs tesseract4, but opencv lib since sikuli.jar already contains it.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3715
diff changeset
    33
               libtesseract4 \
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    34
               \
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
    35
               `# 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
    36
               fluxbox \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    37
               wmctrl xdotool xvfb \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
               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
    39
               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
    40
               \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    41
               `# 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
    42
               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
    43
               libgtk-3-dev libgl1-mesa-dev libglu1-mesa-dev \
3815
56f08ab3a491 Tests: Fix dockerfile for python3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3724
diff changeset
    44
               libpython3.10-dev libssl-dev \
56f08ab3a491 Tests: Fix dockerfile for python3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3724
diff changeset
    45
               python3.10 virtualenv cmake git
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    46
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
    47
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
    48
# 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
    49
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
    50
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
    51
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
# 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
    53
RUN set -xe && \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    54
    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
    55
        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
    56
    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
    57
    ( echo '#!/bin/sh' && \
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    58
      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
    59
    ) | 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
    60
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
    61
3840
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    62
### SVGHMI dependencies : Chromium browser + Inkscape ###
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    63
#
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    64
# On ubuntu chromium is distrinuted as a snap.
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    65
# Running snapd on docker is a mess.
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    66
# As a workaround, there is a PPA where chromium .deb packges build is still beeing maintained :
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    67
#
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    68
# https://launchpad.net/~savoury1/+archive/ubuntu/chromium
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    69
#     ppa:savoury1, maintained by Rob Savoury at the time of writing
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    70
#
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    71
# As a side effect of docker limitations, chromium need --no-sandbox command line argument.
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    72
#
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    73
RUN apt-get install -qqy --no-install-recommends gnupg software-properties-common \
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    74
    && add-apt-repository -y ppa:savoury1/chromium \
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    75
    && add-apt-repository -y ppa:savoury1/ffmpeg4 \
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    76
    && apt-get install -qqy --no-install-recommends chromium-browser inkscape
c2b6354f036f Tests: Add minimal SVGHMI test
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3820
diff changeset
    77
3697
12b6add87876 tests/tools: move comment and remove dead code in Dockerfile
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3696
diff changeset
    78
# easy to remember 'do_tests' alias to invoke main makefile
3542
c1d627434cd1 tests: docker: add dependencies for CLI testing
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3459
diff changeset
    79
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
    80
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
    81
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    82
USER $UNAME
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    83
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    84
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
    85
3815
56f08ab3a491 Tests: Fix dockerfile for python3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3724
diff changeset
    86
RUN virtualenv ~/beremizenv
56f08ab3a491 Tests: Fix dockerfile for python3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3724
diff changeset
    87
3841
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    88
COPY requirements.txt /home/$UNAME
3815
56f08ab3a491 Tests: Fix dockerfile for python3
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3724
diff changeset
    89
3841
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    90
# beremiz python requirements
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    91
RUN ~/beremizenv/bin/pip install -r /home/$UNAME/requirements.txt
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    92
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    93
# tests python requirements
3425
ee3b84d09ccf Add Docker image definition as reference platform to run IDE tests.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    94
RUN ~/beremizenv/bin/pip install \
3841
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    95
        pytest pytest-timeout ddt
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    96
        
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    97
#TODO sslpsk posix_spawn
02fa0f8484d7 Tests: align on requirements.txt
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3840
diff changeset
    98
     
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
    99
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
   100
    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
   101
    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
   102
         -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
   103
    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
   104
    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
   105
    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
   106
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
   107
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
   108
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
   109
# 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
   110
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
   111