Skip to content

Commit

Permalink
Simpler cqlsh installation in base-admin-tools image (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigozhou authored Feb 14, 2025
1 parent 973b5b1 commit fc07f33
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions docker/base-images/base-admin-tools.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,21 @@ ARG BASE_IMAGE=alpine:3.21

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.
# These are necessary to install cqlsh
RUN apk add --update --no-cache \
python3-dev \
musl-dev \
libffi-dev \
libev-dev \
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
pipx

RUN pipx install --global cqlsh

FROM ${BASE_IMAGE} AS base-admin-tools

RUN apk add --update --no-cache \
python3 \
libev \
ca-certificates \
tzdata \
bash \
Expand All @@ -41,16 +25,13 @@ RUN apk add --update --no-cache \
yq \
mysql-client \
postgresql-client \
py3-pip \
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"
COPY --from=builder /opt/pipx/venvs/cqlsh /opt/pipx/venvs/cqlsh
RUN ln -s /opt/pipx/venvs/cqlsh/bin/cqlsh /usr/local/bin/cqlsh

# validate installation
# validate cqlsh installation
RUN cqlsh --version

SHELL ["/bin/bash", "-c"]

0 comments on commit fc07f33

Please # to comment.