Skip to content

Instantly share code, notes, and snippets.

@jeffersonsouza
Created October 4, 2016 11:50
Show Gist options
  • Save jeffersonsouza/359ac73c44eee70cf6aa09ec20de3a9f to your computer and use it in GitHub Desktop.
Save jeffersonsouza/359ac73c44eee70cf6aa09ec20de3a9f to your computer and use it in GitHub Desktop.
FROM debian:jessie
MAINTAINER Jefferson Souza <[email protected]>
RUN apt-get -q update && \
apt-get install -y --no-install-recommends openjdk-7-jre-headless git openssh-server && \
apt-get -q autoremove && \
apt-get -q clean -y && rm -rf /var/lib/apt/lists/* && rm -f /var/cache/apt/*.bin && \
sed -i 's|session required pam_loginuid.so|session optional pam_loginuid.so|g' /etc/pam.d/sshd &&\
mkdir -p /var/run/sshd
RUN useradd -m -d /home/jenkins -s /bin/sh jenkins &&\
echo "jenkins:jenkins" | chpasswd && \
groupadd --gid 999 docker && \
usermod -aG docker jenkins && \
gpasswd -a jenkins docker
RUN ssh-keygen -A
RUN set -x && \
echo "UsePrivilegeSeparation no" >> /etc/ssh/sshd_config && \
echo "PermitRootLogin no" >> /etc/ssh/sshd_config && \
echo "AllowGroups jenkins" >> /etc/ssh/sshd_config
# Comment these lines to disable sudo
RUN echo "%jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
USER jenkins
WORKDIR /home/jenkins
USER root
ADD https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz /tmp
RUN tar -xvzf /tmp/docker-latest.tgz && mv docker/* /usr/bin/ && chmod 755 /usr/bin/docker && rm -f /tmp/docker-latest.tgz
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment