|
| 1 | +FROM ubuntu:24.04 |
| 2 | + |
| 3 | +RUN apt update |
| 4 | +#RUN apt -y install software-properties-common |
| 5 | +#RUN add-apt-repository main |
| 6 | +#RUN add-apt-repository universe |
| 7 | + |
| 8 | +#RUN apt-get update && apt-get install -y apt-transport-https |
| 9 | +RUN apt install -y sudo curl ca-certificates postgresql-common |
| 10 | +#RUN apt install -y lsb-core |
| 11 | + |
| 12 | +RUN bash /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y |
| 13 | + |
| 14 | +RUN install -d /usr/share/postgresql-common/pgdg |
| 15 | +RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc |
| 16 | + |
| 17 | +# It does not work |
| 18 | +#RUN sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' |
| 19 | + |
| 20 | +RUN apt update |
| 21 | +RUN apt install -y postgresql-17 |
| 22 | + |
| 23 | +RUN apt install -y curl python3 python3-dev python3-virtualenv musl-dev |
| 24 | +RUN apt install -y mc |
| 25 | + |
| 26 | +# It is required for psycopg2 |
| 27 | +RUN apt install -y libpq-dev |
| 28 | +RUN apt install -y openssh-server |
| 29 | + |
| 30 | +RUN mkdir -p /pg |
| 31 | +COPY run_tests.sh /run.sh |
| 32 | +RUN chmod 755 /run.sh |
| 33 | + |
| 34 | +# It adds the user 'postgres' in the group 'sudo' |
| 35 | +RUN adduser postgres sudo |
| 36 | + |
| 37 | +ADD . /pg/testgres |
| 38 | +WORKDIR /pg/testgres |
| 39 | +RUN chown -R postgres /pg |
| 40 | + |
| 41 | +EXPOSE 22 |
| 42 | + |
| 43 | +RUN ssh-keygen -A |
| 44 | + |
| 45 | +# It enables execution of "sudo service ssh start" without password |
| 46 | +RUN sh -c "echo postgres ALL=NOPASSWD:/usr/sbin/service ssh start" >> /etc/sudoers |
| 47 | +# It requires for test those work through SSH |
| 48 | +RUN mkdir -p /home/postgres |
| 49 | +RUN chown postgres:postgres /home/postgres |
| 50 | + |
| 51 | +USER postgres |
| 52 | + |
| 53 | +ENV LANG=C.UTF-8 |
| 54 | + |
| 55 | +#ENTRYPOINT PYTHON_VERSION=3.12 /run.sh |
| 56 | +ENTRYPOINT sh -c " \ |
| 57 | +#set -eux; \ |
| 58 | +echo HELLO FROM ENTRYPOINT; \ |
| 59 | +echo HOME DIR IS [`realpath ~/`]; \ |
| 60 | +echo POINT 1; \ |
| 61 | +chmod go-w /var/lib/postgresql; \ |
| 62 | +echo POINT 1.5; \ |
| 63 | +mkdir -p ~/.ssh; \ |
| 64 | +echo POINT 2; \ |
| 65 | +service ssh enable; \ |
| 66 | +echo POINT 3; \ |
| 67 | +sudo service ssh start; \ |
| 68 | +echo POINT 4; \ |
| 69 | +ssh-keyscan -H localhost >> ~/.ssh/known_hosts; \ |
| 70 | +echo POINT 5; \ |
| 71 | +ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts; \ |
| 72 | +echo POINT 6; \ |
| 73 | +ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N ''; \ |
| 74 | +echo ----; \ |
| 75 | +cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys; \ |
| 76 | +echo ----; \ |
| 77 | +chmod 600 ~/.ssh/authorized_keys; \ |
| 78 | +echo ----; \ |
| 79 | +ls -la ~/.ssh/; \ |
| 80 | +echo ----; \ |
| 81 | +bash;" |