# os with ssh
# images
FROM ubuntu:20.04 

# package procedure(update&upgrade&install)
RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y vim net-tools apt-utils iputils-ping wget tar curl language-pack-ko openssh-server openjdk-11-jdk

#package clean unused
RUN apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Set up configuration for SSH
RUN mkdir /var/run/sshd
RUN echo 'root:!@#gds$%^' | chpasswd
RUN sed -ri 's/^#?PermitRootLogin\s+.*/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

# java and tomcat path
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64" >> /etc/profile && \
    echo "export LANG=ko_KR.UTF-8" >> /etc/profile

#run script folder and copy script and ssl(ems.best)
RUN mkdir /service_script
COPY start_service.sh /service_script
RUN chmod +x /service_script/start_service.sh

# Expose port
EXPOSE 22 8090 9908

# Run SSH,DB,TOMCAT
CMD ["/service_script/start_service.sh"]
