Files
RoleForge/dockerfiles/alt9/Dockerfile
2026-05-06 09:00:59 +03:00

108 lines
4.0 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ALT Linux 9 (Platform 9) с systemd
# Автор: Сергей Антропов
# Сайт: https://devops.org.ru
# https://hub.docker.com/_/alt/tags
# Тег: inecs/ansible-lab:alt9-latest
FROM alt:p9
ENV container=docker
ENV DEBIAN_FRONTEND=noninteractive
# Обновляем систему (зеркала ALT иногда отдают RPM с MD5 mismatch — повтор с чистым кешем).
RUN set -eux; \
dist_ok=0; \
for attempt in 1 2 3 4 5; do \
mkdir -p /var/lib/apt/lists/partial; \
apt-get clean || true; \
rm -rf /var/lib/apt/lists/*; \
if apt-get -o Acquire::Retries=5 update \
&& apt-get -o Acquire::Retries=5 dist-upgrade -y --fix-missing; then \
dist_ok=1; \
break; \
fi; \
echo "dist-upgrade attempt ${attempt} failed, retrying in 15s..."; \
sleep 15; \
done; \
mkdir -p /var/lib/apt/lists/partial; \
apt-get clean || true; \
rm -rf /var/lib/apt/lists/*; \
test "$dist_ok" -eq 1
# Устанавливаем systemd и необходимые пакеты (ALT mirrors may be briefly inconsistent; retry with fresh indexes)
RUN set -eux; \
for attempt in 1 2 3 4; do \
mkdir -p /var/lib/apt/lists/partial; \
apt-get update && \
apt-get install -y --fix-missing \
systemd \
dbus \
curl \
wget \
nano \
sudo \
gcc \
gcc-c++ \
make \
zlib-devel \
openssl-devel \
libffi-devel \
sqlite-devel \
ca-certificates \
tar \
gzip \
&& break; \
echo "apt install attempt ${attempt} failed, retrying in 8s..."; \
mkdir -p /var/lib/apt/lists/partial; \
apt-get clean || true; \
rm -rf /var/lib/apt/lists/*; \
sleep 8; \
done; \
mkdir -p /var/lib/apt/lists/partial; \
apt-get clean || true; \
rm -rf /var/lib/apt/lists/*
# Ansible 2.14+ требует Python 3.9+ на цели — на ALT p9 базовый python3 может быть 3.7.
# curl/ca-certificates ставятся в предыдущем RUN; здесь не вызываем apt-get — после rm -rf /var/lib/apt/lists/*
# слой apt «пустой» и apt-get update падает (нет /var/lib/apt/lists/partial).
RUN curl -fsSL -o /tmp/Python-3.11.9.tgz https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz \
&& tar xzf /tmp/Python-3.11.9.tgz -C /tmp \
&& rm -f /tmp/Python-3.11.9.tgz \
&& cd /tmp/Python-3.11.9 \
&& ./configure --prefix=/usr/local --with-ensurepip=install \
&& make -j "$(nproc)" \
&& make install \
&& update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 1 \
&& python3 -m pip install --upgrade pip setuptools wheel \
&& python3 -c "import sys; assert sys.version_info[:2] >= (3, 9), sys.version"
# Устанавливаем yq
# RUN wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_arm64 \
# && chmod +x /usr/local/bin/yq
# Устанавливаем Docker вручную для ALT Linux
# RUN apt-get update && apt-get install -y \
# ca-certificates \
# curl \
# gnupg \
# && apt-get clean
# Устанавливаем Docker Compose
# RUN curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
# && chmod +x /usr/local/bin/docker-compose
# Настраиваем systemd
RUN systemctl set-default multi-user.target
# Настраиваем sudoers для root и пользователей
RUN echo "root ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
echo "ALL ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ansible-test
# Создаем пользователя для Ansible
RUN useradd -m -s /bin/bash ansible \
&& echo "ansible ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Команда по умолчанию (система запускается от root для systemd)
STOPSIGNAL SIGRTMIN+3
VOLUME ["/sys/fs/cgroup"]
CMD ["/sbin/init"]