-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathubuntu.Dockerfile
More file actions
69 lines (59 loc) · 1.75 KB
/
Copy pathubuntu.Dockerfile
File metadata and controls
69 lines (59 loc) · 1.75 KB
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
# Arguments
ARG BASE_VERSION=latest
ARG PY_VERSION=3.8
# Stage 1: Install Python
FROM ubuntu:${BASE_VERSION} AS py-installer
ARG PY_VERSION
ENV PATH=/usr/local/python${PY_VERSION}/bin:${PATH}
# Install dependencies
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
apt-transport-https \
ca-certificates \
bash \
curl \
build-essential \
libssl-dev \
zlib1g-dev \
libncurses5-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libffi-dev \
libnss3-dev \
libgdbm-dev \
liblzma-dev \
libev-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/tmp/* \
&& rm -rf /tmp/*
COPY ./python.sh /tmp/python.sh
RUN bash /tmp/python.sh --download
RUN bash /tmp/python.sh --install
# Stage 2: Copy results from previous stages
FROM ubuntu:${BASE_VERSION} AS official
ARG PY_VERSION
ENV PATH=/usr/local/python${PY_VERSION}/bin:${PATH}
# Change the default shell
SHELL [ "/bin/bash", "-c" ]
# Install dependencies
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
apt-transport-https \
ca-certificates \
bash \
libc6 \
libsqlite3-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/tmp/* \
&& rm -rf /tmp/*
# Copy files
COPY --from=py-installer /usr/local/python${PY_VERSION} /usr/local/python${PY_VERSION}
# Set environment variables
RUN \
# Set environment variables for Python \
PY_PATH="PATH=/usr/local/python${PY_VERSION}/bin:\${PATH}" && \
echo "export ${PY_PATH}" >> /etc/profile && \
echo "export ${PY_PATH}" >> ~/.bashrc