|
| 1 | +# codespaces_create_and_start_containers.Dockerfile |
| 2 | + |
| 3 | +FROM ubuntu:latest |
| 4 | + |
| 5 | +ENV DEBIAN_FRONTEND=noninteractive |
| 6 | + |
| 7 | +# Use the TIMEZONE variable to configure the timezone |
| 8 | +ENV TIMEZONE=Etc/UTC |
| 9 | +RUN ln -fs /usr/share/zoneinfo/$TIMEZONE /etc/localtime && echo $TIMEZONE > /etc/timezone |
| 10 | + |
| 11 | +# Update package list and install dependencies in one line |
| 12 | +RUN apt-get update && apt-get install -y \ |
| 13 | + software-properties-common \ |
| 14 | + openssh-server \ |
| 15 | + sudo \ |
| 16 | + python3 \ |
| 17 | + python3-venv \ |
| 18 | + python3-setuptools \ |
| 19 | + python3-wheel \ |
| 20 | + python3-apt \ |
| 21 | + passwd \ |
| 22 | + tzdata \ |
| 23 | + iproute2 \ |
| 24 | + wget \ |
| 25 | + cron \ |
| 26 | + --no-install-recommends && \ |
| 27 | + add-apt-repository ppa:deadsnakes/ppa -y && \ |
| 28 | + apt-get update && apt-get install -y \ |
| 29 | + python3.11 \ |
| 30 | + python3.11-venv \ |
| 31 | + python3.11-distutils \ |
| 32 | + python3.11-dev && \ |
| 33 | + dpkg-reconfigure --frontend noninteractive tzdata && \ |
| 34 | + apt-get clean && \ |
| 35 | + rm -rf /var/lib/apt/lists/* |
| 36 | + |
| 37 | +# Install pip using get-pip.py |
| 38 | +RUN wget https://bootstrap.pypa.io/get-pip.py && python3.11 get-pip.py && rm get-pip.py |
| 39 | + |
| 40 | +# Install required Python packages |
| 41 | +RUN python3.11 -m pip install --no-cache-dir passlib cffi cryptography |
| 42 | + |
| 43 | +# Ensure python3-apt is properly installed and linked |
| 44 | +RUN ln -s /usr/lib/python3/dist-packages/apt_pkg.cpython-310-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/apt_pkg.so || true |
| 45 | + |
| 46 | +# Prepare SSH server |
| 47 | +RUN mkdir /var/run/sshd |
| 48 | + |
| 49 | +# Create ansible user |
| 50 | +RUN useradd -m -s /bin/bash ansible |
| 51 | + |
| 52 | +# Set up SSH for ansible |
| 53 | +RUN mkdir -p /home/ansible/.ssh && \ |
| 54 | + chmod 700 /home/ansible/.ssh && \ |
| 55 | + chown ansible:ansible /home/ansible/.ssh |
| 56 | + |
| 57 | +# Configure sudo access for ansible |
| 58 | +RUN echo "ansible ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ansible |
| 59 | + |
| 60 | +# Disable root SSH login |
| 61 | +RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config |
| 62 | + |
| 63 | +# Expose SSH port |
| 64 | +EXPOSE 22 |
| 65 | + |
| 66 | +# Start SSH server |
| 67 | +CMD ["/usr/sbin/sshd", "-D"] |
0 commit comments