Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installs python version for UsePythonVersion (#17) #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes

# Default available python version to install
# This always downloads the latest available patch version
# Keep it empty for default behaviour
ARG PYTHON_AVAILABLE_VERSION_VERSIONS="3.10 3.11"

RUN apt-get update && apt-get install -y --no-install-recommends \
apt-transport-https \
apt-utils \
Expand All @@ -16,12 +21,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
jq \
lsb-release \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get -y upgrade

RUN curl -LsS https://aka.ms/InstallAzureCLIDeb | bash \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*

RUN az extension add --name azure-devops

Expand All @@ -30,6 +35,11 @@ ENV TARGETARCH=linux-x64

WORKDIR /azp

COPY ./pre-install.sh .
RUN chmod +x pre-install.sh && \
./pre-install.sh && \
rm ./pre-install.sh

RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
unzip \
Expand Down Expand Up @@ -58,8 +68,8 @@ RUN apt-get update \
#install docker cli
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update \
&& apt-get install -y docker-ce-cli

Expand All @@ -86,4 +96,4 @@ RUN sudo groupadd docker
RUN sudo usermod -aG docker azuredevops
RUN sudo newgrp docker

ENTRYPOINT ["./start.sh"]
ENTRYPOINT ["./start.sh"]
31 changes: 31 additions & 0 deletions src/pre-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

AGENT_TOOLSDIRECTORY="/azp/_work/_tool"

# Adding ppa to fetch old python versions
add-apt-repository ppa:deadsnakes/ppa

echo "Available python version to install: $PYTHON_AVAILABLE_VERSION_VERSIONS"
for py in $PYTHON_AVAILABLE_VERSION_VERSIONS
do
echo "--------------------------------------------------------"
apt install -qq -y python$py-dev python$py-venv

PYTHON_VERSION=$(python$py -V | cut -d " " -f2)
mkdir -p $AGENT_TOOLSDIRECTORY/Python/$PYTHON_VERSION
if [[ $? == 1 ]]; then echo "Failed created python $py version folder";exit 1;fi

cd $AGENT_TOOLSDIRECTORY/Python/$PYTHON_VERSION
python$py -m venv x64
touch x64.complete
cd x64
mkdir -p share
ln -s bin/python$py python
cd ..
cd ..

ln -s $PYTHON_VERSION $py
echo "Available versions:"
tree -L 1
done