Dockerfile-pgtests 1.1 KB

123456789101112131415161718192021222324252627282930
  1. # Use the Sytest image that comes with a lot of the build dependencies
  2. # pre-installed
  3. FROM matrixdotorg/sytest:focal
  4. # The Sytest image doesn't come with python, so install that
  5. RUN apt-get update && apt-get -qq install -y python3 python3-dev python3-pip
  6. # We need tox to run the tests in run_pg_tests.sh
  7. RUN python3 -m pip install tox
  8. # Initialise the db
  9. RUN su -c '/usr/lib/postgresql/10/bin/initdb -D /var/lib/postgresql/data -E "UTF-8" --lc-collate="C.UTF-8" --lc-ctype="C.UTF-8" --username=postgres' postgres
  10. # Add a user with our UID and GID so that files get created on the host owned
  11. # by us, not root.
  12. ARG UID
  13. ARG GID
  14. RUN groupadd --gid $GID user
  15. RUN useradd --uid $UID --gid $GID --groups sudo --no-create-home user
  16. # Ensure we can start postgres by sudo-ing as the postgres user.
  17. RUN apt-get update && apt-get -qq install -y sudo
  18. RUN echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
  19. ADD run_pg_tests.sh /run_pg_tests.sh
  20. # Use the "exec form" of ENTRYPOINT (https://docs.docker.com/engine/reference/builder/#entrypoint)
  21. # so that we can `docker run` this container and pass arguments to pg_tests.sh
  22. ENTRYPOINT ["/run_pg_tests.sh"]
  23. USER user