Files
shell/shell-setup/Dockerfile
Peter Wood 52492f9218 Add Docker test scripts for setup validation
- Created run-docker-tests.sh to execute setup tests in isolated Docker containers (Ubuntu and Debian).
- Implemented logging functionality to track test results and errors.
- Added startup.sh to ensure proper permissions and run tests within Docker containers.
- Developed test-setup.sh to validate bootstrap.sh and setup.sh scripts, including package availability checks.
- Enhanced error handling and reporting for package installations and missing dependencies.
- Included detailed logging for system information and test results.
2025-05-12 14:16:03 -04:00

81 lines
3.0 KiB
Docker

# Dockerfile to test bootstrap.sh and setup.sh scripts in different environments
# This allows testing the setup process in isolated containers
# Ubuntu test environment
FROM ubuntu:24.04 as ubuntu-test
LABEL description="Ubuntu test environment for shell setup scripts"
# Install minimal dependencies needed to run the test
ENV TZ=America/New_York
ENV DEBIAN_FRONTEND=noninteractive
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& apt-get update && apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -y curl git sudo wget
# Pre-install cowsay and lolcat packages for testing
RUN apt-get update && apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -y cowsay lolcat
# Create logs directory with proper permissions
RUN mkdir -p /logs && chmod -R 777 /logs
# Create a test user with sudo permissions
RUN useradd -ms /bin/bash testuser && \
echo "testuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/testuser
USER testuser
WORKDIR /home/testuser
# Create directory structure for shell setup
RUN mkdir -p /home/testuser/shell/setup
# Copy test script, startup script, and packages.list
COPY --chown=testuser:testuser test-setup.sh /home/testuser/
COPY --chown=testuser:testuser startup.sh /home/testuser/
COPY --chown=testuser:testuser setup/packages.list /home/testuser/shell/setup/
# Make scripts executable
RUN chmod +x /home/testuser/test-setup.sh
RUN chmod +x /home/testuser/startup.sh
CMD ["/bin/bash", "-c", "./startup.sh"]
# Debian test environment
FROM debian:12 as debian-test
LABEL description="Debian test environment for shell setup scripts"
# Install minimal dependencies needed to run the test
ENV TZ=America/New_York
ENV DEBIAN_FRONTEND=noninteractive
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& apt-get update && apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -y curl git sudo wget
# Pre-install cowsay and lolcat packages for testing
RUN apt-get update && apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" -y cowsay lolcat
# Create logs directory with proper permissions
RUN mkdir -p /logs && chmod -R 777 /logs
# Create a test user with sudo permissions
RUN useradd -ms /bin/bash testuser && \
echo "testuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/testuser
USER testuser
WORKDIR /home/testuser
# Create directory structure for shell setup
RUN mkdir -p /home/testuser/shell/setup
# Copy test script, startup script, and packages.list
COPY --chown=testuser:testuser test-setup.sh /home/testuser/
COPY --chown=testuser:testuser startup.sh /home/testuser/
COPY --chown=testuser:testuser setup/packages.list /home/testuser/shell/setup/
# Make scripts executable
RUN chmod +x /home/testuser/test-setup.sh
RUN chmod +x /home/testuser/startup.sh
CMD ["/bin/bash", "-c", "./startup.sh"]