Update Dockerfile for OpenShift compatibility (Port 2222, Permissions)

This commit is contained in:
2026-02-02 00:36:37 +00:00
parent 972a1769f2
commit ef016e67da

View File

@@ -9,23 +9,30 @@ RUN apt-get update && apt-get install -y curl wget git jq un
# Install yq (binary release for latest version) # Install yq (binary release for latest version)
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq
# Setup SSH directory # Setup SSH directory & Config for OpenShift (Random UID support)
RUN mkdir /var/run/sshd RUN mkdir -p /var/run/sshd && mkdir -p /etc/ssh/host_keys && chmod 775 /var/run/sshd && chmod 775 /etc/ssh/host_keys
# Custom sshd_config for non-root usage
RUN echo "Port 2222\nPermitRootLogin no\nPasswordAuthentication no\nPubkeyAuthentication yes\nPidFile /var/run/sshd/sshd.pid\nHostKey /etc/ssh/host_keys/ssh_host_rsa_key\nHostKey /etc/ssh/host_keys/ssh_host_ecdsa_key\nHostKey /etc/ssh/host_keys/ssh_host_ed25519_key\nAuthorizedKeysFile .ssh/authorized_keys\nChallengeResponseAuthentication no\nUsePAM yes\nSubsystem sftp /usr/lib/openssh/sftp-server" > /etc/ssh/sshd_config
# Create a user 'claw' with sudo access # Create a user 'claw' with sudo access
# Passwordless sudo allowed for friction-free automation # Passwordless sudo allowed for friction-free automation
RUN useradd -m -s /bin/bash claw && echo "claw ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # OpenShift runs as random UID, but 'claw' gives us a named user for direct exec if needed
RUN useradd -m -s /bin/bash claw && echo "claw ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && # Allow group (0) write access for OpenShift random UID
chmod -R g+rwX /home/claw
# Prepare volume mount point # Prepare volume mount point
# Mount persistent storage here # Mount persistent storage here
VOLUME /data VOLUME /data
RUN chown claw:claw /data RUN mkdir -p /data && chown claw:claw /data && # Critical for OpenShift: Allow root group (gid 0) to write to /data
chmod 775 /data
# Set working directory to the persistent volume # Set working directory to the persistent volume
WORKDIR /data WORKDIR /data
# Expose SSH port # Expose SSH port (non-privileged)
EXPOSE 22 EXPOSE 2222
# Start SSH daemon # Start SSH daemon
CMD ["/usr/sbin/sshd", "-D"] # Generate host keys on startup if missing (for ephemeral pods)
CMD ["/bin/bash", "-c", "ssh-keygen -A && /usr/sbin/sshd -D -f /etc/ssh/sshd_config"]