-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathDockerfile.testing
154 lines (120 loc) · 4.43 KB
/
Dockerfile.testing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# vim: set ft=dockerfile:
# Best to compile and test as non-root
ARG nonroot_uid=3973
##------------------------------------------------------------------------------
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 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
##------------------------------------------------------------------------------
FROM base AS builder-base
RUN mkdir /usr/local/openssl11 \
&& cd /usr/local/openssl11 \
&& ln -s /usr/lib64/openssl11 lib \
&& ln -s /usr/include/openssl11 include
RUN mkdir /src
##------------------------------------------------------------------------------
FROM builder-base AS builder-py39
ARG py_ver=39
ARG nonroot_uid
COPY --from=py39 /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} --enable-optimizations \
&& make -j 4 altinstall
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} --enable-optimizations \
&& make -j 4 altinstall
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 base AS csdk
ARG nonroot_uid
COPY --chown=${nonroot_uid} \
--from=ibmcom/informix-developer-sandbox@sha256:678250715879a7cbdd2ea658ff7ecd7087dcaf0b8e39d47c936916edff62c5ec \
/home/informix/odbc/ /opt/IBM/informix/
##------------------------------------------------------------------------------
FROM csdk AS multipy
ARG nonroot_uid
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
ADD --chown=${nonroot_uid} README.rst setup.* tox.ini /src/
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:"${PATH}"
RUN pip3 --no-cache-dir install tox
USER ${nonroot_uid}
ENV HOME=/src
WORKDIR /src