ollie/cmd/toolsrv/test/Containerfile

43 lines
1.4 KiB
Docker

FROM fedora:41
# Minimal packages for remote execution testing
RUN dnf install -y \
openssh-server \
bash \
python3 \
git \
golang \
make \
procps-ng \
&& dnf clean all
# Configure SSHD
RUN ssh-keygen -A \
&& sed -i 's/#PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config \
&& sed -i 's/#PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config \
&& sed -i 's/#PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config \
&& sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
# Create test user matching host UID for easy volume mounting
ARG UID=1000
ARG USER=lkn
RUN useradd -m -u ${UID} -s /bin/bash ${USER}
# Set up SSH authorized_keys
RUN mkdir -p /home/${USER}/.ssh && chmod 700 /home/${USER}/.ssh
COPY authorized_keys /home/${USER}/.ssh/authorized_keys
RUN chmod 600 /home/${USER}/.ssh/authorized_keys \
&& chown -R ${USER}:${USER} /home/${USER}/.ssh
# Create a test project directory
RUN mkdir -p /home/${USER}/project && chown ${USER}:${USER} /home/${USER}/project
COPY hello.go /home/${USER}/project/hello.go
RUN chown ${USER}:${USER} /home/${USER}/project/hello.go
# Cache directory for ollie-remote binary
RUN mkdir -p /home/${USER}/.cache/ollie/bin \
&& chown -R ${USER}:${USER} /home/${USER}/.cache
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D", "-e"]