-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.ci
76 lines (68 loc) · 2.47 KB
/
Dockerfile.ci
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
# Docker image for CI, includes a variety of Python versions
ARG INNOCONV_IMAGE=innodoc/innoconv
FROM $INNOCONV_IMAGE AS innoconv
FROM alpine:3.16
LABEL maintainer="Mirko Dietrich <[email protected]>"
ARG PYTHON_VERSIONS
ENV PYTHON_VERSIONS ${PYTHON_VERSIONS:-3.10.8 3.9.15 3.8.15 3.7.15}
RUN set -xe && \
apk update && \
apk upgrade && \
apk add --no-cache \
bash \
build-base \
bzip2-dev \
cairo \
git \
glib \
libffi \
libffi-dev \
linux-headers \
ncurses-dev \
openssl-dev \
poppler-glib \
readline-dev \
sqlite-dev \
sqlite-libs \
texlive \
texmf-dist \
texmf-dist-latexextra \
texmf-dist-pictures \
zlib-dev
# add user/group to run as
RUN set -xe && \
addgroup -S testuser && \
adduser -S -g testuser testuser
# install Python versions
WORKDIR /home/testuser
USER testuser
RUN set -xe && \
git clone --depth 1 https://github.com/pyenv/pyenv.git ~/.pyenv && \
rm -rf ~/.pyenv/.git && \
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile && \
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile && \
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile && \
bash -c 'set -xe; . ~/.bash_profile; for version in $PYTHON_VERSIONS; do pyenv install $version; done; pyenv global $PYTHON_VERSIONS' && \
find ~/.pyenv/versions -type d -name "test*" -print0 | xargs -0 rm -rf && \
find ~/.pyenv/versions -type d -name "share" -print0 | xargs -0 rm -rf && \
bash -c 'set -xe; for version in $PYTHON_VERSIONS; do chmod +w .pyenv/versions/$version/lib/libpython*.a; strip -s .pyenv/versions/$version/lib/libpython*.a; chmod -w .pyenv/versions/$version/lib/libpython*.a; done;' && \
bash -c 'set -xe; for version in $PYTHON_VERSIONS; do find .pyenv/versions/$version/bin -regex ".*\/python\d\.\d*" -print0 | xargs -0 strip -s; done;' && \
bash -c 'set -xe; . ~/.bash_profile; pyenv rehash; pip3.10 install tox; for version in $PYTHON_VERSIONS; do pyenv local $version; pip install --upgrade pip setuptools; done; pyenv local $PYTHON_VERSIONS'
# copy Pandoc and pdf2svg from main image
USER root
COPY --from=innoconv /usr/local/bin /usr/local/bin
# clean up
RUN set -xe && \
apk del \
ncurses-dev \
bzip2-dev \
readline-dev \
sqlite-dev \
linux-headers && \
rm -rf \
/var/cache/apk/* \
/usr/share/man \
/home/testuser/.cache \
/tmp/*
USER testuser
CMD ["bash"]