Skip to content
Merged
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ services:
- docker

install:
- ./mk_dockerfile.sh
- docker-compose build
- docker build --build-arg PG_VERSION="${PG_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" -t tests -f Dockerfile--${TEST_PLATFORM}.tmpl .

script:
- docker-compose run $(bash <(curl -s https://codecov.io/env)) tests
- docker run $(bash <(curl -s https://codecov.io/env)) -t tests

notifications:
email:
Expand All @@ -27,5 +26,5 @@ env:
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=12
- 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=std-all PYTHON_VERSION=3 PG_VERSION=17
- TEST_PLATFORM=ubuntu_24_04 PYTHON_VERSION=3 PG_VERSION=17
31 changes: 19 additions & 12 deletions Dockerfile--std.all.tmpl → Dockerfile--std-all.tmpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
FROM postgres:${PG_VERSION}-alpine

ENV PYTHON=python${PYTHON_VERSION}
RUN if [ "${PYTHON_VERSION}" = "2" ] ; then \
apk add --no-cache curl python2 python2-dev build-base musl-dev \
linux-headers py-virtualenv py-pip; \
fi
RUN if [ "${PYTHON_VERSION}" = "3" ] ; then \
apk add --no-cache curl python3 python3-dev build-base musl-dev \
linux-headers py-virtualenv; \
fi
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
FROM postgres:${PG_VERSION}-alpine as base1

# --------------------------------------------- base2_with_python-2
FROM base1 as base2_with_python-2
RUN apk add --no-cache curl python2 python2-dev build-base musl-dev linux-headers py-virtualenv py-pip
ENV PYTHON_VERSION=2

# --------------------------------------------- base2_with_python-3
FROM base1 as base2_with_python-3
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers py-virtualenv
ENV PYTHON_VERSION=3

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

#RUN apk add --no-cache mc

Expand Down Expand Up @@ -57,4 +64,4 @@ ls -la ~/.ssh/; \
sudo /usr/sbin/sshd; \
ssh-keyscan -H localhost >> ~/.ssh/known_hosts; \
ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts; \
TEST_FILTER=\"\" PYTHON_VERSION=${PYTHON_VERSION} bash run_tests.sh;"
TEST_FILTER=\"\" bash run_tests.sh;"
30 changes: 19 additions & 11 deletions Dockerfile--std.tmpl
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
FROM postgres:${PG_VERSION}-alpine
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
FROM postgres:${PG_VERSION}-alpine as base1

# --------------------------------------------- base2_with_python-2
FROM base1 as base2_with_python-2
RUN apk add --no-cache curl python2 python2-dev build-base musl-dev linux-headers py-virtualenv py-pip
ENV PYTHON_VERSION=2

# --------------------------------------------- base2_with_python-3
FROM base1 as base2_with_python-3
RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers py-virtualenv
ENV PYTHON_VERSION=3

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

ENV PYTHON=python${PYTHON_VERSION}
RUN if [ "${PYTHON_VERSION}" = "2" ] ; then \
apk add --no-cache curl python2 python2-dev build-base musl-dev \
linux-headers py-virtualenv py-pip; \
fi
RUN if [ "${PYTHON_VERSION}" = "3" ] ; then \
apk add --no-cache curl python3 python3-dev build-base musl-dev \
linux-headers py-virtualenv; \
fi
ENV LANG=C.UTF-8

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

USER postgres
ENTRYPOINT PYTHON_VERSION=${PYTHON_VERSION} bash run_tests.sh
ENTRYPOINT bash run_tests.sh
41 changes: 27 additions & 14 deletions Dockerfile--ubuntu-24_04.tmpl → 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,38 @@ 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 install -y python3 python3-dev python3-virtualenv libpq-dev
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 +68,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;"
4 changes: 0 additions & 4 deletions docker-compose.yml

This file was deleted.

2 changes: 0 additions & 2 deletions mk_dockerfile.sh

This file was deleted.