Skip to content

Commit

Permalink
fix: deps installation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-stoian-zama committed Nov 20, 2024
1 parent 1bacb07 commit 744df04
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 34 deletions.
17 changes: 6 additions & 11 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# original archive showed performance issues and is farther away
RUN sed -i 's|^deb http://archive|deb http://fr.archive|g' /etc/apt/sources.list

COPY ./script/make_utils/setup_os_deps.sh ./setup_os_deps.sh
COPY ./script/make_utils/detect_docker.sh ./detect_docker.sh
RUN ./setup_os_deps.sh --linux-install-python && rm ./setup_os_deps.sh && rm ./detect_docker.sh

ENV SRC_DIR=/src

# Default to Ubuntu default uid for first user
Expand All @@ -20,7 +16,7 @@ ARG BUILD_UID=1000

# Get sudo and vim for our future user
RUN apt-get update && \
apt-get install --no-install-recommends -y sudo vim && \
apt-get install --no-install-recommends -y sudo vim adduser && \
rm -rf /var/lib/apt/lists/*

# For ubuntu>23 the ubuntu user will exist and use uid/gid=1000
Expand All @@ -41,15 +37,14 @@ RUN groupadd -f -g "${BUILD_GID}" dev_user && \
chown dev_user "${SRC_DIR}" && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

RUN groupadd docker && usermod -aG docker dev_user

# Now switch to the newly created user
USER dev_user

RUN (pipx install poetry && pipx ensurepath) || \
(\
python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir --ignore-installed poetry==1.7.1 && \
echo 'PATH=$PATH:/home/dev_user/.local/bin/' >> ~/.bashrc \
)
COPY ./script/make_utils/setup_os_deps.sh ./setup_os_deps.sh
COPY ./script/make_utils/detect_docker.sh ./detect_docker.sh
RUN ./setup_os_deps.sh --linux-install-python && sudo rm ./setup_os_deps.sh && sudo rm ./detect_docker.sh

RUN echo "source ~/dev_venv/bin/activate" >> ~/.bashrc && \
echo "if [[ \"\$?\" != \"0\" ]]; then" >> ~/.bashrc && \
Expand Down
40 changes: 17 additions & 23 deletions script/make_utils/setup_os_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,12 @@ OS_NAME=$(uname)

if [[ "${OS_NAME}" == "Linux" ]]; then
# Docker build
if isDockerBuildkit || (isDocker && ! isDockerContainer); then
CLEAR_APT_LISTS="rm -rf /var/lib/apt/lists/* &&"
SUDO_BIN=""
else
CLEAR_APT_LISTS=""
SUDO_BIN="$(command -v sudo)"
if [[ "${SUDO_BIN}" != "" ]]; then
SUDO_BIN="${SUDO_BIN} "
fi
CLEAR_APT_LISTS=""
SUDO_BIN="$(command -v sudo)"
if [[ "${SUDO_BIN}" != "" ]]; then
SUDO_BIN="${SUDO_BIN} "
fi

PYTHON_PACKAGES=
if [[ "${LINUX_INSTALL_PYTHON}" == "1" ]]; then
PYTHON_PACKAGES="python3-pip \
Expand All @@ -119,7 +114,8 @@ if [[ "${OS_NAME}" == "Linux" ]]; then
then
SETUP_CMD="linux_install_actionlint"
else
SETUP_CMD="${SUDO_BIN:+$SUDO_BIN}apt-get update && apt-get upgrade --no-install-recommends -y && \
SETUP_CMD="${SUDO_BIN:+$SUDO_BIN}apt-get update && \
${SUDO_BIN:+$SUDO_BIN}apt-get upgrade --no-install-recommends -y && \
${SUDO_BIN:+$SUDO_BIN}apt-get install --no-install-recommends -y \
build-essential \
curl \
Expand All @@ -136,22 +132,20 @@ if [[ "${OS_NAME}" == "Linux" ]]; then
openssl \
shellcheck \
texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-xetex lmodern \
wget pipx adduser &&
wget pipx &&
${CLEAR_APT_LISTS:+$CLEAR_APT_LISTS} \
linux_install_gitleaks && linux_install_actionlint && linux_install_github_cli"
${SUDO_BIN:+$SUDO_BIN} linux_install_gitleaks && \
${SUDO_BIN:+$SUDO_BIN} linux_install_actionlint && \
${SUDO_BIN:+$SUDO_BIN} linux_install_github_cli"
fi
eval "${SETUP_CMD}"

# If this is a CI build, install poetry (installs as root)
# if not, the Dockerfile installs poetry for docker builds (under dev_user)
if !isDockerBuildkit; then
(pipx install poetry && pipx ensurepath) || \
(\
python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir --ignore-installed poetry==1.7.1 && \
echo 'PATH=$PATH:/home/dev_user/.local/bin/' >> ~/.bashrc \
)
fi
(pipx install poetry && pipx ensurepath) || \
(\
python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir --ignore-installed poetry==1.7.1 \
);
echo 'PATH=$PATH:/home/dev_user/.local/bin/' >> ~/.bashrc
elif [[ "${OS_NAME}" == "Darwin" ]]; then

# Some problems with the git which is preinstalled on AWS virtual machines. Let's unlink it
Expand Down

0 comments on commit 744df04

Please sign in to comment.