Skip to content

Commit

Permalink
Install Python 3.11.9 on base-admin-tools so cqlsh can run (temporali…
Browse files Browse the repository at this point in the history
…o#233)

* Pin Python3 to 3.11 in base-admin-tools

* Install Python 3.11.9 on base-admin-tools so cqlsh can run
  • Loading branch information
ShahabT authored Jul 17, 2024
1 parent 8e237bd commit 5568ddc
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions docker/base-images/base-admin-tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@ ARG BASE_IMAGE=alpine:3.20

FROM ${BASE_IMAGE} AS builder

# Alpine v3.20 comes with Python 3.12. But cqlsh won't work with Python 3.12 until the following issue is resolved.
# https://issues.apache.org/jira/browse/CASSANDRA-19206
# Compiling Python 3.11.9 from source and installing it on the side. Then creating a venv using that python version.
# Revert this change once the issue mentioned above is resolved.
RUN apk add --update --no-cache \
py3-pip \
python3-dev \
musl-dev \
libffi-dev \
gcc

RUN python3 -m venv /opt/venv
gcc \
make \
zlib-dev \
openssl-dev

RUN mkdir -p /opt/python/3.11.9 ; \
cd /opt/python/3.11.9/ ; \
wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz -P . ; \
tar zxvf Python-3.11.9.tgz ; \
cd Python-3.11.9 ; \
./configure --prefix=/opt/python/3.11.9; \
make ; \
make install ; \
make clean ; \
cd .. ; \
rm -rf Python-3.11.9*

RUN cd /opt/python/3.11.9/bin ; ./python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip3 install cqlsh

Expand All @@ -28,6 +45,7 @@ RUN apk add --update --no-cache \
expat \
tini

COPY --from=builder /opt/python/3.11.9 /opt/python/3.11.9
COPY --from=builder /opt/venv /opt/venv

ENV PATH="/opt/venv/bin:$PATH"
Expand Down

0 comments on commit 5568ddc

Please sign in to comment.