Last active
December 14, 2015 15:13
-
-
Save aalbadeb/a256479247e85e06fdef to your computer and use it in GitHub Desktop.
Test user dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------------------------------------------------------------------- | |
# @file Dockerfile | |
# @author Agustin Alba Chicar | |
# @brief It configures a container with apache, phpmyadmin, mysql, java8, play and the app. | |
#---------------------------------------------------------------------------------------------------------- | |
#---------------------------------------------------------------------------------------------------------- | |
## Base Container | |
FROM ubuntu:12.04.5 | |
#---------------------------------------------------------------------------------------------------------- | |
#---------------------------------------------------------------------------------------------------------- | |
## Install sudo | |
RUN apt-get update && \ | |
apt-get upgrade -y && \ | |
apt-get install -y sudo | |
#---------------------------------------------------------------------------------------------------------- | |
#---------------------------------------------------------------------------------------------------------- | |
## SSH | |
RUN apt-get update && apt-get install -y openssh-server | |
RUN mkdir /var/run/sshd | |
RUN echo 'root:roor' | chpasswd | |
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config | |
# SSH login fix. Otherwise user is kicked off after login | |
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd | |
ENV NOTVISIBLE "in users profile" | |
RUN echo "export VISIBLE=now" >> /etc/profile | |
EXPOSE 22 | |
#---------------------------------------------------------------------------------------------------------- | |
#---------------------------------------------------------------------------------------------------------- | |
## Add run.sh | |
ADD run.sh /run.sh | |
RUN chmod +x run.sh | |
#---------------------------------------------------------------------------------------------------------- | |
#---------------------------------------------------------------------------------------------------------- | |
## Users | |
# Creo un directorio para testing de permisos | |
RUN mkdir /app | |
RUN touch /app/lalal | |
RUN echo "Texto de ejemplo lalala" >> /app/lalal | |
RUN chmod -R 660 /app | |
#---------------------------------------------------------------------------------------------------------- | |
#---------------------------------------------------------------------------------------------------------- | |
## User | |
RUN useradd -ms /bin/bash devops | |
RUN echo 'devops:devops' | chpasswd | |
RUN touch /etc/sudoers.d/devops | |
RUN echo 'devops ALL = NOPASSWD: /usr/sbin/sshd' >> /etc/sudoers.d/devops | |
RUN chmod 0440 /etc/sudoers.d/devops | |
ENV HOME /home/devops | |
USER devops | |
#---------------------------------------------------------------------------------------------------------- | |
#---------------------------------------------------------------------------------------------------------- | |
## Add VOLUMES to allow backup of config and databases | |
# VOLUME [] | |
#---------------------------------------------------------------------------------------------------------- | |
CMD ["./run.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment