Skip to content

Commit

Permalink
change test to use rocky9
Browse files Browse the repository at this point in the history
  • Loading branch information
fransy26 committed Nov 28, 2023
1 parent 69f6ec4 commit 87db79f
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 152 deletions.
181 changes: 33 additions & 148 deletions Dockerfile.testing
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,46 @@
# Best to compile and test as non-root
ARG nonroot_uid=3973

##------------------------------------------------------------------------------
FROM python:3.7 AS py37

RUN echo "${PYTHON_VERSION}" > /tmp/py37-latest

##------------------------------------------------------------------------------
FROM python:3.8 AS py38

RUN echo "${PYTHON_VERSION}" > /tmp/py38-latest

##------------------------------------------------------------------------------
FROM python:3.9 AS py39

RUN echo "${PYTHON_VERSION}" > /tmp/py39-latest

##------------------------------------------------------------------------------
FROM python:3.10 AS py310

RUN echo "${PYTHON_VERSION}" > /tmp/py310-latest

##------------------------------------------------------------------------------
FROM centos:7 AS base

# EPEL needed for openssl 1.1.x
RUN yum clean all \
&& yum update -y \
&& yum install -y \
epel-release \
nmap-ncat \
unixODBC \
&& yum clean all \
&& rm -rf /var/yum/cache
FROM rockylinux:9 AS base

RUN dnf makecache \
&& dnf update -y \
&& dnf install -y --allowerasing \
curl \
dnf-plugins-core \
&& dnf config-manager --set-enabled crb \
&& dnf install -y \
bzip2-devel \
findutils \
gcc \
gcc-c++ \
git \
libffi-devel \
make \
openssl-devel \
python-devel \
python3-pip \
wget \
xz \
zlib-devel \
sqlite-devel \
unixODBC-devel \
nc \
&& dnf clean all

RUN pip3 install --no-cache-dir \
tox

##------------------------------------------------------------------------------
FROM base AS builder-base

RUN yum install -y \
make \
yum-utils

RUN yum-builddep -y python3

# For pyodbc
RUN yum install -y \
unixODBC-devel

# Python >= 3.10 needs openssl 1.1.x
RUN yum install -y \
openssl11-devel

RUN mkdir /usr/local/openssl11 \
&& cd /usr/local/openssl11 \
Expand All @@ -60,72 +51,8 @@ RUN mkdir /usr/local/openssl11 \

RUN mkdir /src

##------------------------------------------------------------------------------
FROM builder-base AS builder-py37
ARG py_ver=37
ARG nonroot_uid
COPY --from=py37 /tmp/py${py_ver}-latest /tmp/

RUN mkdir /opt/py${py_ver} && chown -R ${nonroot_uid} /opt/py${py_ver} /src
USER ${nonroot_uid}
WORKDIR /tmp

RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
&& curl --silent --show-error --fail --location \
"https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" \
| tar -xz

RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
&& cd "/tmp/Python-${PYTHON_VERSION}" \
&& ./configure --prefix=/opt/py${py_ver} --with-openssl=/usr/local/openssl11 \
&& make install

USER root
ENV PATH=/opt/py${py_ver}/bin:"${PATH}"
RUN pip3 install tox
USER ${nonroot_uid}

ENV HOME=/src
ENV PATH=/opt/py${py_ver}/bin:"${PATH}"
WORKDIR /src

ADD django_informixdb/ /src/django_informixdb/
ADD README.rst setup.* tox.ini /src/
RUN tox -e "$(tox --listenvs | grep py${py_ver} | tr '\n' ',')" --notest # prep venvs

##------------------------------------------------------------------------------
FROM builder-base AS builder-py38
ARG py_ver=38
ARG nonroot_uid
COPY --from=py38 /tmp/py${py_ver}-latest /tmp/

RUN mkdir /opt/py${py_ver} && chown -R ${nonroot_uid} /opt/py${py_ver} /src
USER ${nonroot_uid}
WORKDIR /tmp

RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
&& curl --silent --show-error --fail --location \
"https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" \
| tar -xz

RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
&& cd "/tmp/Python-${PYTHON_VERSION}" \
&& ./configure --prefix=/opt/py${py_ver} --with-openssl=/usr/local/openssl11 \
&& make install

USER root
ENV PATH=/opt/py${py_ver}/bin:"${PATH}"
RUN pip3 install tox
USER ${nonroot_uid}

ENV HOME=/src
ENV PATH=/opt/py${py_ver}/bin:"${PATH}"
WORKDIR /src

ADD django_informixdb/ /src/django_informixdb/
ADD README.rst setup.* tox.ini /src/
RUN tox -e "$(tox --listenvs | grep py${py_ver} | tr '\n' ',')" --notest # prep venvs

##------------------------------------------------------------------------------
FROM builder-base AS builder-py39
ARG py_ver=39
Expand All @@ -141,43 +68,11 @@ RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
"https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" \
| tar -xz

RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
&& cd "/tmp/Python-${PYTHON_VERSION}" \
&& ./configure --prefix=/opt/py${py_ver} --with-openssl=/usr/local/openssl11 \
&& make install

USER root
ENV PATH=/opt/py${py_ver}/bin:"${PATH}"
RUN pip3 install tox
USER ${nonroot_uid}

ENV HOME=/src
ENV PATH=/opt/py${py_ver}/bin:"${PATH}"
WORKDIR /src

ADD django_informixdb/ /src/django_informixdb/
ADD README.rst setup.* tox.ini /src/
RUN tox -e "$(tox --listenvs | grep py${py_ver} | tr '\n' ',')" --notest # prep venvs

##------------------------------------------------------------------------------
FROM builder-base AS builder-py310
ARG py_ver=310
ARG nonroot_uid
COPY --from=py310 /tmp/py${py_ver}-latest /tmp/

RUN mkdir /opt/py${py_ver} && chown -R ${nonroot_uid} /opt/py${py_ver} /src
USER ${nonroot_uid}
WORKDIR /tmp

RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
&& curl --silent --show-error --fail --location \
"https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" \
| tar -xz

RUN export PYTHON_VERSION="$(cat /tmp/py${py_ver}-latest)" \
&& cd "/tmp/Python-${PYTHON_VERSION}" \
&& ./configure --prefix=/opt/py${py_ver} --with-openssl=/usr/local/openssl11 \
&& make install
&& ./configure --prefix=/opt/py${py_ver} --enable-optimizations \
&& make -j 4 altinstall

USER root
ENV PATH=/opt/py${py_ver}/bin:"${PATH}"
Expand All @@ -192,6 +87,7 @@ ADD django_informixdb/ /src/django_informixdb/
ADD README.rst setup.* tox.ini /src/
RUN tox -e "$(tox --listenvs | grep py${py_ver} | tr '\n' ',')" --notest # prep venvs


##------------------------------------------------------------------------------
FROM base AS csdk
ARG nonroot_uid
Expand All @@ -204,21 +100,10 @@ COPY --chown=${nonroot_uid} \
FROM csdk AS multipy
ARG nonroot_uid

COPY --from=builder-py37 /opt/py37/ /opt/py37/
COPY --from=builder-py37 /src/.tox/ /src/.tox/
COPY --from=builder-py37 /src/.cache/ /src/.cache/

COPY --from=builder-py38 /opt/py38/ /opt/py38/
COPY --from=builder-py38 /src/.tox/ /src/.tox/
COPY --from=builder-py38 /src/.cache/ /src/.cache/

COPY --from=builder-py39 /opt/py39/ /opt/py39/
COPY --from=builder-py39 /src/.tox/ /src/.tox/
COPY --from=builder-py39 /src/.cache/ /src/.cache/

COPY --from=builder-py310 /opt/py310/ /opt/py310/
COPY --from=builder-py310 /src/.tox/ /src/.tox/
COPY --from=builder-py310 /src/.cache/ /src/.cache/

ADD wait-for-deps.sh /usr/local/bin
RUN chmod a+rx /usr/local/bin/wait-for-deps.sh
Expand All @@ -228,7 +113,7 @@ ADD --chown=${nonroot_uid} django_informixdb/ /src/django_informixdb/
ADD --chown=${nonroot_uid} test/ /src/test/
RUN chown ${nonroot_uid} /src

ENV PATH=/opt/py310/bin:/opt/py39/bin:/opt/py38/bin:/opt/py37/bin:"${PATH}"
ENV PATH=/opt/py39/bin:"${PATH}"
RUN pip3 --no-cache-dir install tox

USER ${nonroot_uid}
Expand Down
Loading

0 comments on commit 87db79f

Please sign in to comment.