-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
110 lines (88 loc) · 3.3 KB
/
Dockerfile
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
FROM ubuntu:20.04 as builder
# Locale
ENV LC_ALL C
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
# ensure any pipes fail correctly, may impact other things
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# work in an area that will get discarded
WORKDIR /tmp/build
# Prevent interactive options during installs
ENV DEBIAN_FRONTEND=noninteractive
# apt stuff
# hadolint ignore=DL3008
RUN apt-get -yq update \
&& apt-get -yq install --no-install-recommends software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get -yq install --no-install-recommends python3.9 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
# not in final image
# hadolint ignore=DL3008
RUN apt-get -yq update \
&& apt-get -yq install --no-install-recommends \
build-essential \
python3.9-dev \
python3.9-distutils \
python3.9-venv \
curl \
zlib1g-dev \
libbz2-dev \
liblzma-dev \
libcurl4-openssl-dev \
libmagic-dev \
&& curl -sSL --retry 10 https://bootstrap.pypa.io/get-pip.py > get-pip.py \
&& python3.9 get-pip.py
# base environment
ENV OPT /opt/wsi-t78
ENV VIRTUAL_ENV=$OPT/venv
RUN python3.9 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --no-cache-dir --upgrade pip==21.3.1 && pip install --no-cache-dir Cython==0.29.24
COPY pycroquet/ pycroquet/
COPY README.md setup.py requirements.txt requirements-dev.txt ./
RUN pip install --no-cache-dir -r requirements-dev.txt
COPY tests/ tests/
COPY .coveragerc .
RUN python3.9 ./setup.py develop && tests/scripts/run_unit_tests.sh
# generate the coverage report (and junit.xml) in for info and later use
RUN mkdir -p /var/www/pycroquet && mv htmlcov /var/www/pycroquet/test-coverage && mv junit.xml /var/www/pycroquet/.
# as we use COPY we can cleanup stuff from the testing layers and actually get a smaller image
RUN comm -13 <(sort requirements.txt) <(sort requirements-dev.txt) | xargs pip uninstall -y
# deploy properly
RUN python3.9 ./setup.py install \
# make sure permissions are correct
&& find $OPT -type d -exec chmod o+rx {} \; \
&& find $OPT -type f -exec chmod o+r {} \;
########################## FINAL IMAGE ##########################
FROM ubuntu:20.04
# Locale
ENV LC_ALL C
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
# Prevent interactive options during installs
ENV DEBIAN_FRONTEND=noninteractive
# apt stuff
# hadolint ignore=DL3008
RUN apt-get -yq update \
&& apt-get -yq install --no-install-recommends software-properties-common libmagic-dev zlib1g curl \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get -yq install --no-install-recommends python3.9 \
# make sure all security patches are applied
&& apt-get -yq update && apt-get install -yq --no-install-recommends unattended-upgrades \
&& unattended-upgrade -d -v \
&& apt-get remove -yq unattended-upgrades \
&& apt-get autoremove -yq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
ENV OPT /opt/wsi-t78
ENV VIRTUAL_ENV=$OPT/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY --from=builder $OPT $OPT
# the test coverate html output - we can grab and pass to gitlab-pages
COPY --from=builder /var/www/ /var/www/
RUN adduser --disabled-password --gecos '' ubuntu && chsh -s /bin/bash && mkdir -p /home/ubuntu
USER ubuntu
RUN pycroquet --version
WORKDIR /home/ubuntu
CMD ["/bin/bash"]