Skip to content

Commit 90e4f6d

Browse files
committed
Docker Base: Setup vim for all python vesions
1 parent 592cdb2 commit 90e4f6d

File tree

2 files changed

+46
-21
lines changed

2 files changed

+46
-21
lines changed

.github/workflows/build_base_image.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
build-and-push-base:
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
pyver: ["3.10.13", "3.11.9", "3.12.4", "3.13.0"]
1417
permissions:
1518
contents: read
1619
packages: write
@@ -33,11 +36,18 @@ jobs:
3336
run: |
3437
echo "REPO=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
3538
39+
- name: Extract short Python version
40+
id: pyver_short
41+
run: |
42+
echo "PYVER_SHORT=$(echo ${{ matrix.pyver }} | cut -d'.' -f1,2)" >> $GITHUB_OUTPUT
43+
3644
- name: Build and push base image
3745
uses: docker/build-push-action@v5
3846
with:
3947
context: .
4048
file: Dockerfile.base
4149
push: true
50+
build-args: |
51+
PYTHON_VERSION=${{ matrix.pyver }}
4252
tags: |
43-
ghcr.io/${{ steps.repo.outputs.REPO }}-base:latest
53+
ghcr.io/${{ steps.repo.outputs.REPO }}-base:${{ steps.pyver_short.outputs.PYVER_SHORT }}-latest

Dockerfile.base

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ ENV DEBIAN_FRONTEND=noninteractive
44
ENV PYTHON_CONFIGURE_OPTS="--enable-shared"
55
ENV PYENV_ROOT="/opt/pyenv"
66
ENV PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
7+
ARG PYTHON_VERSION=3.13.0
8+
ENV PYTHON_VERSION=${PYTHON_VERSION}
79

810
# Install system dependencies for pyenv and Python builds
11+
# TODO: Remove GUI dependencies
912
RUN apt-get update && apt-get install -yqq \
1013
libncurses5-dev \
1114
libgtk2.0-dev \
@@ -32,30 +35,42 @@ RUN apt-get update && apt-get install -yqq \
3235
&& rm -rf /var/lib/apt/lists/*
3336

3437
# Remove existing vim packages
35-
RUN apt-get remove --purge -yqq vim vim-runtime gvim || true
38+
RUN apt-get remove --purge -yqq vim vim-runtime gvim 2>&1 > /dev/null || true
3639

3740
# Install pyenv
38-
RUN git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT && \
41+
RUN git clone --depth 1 https://github.com/pyenv/pyenv.git $PYENV_ROOT && \
3942
cd $PYENV_ROOT && \
40-
git checkout $(git describe --tags --abbrev=0)
43+
git checkout $(git describe --tags --abbrev=0) && \
44+
eval "$(pyenv init -)" && \
45+
eval "$(pyenv init --path)"
4146

42-
# Install Python versions with pyenv
43-
RUN pyenv install 3.10.13 && \
44-
pyenv install 3.11.9 && \
45-
pyenv install 3.12.4 && \
46-
pyenv install 3.13.0
47+
# Set up bash profile for pyenv
48+
RUN echo 'export PYENV_ROOT="/opt/pyenv"' >> /root/.bashrc && \
49+
echo 'export PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:$PATH"' >> /root/.bashrc && \
50+
echo 'eval "$(pyenv init -)"' >> /root/.bashrc && \
51+
echo 'eval "$(pyenv init --path)"' >> /root/.bashrc && \
52+
echo 'alias python=python3' >> /root/.bashrc
4753

48-
ARG PYTHON_VERSION=3.10.13
49-
ENV PYTHON_VERSION=${PYTHON_VERSION}
50-
RUN pyenv global ${PYTHON_VERSION}
51-
52-
# Create virtual environment
53-
RUN python -m venv /opt/venv
54-
ENV PATH="/opt/venv/bin:$PATH"
55-
ENV VIRTUAL_ENV="/opt/venv"
54+
# Install Python versions with pyenv
55+
RUN pyenv install ${PYTHON_VERSION} && \
56+
pyenv global ${PYTHON_VERSION} && \
57+
rm -rf /tmp/python-build*
5658

57-
# Upgrade pip in the virtual environment
58-
RUN pip install --upgrade pip setuptools wheel
59+
# Upgrade pip and add some other dependencies
60+
RUN eval "$(pyenv init -)" && \
61+
echo "Upgrading pip for Python ($(python --version): $(which python))..." && \
62+
pip install --upgrade pip setuptools wheel && \
63+
## Python-mode dependency
64+
pip install pytoolconfig
5965

60-
# Dependency to load some modules within pyton-mode
61-
RUN pip install pytoolconfig
66+
# Build and install Vim from source with Python support for each Python version
67+
RUN cd /tmp && \
68+
git clone --depth 1 https://github.com/vim/vim.git && \
69+
cd vim && \
70+
# Build Vim for each Python version
71+
echo "Building Vim with python support: Python ($(python --version): $(which python))..." && \
72+
make clean || true && \
73+
./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=$(python-config --configdir) --enable-perlinterp=yes --enable-luainterp=yes --enable-cscope --prefix=/usr/local --exec-prefix=/usr/local && \
74+
make && \
75+
make install && \
76+
echo "Vim for Python $pyver installed as vim"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy