view docker/backend/Dockerfile @ 3415:814e118d9ef3

tests: end-2-end tests first draft: - e2e tests are launched inside the new docker e2e test environment - `run_e2e.py` launch the docker container, mount the current code base in it, launch the e2e tests and print report in real time - `conftest.py` are pytest fixtures managing many things such as account creation, fake files management, JSON or Domish.Element parsing, fake editor, etc. - `test_jp.py` are end-to-end test done with `jp`. `sh` library is used to make tests writting as user-friendly as possible. The `SAT_TEST_ENV_E2E` environment variable is checked, and tests will be skipped if it's not set.
author Goffi <goffi@goffi.org>
date Thu, 12 Nov 2020 14:53:16 +0100
parents 127dde80a0a5
children fc83c4996c77
line wrap: on
line source

FROM debian:buster

LABEL maintainer="Goffi <tmp_dockerfiles@goffi.org>"

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y --no-install-recommends locales python3-dev python3-venv python3-wheel mercurial libxml2-dev libxslt-dev libcairo2-dev libjpeg-dev libgirepository1.0-dev libdbus-1-dev libdbus-glib-1-dev dbus-x11 cmake && \
    \
    # will be used to put many SàT specific data
    mkdir -p /usr/share/sat/certificates && \
    addgroup tls-cert --gid 9999 && \
    chown :tls-cert /usr/share/sat/certificates && \
    chmod 2770 /usr/share/sat/certificates && \
    # it's better to have a dedicated user
    useradd -m sat && adduser sat tls-cert && \
    # we'll put all source there to have an easy mount point
    mkdir /src && chown sat:sat /src && \
    \
    # we need UTF-8 locale
    sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen && locale-gen && \
    \
    # we need a TCP socket for D-Bus
    sed -i "s&<listen>unix:tmpdir=/tmp</listen>&\0\n  <listen>tcp:host=localhost,bind=*,port=55555,family=ipv4</listen>\n  <auth>ANONYMOUS</auth>\n  <allow_anonymous/>&" /usr/share/dbus-1/session.conf

ENV LC_ALL en_US.UTF-8

WORKDIR /home/sat
USER sat

RUN python3 -m venv sat_env && sat_env/bin/pip install wheel && cd /src && \
    # We install thoses packages in editable mode, so we can replace them easily with volumes.
    # We need to move *.egg-info (generated by pip) out of src dirs, otherwise mounting
    # local repos without it them cause troubles
    hg clone https://repos.goffi.org/urwid-satext && ~/sat_env/bin/pip install -e urwid-satext && \
    mv urwid-satext/urwid_satext.egg-info ~/sat_env/lib/python3.*/site-packages && \
    hg clone https://repos.goffi.org/sat_tmp && ~/sat_env/bin/pip install -e sat_tmp && \
    mv sat_tmp/sat_tmp.egg-info ~/sat_env/lib/python3.*/site-packages && \
    hg clone https://repos.goffi.org/sat_templates && ~/sat_env/bin/pip install -e sat_templates && \
    mv sat_templates/sat_templates.egg-info ~/sat_env/lib/python3.*/site-packages && \
    hg clone https://repos.goffi.org/sat_media && \
    hg clone https://repos.goffi.org/sat && ~/sat_env/bin/pip install -e 'sat[SVG]' && \
    mv sat/sat.egg-info ~/sat_env/lib/python3.*/site-packages

ENV DBUS_SESSION_BUS_ADDRESS=tcp:host=sat,port=55555,family=ipv4
ENV PATH=/home/sat/sat_env/bin:$PATH

COPY --chown=root:root sat.conf /etc/_sat.conf
COPY --chown=sat:sat scripts/entrypoint.sh /home/sat/

ENTRYPOINT ["/home/sat/entrypoint.sh"]