Files
iopsyswrt/Dockerfile
Dariusz Iwanoczko 281c748f13 Dockerfile: Switch docker base image to Debian bookworm-slim
Ubuntu delete snapshots after some time what could cause a problems with
use packages with specific versions.

This commit move and adapt the Dockerfile to Debian bookworm-slim.
Advantage of Debian over Ubuntu is that that all package versions are
archived via snapshots.debian.org (which we might move to in a later
commit). Ubuntu has a similar service, but does not retain all versions.

Move coccinelle from Debian archives because the version from Debian
works equally well and is even the same version 1.1.1 in bookworm.

Compile python2.7 from source, because it is no longer supplied in the
repos because it has been EOL for a very long time.

Issue: #17329
2025-10-01 19:19:56 +02:00

104 lines
3.8 KiB
Docker

FROM debian:bookworm-slim as build-git
ARG GIT_DEB_GIT_COMMIT=d7922e98fad107e82e2b11c7defecf9f6d89bfb4 # git 2.45.2
RUN set -x && apt-get -y update && \
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install --no-install-recommends \
devscripts \
git \
equivs \
&& \
git clone https://repo.or.cz/git/debian.git /git-debian && \
git -C /git-debian checkout "$GIT_DEB_GIT_COMMIT" && \
mk-build-deps -i -t 'apt-get -o Debug::pkgProblemResolver=yes -y' /git-debian/debian/control && \
(cd /git-debian && debuild -eDEB_BUILD_OPTIONS="parallel=$(nproc)" -us -uc -b) && \
rm -rf /git-debian
FROM debian:bookworm-slim as build-python2
RUN apt-get -y update && \
apt-get install -y libreadline-dev libbz2-dev libsqlite3-dev libssl-dev build-essential wget && \
rm -rf /var/lib/apt/lists/* && \
wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz && \
tar xf Python-2.7.18.tgz && \
cd Python-2.7.18 && \
./configure --prefix=/usr/local/python2.7 --enable-shared && \
make -j8 && \
make install && \
mkdir -p /usr/local/python2.7/DEBIAN
COPY docker/control-python2.7 /usr/local/python2.7/DEBIAN/control
RUN dpkg-deb --build /usr/local/python2.7 && \
rm -rf /Python-2.7.18.tgz Python-2.7.18
FROM debian:bookworm-slim
COPY --from=build-git /git_*_*.deb /git-man_*_*.deb /tmp/
RUN apt-get -y update && \
apt-get -y install /tmp/git*.deb && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/git*.deb
# Install prerequisites for the "iop" script and iopsys-taas
RUN dpkg --add-architecture i386 && \
apt-get -y update && \
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install \
locales \
sudo \
wget \
expect \
socat \
curl \
gnupg \
sshpass \
trickle \
python3-mako \
python3-yaml && \
rm -rf /var/lib/apt/lists/*
# Set the same PATH varialbe for root and non-root users
RUN echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\" && export PATH" >> /etc/profile
# Install Node.js
ARG NODEJS_VERSION_MAJOR=20
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODEJS_VERSION_MAJOR}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get -y update && \
apt-get install -y nodejs && \
npm install --global typescript yarn && \
rm -rf /var/lib/apt/lists/*
# 1. Create new unprivileged user "dev"
# 2. Install fixuid to accomodate for the host machine UID/GID
ARG FIXUID_VERSION=0.5.1
RUN useradd -m -s /bin/bash dev && \
curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v${FIXUID_VERSION}/fixuid-${FIXUID_VERSION}-linux-amd64.tar.gz" | tar -C /usr/local/bin -xzf -
# Copy fixuid configuration
COPY docker/fixuid.yml /etc/fixuid/config.yml
# Copy git configuration to dev's home folder
COPY --chown=dev:dev docker/gitconfig /home/dev/.gitconfig
# Install python2
COPY --from=build-python2 /usr/local/python2.7.deb /tmp/
RUN dpkg -i /tmp/python2.7.deb
# Run "iop setup_host" inside image to install necessary SDK dependencies
COPY iop /
RUN echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections && \
ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
yes | /iop setup_host && \
rm /iop && \
rm -rf /var/lib/apt/lists/*
RUN echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/10-dev
ENTRYPOINT ["/usr/local/bin/fixuid", "-q"]
CMD ["bash"]
RUN mkdir -p /home/dev/iopsyswrt /home/dev/.ssh \
&& chown -R dev:dev /home/dev
USER dev:dev
WORKDIR /home/dev/iopsyswrt
VOLUME ["/home/dev/iopsyswrt"]