annotate docker/backend-dev-e2e/Dockerfile @ 4212:5f2d496c633f

core: get rid of `pickle`: Use of `pickle` to serialise data was a technical legacy that was causing trouble to store in database, to update (if a class was serialised, a change could break update), and to security (pickle can lead to code execution). This patch remove all use of Pickle in favour in JSON, notably: - for caching data, a Pydantic model is now used instead - for SQLAlchemy model, the LegacyPickle is replaced by JSON serialisation - in XEP-0373 a class `PublicKeyMetadata` was serialised. New method `from_dict` and `to_dict` method have been implemented to do serialisation. - new methods to (de)serialise data can now be specified with Identity data types. It is notably used to (de)serialise `path` of avatars. A migration script has been created to convert data (for upgrade or downgrade), with special care for XEP-0373 case. Depending of size of database, this migration script can be long to run. rel 443
author Goffi <goffi@goffi.org>
date Fri, 23 Feb 2024 13:31:04 +0100
parents 09f5ac48ffe3
children 31c84a32c897
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3689
f25442794e11 docker: fix use of `REVISION` in `FROM` instruction
Goffi <goffi@goffi.org>
parents: 3688
diff changeset
1 ARG REVISION
f25442794e11 docker: fix use of `REVISION` in `FROM` instruction
Goffi <goffi@goffi.org>
parents: 3688
diff changeset
2 FROM libervia/backend:${REVISION:-dev}
3381
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 LABEL maintainer="Goffi <tmp_dockerfiles@goffi.org>"
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 USER root
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7
3427
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
8 ARG DEBIAN_FRONTEND=noninteractive
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
9
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
10 RUN mkdir -m 777 /reports && \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
11 apt-get install -y --no-install-recommends \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
12 # firefox is needed to test Libervia via selenium
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
13 firefox-esr \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
14 # VNC/X11 server for visual mode + window manager
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
15 # using openbox as it allows to resize easily when doing manual debugging/tests
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
16 # and it adapts correctly when doing driver.set_window_size
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
17 tigervnc-standalone-server openbox \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
18 # useful for remote debugging
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
19 telnet net-tools \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
20 # needed to make Firefox trust system certificates
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
21 # cf. https://askubuntu.com/a/1036637
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
22 p11-kit && \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
23 ln -fs /usr/lib/x86_64-linux-gnu/pkcs11/p11-kit-trust.so /usr/lib/firefox-esr/libnssckbi.so
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
24
3381
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 # we install pre-generated certificates so we can do tests with valid TLS
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 COPY --chown=root:root certificates/minica.pem /usr/local/share/ca-certificates/minica.crt
3497
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
27 COPY --chown=root:tls-cert certificates/server1.test/cert.pem /usr/share/libervia/certificates/server1.test.pem
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
28 COPY --chown=root:tls-cert certificates/server1.test/key.pem /usr/share/libervia/certificates/server1.test-key.pem
3381
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 RUN update-ca-certificates
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
3497
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
31 COPY --chown=root:root libervia.conf /etc/libervia.conf
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
32 COPY --chown=libervia:libervia scripts/entrypoint.sh /home/libervia/entrypoint_e2e.sh
3381
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
3427
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
34 RUN \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
35 # we install webdriver (needed to control Firefox from Selenium)
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
36 # note: this is not absolutely necessary as long as we use helium because it includes
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
37 # is own webdriver
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
38 python -c 'from urllib.request import urlretrieve;\
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
39 urlretrieve(\
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
40 "https://github.com/mozilla/geckodriver/releases/download/v0.28.0"\
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
41 "/geckodriver-v0.28.0-linux64.tar.gz", "/usr/local/bin/geckodriver.tar.gz")' && \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
42 cd /usr/local/bin && tar zxf geckodriver.tar.gz && rm -f geckodriver.tar.gz
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
43
3497
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
44 WORKDIR /home/libervia
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
45 USER libervia
3381
127dde80a0a5 docker: dockers images, first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46
3427
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
47 RUN \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
48 # pytest and its plugins
3671
9c50d2f812c1 docker (e2e): add `pytest-twisted` to image
Goffi <goffi@goffi.org>
parents: 3641
diff changeset
49 pip install pytest pytest-timeout pytest-dependency pytest-twisted \
3641
0ffaa231138c docker: Libervia revision can now be specified:
Goffi <goffi@goffi.org>
parents: 3497
diff changeset
50 # needed to test libervia-cli
3427
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
51 sh \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
52 # needed to test libervia
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
53 helium \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
54 # needed to check sent emails
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
55 aiosmtpd \
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
56 # useful for debugging
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
57 pudb
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
58
3385
bcdfe7905409 docker (backend_e2e): install pytest and sh
Goffi <goffi@goffi.org>
parents: 3381
diff changeset
59 RUN ./entrypoint.sh \
bcdfe7905409 docker (backend_e2e): install pytest and sh
Goffi <goffi@goffi.org>
parents: 3381
diff changeset
60 # we create the file sharing component which will autoconnect when backend is started
3688
d5fd630b57bb docker: fix use of File Sharing component following entry point renaming
Goffi <goffi@goffi.org>
parents: 3641
diff changeset
61 li profile create file-sharing -j files.server1.test -p "" --xmpp-password test_e2e -C file-sharing -A && \
3497
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
62 libervia-backend stop
3427
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
63
3497
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
64 ENV LIBERVIA_TEST_REPORT_DIR=/reports
3427
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
65 ENV DISPLAY=:0
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
66 USER root
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
67 RUN apt-get install -y openbox
3497
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
68 USER libervia
3427
f023f06fa344 docker (backend_e2e): added packages necessary to test Libervia + some debugging tools
Goffi <goffi@goffi.org>
parents: 3385
diff changeset
69 EXPOSE 5900
3497
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
70
73e04040d577 docker: update following name changes:
Goffi <goffi@goffi.org>
parents: 3439
diff changeset
71 ENTRYPOINT ["/home/libervia/entrypoint_e2e.sh"]