Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Refactoring of dockerfiles #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Prev Previous commit
Next Next commit
Dockerfile--ubuntu-24_04.tmpl
  • Loading branch information
dmitry-lipetsk committed Mar 12, 2025
commit 64e4b84b2067bb340bd649d27d4a8527d8e98d4d
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ env:
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=11
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=10
- TEST_PLATFORM=std.all PYTHON_VERSION=3 PG_VERSION=17
# - TEST_PLATFORM=ubuntu-24_04 PYTHON_VERSION=3 PG_VERSION=17
- TEST_PLATFORM=ubuntu-24_04 PYTHON_VERSION=3 PG_VERSION=17
48 changes: 34 additions & 14 deletions Dockerfile--ubuntu-24_04.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
FROM ubuntu:24.04
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
FROM ubuntu:24.04 as base1
ARG PG_VERSION

RUN apt update
RUN apt install -y sudo curl ca-certificates
RUN apt update
RUN apt install -y openssh-server

RUN apt update
RUN apt install -y sudo curl ca-certificates postgresql-common
RUN apt install -y postgresql-common

RUN bash /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y

Expand All @@ -14,35 +24,45 @@ RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail http
RUN apt update
RUN apt install -y postgresql-${PG_VERSION}

RUN apt install -y python3 python3-dev python3-virtualenv
# RUN apt install -y mc

# It is required for psycopg2
RUN apt install -y libpq-dev
RUN apt install -y openssh-server

# [2025-02-26] It adds the user 'postgres' in the group 'sudo'
# [2025-02-27] It is not required.
# RUN adduser postgres sudo

ADD . /pg/testgres
WORKDIR /pg/testgres
RUN chown -R postgres /pg

EXPOSE 22

RUN ssh-keygen -A

# It enables execution of "sudo service ssh start" without password
RUN sh -c "echo postgres ALL=NOPASSWD:/usr/sbin/service ssh start" >> /etc/sudoers

USER postgres
# --------------------------------------------- base2_with_python-3
FROM base1 as base2_with_python-3
RUN apt update
RUN apt install -y python3
RUN apt update
RUN apt install -y python3-dev
RUN apt update
RUN apt install -y python3-virtualenv
RUN apt update
RUN apt install -y libpq-dev # It is required for psycopg2
ENV PYTHON_VERSION=3

# --------------------------------------------- final
FROM base2_with_python-${PYTHON_VERSION} as final

ADD . /pg/testgres
WORKDIR /pg/testgres
RUN chown -R postgres /pg

ENV LANG=C.UTF-8

USER postgres

RUN chmod 700 ~/
RUN mkdir -p ~/.ssh

#ENTRYPOINT PYTHON_VERSION=3.12 /run.sh
ENTRYPOINT sh -c " \
#set -eux; \
echo HELLO FROM ENTRYPOINT; \
Expand All @@ -55,4 +75,4 @@ ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N ''; \
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys; \
chmod 600 ~/.ssh/authorized_keys; \
ls -la ~/.ssh/; \
TEST_FILTER=\"\" PYTHON_VERSION=${PYTHON_VERSION} bash run_tests.sh;"
TEST_FILTER=\"\" bash ./run_tests.sh;"