Skip to content

Decs1.4 ubuntu20.04 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
FROM tensorflow/tensorflow:2.5.0rc1-gpu
<<<<<<< HEAD
FROM tensorflow/tensorflow:2.9.1-gpu-jupyter
=======
FROM tensorflow/tensorflow:2.6.0-gpu
>>>>>>> 7250ac3299e92efeadffb93324e4d7caed5ee25f
# # 설치 시 geographic area 를 물어보지 않도록 설정(apt install 시 interrupted 됨)
ENV DEBIAN_FRONTEND noninteractive

ENV SUDOER_ID svmanager
ENV SUDOER_PW decs2260
ENV SUDOER_DIR /$SUDOER_ID
ENV SSHD_CONFIG_PATH /etc/ssh/sshd_config
# RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub

RUN apt-get clean \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC \
Expand All @@ -21,6 +26,10 @@ curl \
ssh \
software-properties-common

# motd install
RUN apt-get update && apt-get install -y update-motd


# 관리자 계정의 home directory 로 쓸 폴더 추가(home은 nfs이므로, 다른 곳에 생성)
RUN mkdir "$SUDOER_DIR"
# 관리자 계정을 추가, home directory 를 위에서 생성한 폴더로 설정
Expand All @@ -30,8 +39,7 @@ RUN useradd -s /bin/bash -d /$SUDOER_ID -G sudo $SUDOER_ID \
RUN cp -R /etc/skel/. "$SUDOER_DIR"

RUN echo $SUDOER_ID:$SUDOER_PW | chpasswd
# 소유권 설정 필요한가?
# RUN chown -R $SUDOER_ID:$SUDOER_ID "$SUDOER_DIR"


# decs dir 을 생성
RUN mkdir /home/decs
Expand All @@ -45,18 +53,8 @@ RUN printf "LANG=\"ko_KR.UTF-8\"\nLANG=\"ko_KR.EUC-KR\"\nLANGUAGE=\"ko_KR:ko:en_

RUN cat /etc/environment

# xrdp 실행을 위한 그래픽 인터페이스 설치
RUN apt-get install -y xrdp xfce4 xfce4-terminal

# xrdp 필요한 환경 변수 설정
RUN echo "unset DBUS_SESSION_BUS_ADDRESS" >> $HOME/.profile && \
echo "unset XDG_RUNTIME_DIR" >> $HOME/.profile

# ssl-cert 그룹에 xrdp 사용자 추가
RUN usermod -aG ssl-cert xrdp


# Anaconda 설치 및 환경설정
# # Anaconda 설치 및 환경설정
RUN wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh \
&& bash Anaconda3-2020.02-Linux-x86_64.sh -b -p /opt/anaconda3 \
&& rm Anaconda3-2020.02-Linux-x86_64.sh
Expand All @@ -65,10 +63,10 @@ ENV PATH opt/anaconda3/bin:$PATH
RUN echo "export PATH="/opt/anaconda3/bin:$PATH >> /etc/profile \
&& /opt/anaconda3/bin/conda init

# jupyterlab 설치
# # jupyterlab 설치
RUN /opt/anaconda3/bin/conda install -y jupyterlab

# jupyterlab 설정파일 생성
# # jupyterlab 설정파일 생성
RUN mkdir /jupyter_config \
&& /opt/anaconda3/bin/jupyter lab --generate-config --config=/jupyter_config/jupyter_notebook_config.py

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# DECS
Dongguk Education Containter Service 입니다. ailab_base 의 다양한 오류를 수정하고 기능을 개선
Dongguk Education(Elastic이 되게끔 k8s 도입 예정) Containter Service 입니다.

![image](https://github.com/DGU-AILab/DECS/assets/106306092/3e895872-06a4-4cf0-9c75-c3d5866d3081)

73 changes: 51 additions & 22 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@
# sudo docker logs [container_name] 으로 로그 확인 가능
echo "hello entrypoint!"

echo -e "\n\n --------------------------------------------------------------------------------------------------------------------------------------------
\n\n 안녕하세요. 동국대학교 AI lab 입니다. \n\n 해당 컨테이너는 sudo권한을 가집니다.
\n 따라서, 컨테이너 또는 컨테이너가 실행중인 로컬서버에 해가 되는 행동을 할 시 사용자분에게 전적인 책임이 있음을 안내드립니다.
<<<<<<< HEAD
\n 디렉토리 또는 파일을 삭제하는 행위 또는 root 권한을 통해 시스템을 수정하는 명령어 등을 조심히 사용해주시면 됩니다.
\n 추가로, 사용자분의 디렉토리는 별도로 백업되지 않습니다. 중요한 파일의 경우 주기적으로 백업해 주시기 바랍니다. 감사합니다.
=======
\n 디렉토리 또는 파일을 삭제하는 행위 또는 root 권한을 통해 시스템을 수정하는 명령어 등을 조심히 사용해주시면 됩니다. 감사합니다.
>>>>>>> 7250ac3299e92efeadffb93324e4d7caed5ee25f
\n (이미지 버전 : decs:1.4) \n\n
--------------------------------------------------------------------------------------------------------------------------------------------\n" > /etc/motd
# 유저 계정 생성
if ! id "$USER_ID" >/dev/null 2>&1; then
echo "No User account detected..."

# 유저 계정을 생성, 홈폴더는 decs폴더로 설정
useradd -s /bin/bash -d /$USER_ID $USER_ID
# sudo 권한을 주되, 자신 소유가 아닌 폴더를 삭제하는 shell command를 제한
echo "$USER_ID ALL=(ALL) NOPASSWD:ALL, !/bin/rm" >> /etc/sudoers
# sudo 권한을 준다.
echo "$USER_ID ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# 홈폴더 생성
# skeleton 파일을 복사하여, 유저명이 tf-docker 로 표시되는 것을 방지
Expand All @@ -23,10 +34,11 @@ if ! id "$USER_ID" >/dev/null 2>&1; then
echo "user account config done..."

# sshd 설정도 바꾼다.
# 서버관리자와 유저계정의 ssh 접속을 허용
# 서버관리자와 유저계정의 ssh 접속을 허용 및 다중접속 허용
sed -i "/^#PermitRootLogin/a AllowUsers svmanager" /etc/ssh/sshd_config
sed -i "/^#PermitRootLogin/a AllowUsers $USER_ID" /etc/ssh/sshd_config
service ssh restart
sed -i 's/^UsePAM yes/UsePAM no/' /etc/ssh/sshd_config

echo "ssh change done..."

fi
Expand Down Expand Up @@ -58,7 +70,8 @@ usermod -u $UID -g $UID $USER_ID
# readme 안내문 생성
echo "Hello Decs, 동국대학교 GPU 서버 컨테이너 서비스 decs 입니다." > /home/$USER_ID/readme_decs.txt

# jupyterlab 설정파일 수정
# ssh restart
service ssh restart

# jupyter lab 에서 생성한 ipynb 파일을 저장할 디렉토리 생성 (없는경우만 신규 생성)
if [ ! -d "/home/$USER_ID/decs_jupyter_lab" ]; then
Expand All @@ -74,30 +87,46 @@ echo "trying jupyter lab..."
nohup /opt/anaconda3/bin/jupyter lab --NotebookApp.token=decs --config=/jupyter_config/jupyter_notebook_config.py >/dev/null 2>&1 &
echo "jupyter lab listening!"

# xrdp의 터미널이 안켜지는 오류 자동 해결 : 터미널로 xface 를 선택
# update-alternatives --set x-terminal-emulator /usr/bin/xfce4-terminal
# auditd 설치
sudo apt update
sudo apt install -y auditd
<<<<<<< HEAD

# /etc/audit/audit.rules 파일에 줄 추가
# sed -i "/^#-a always,exit -F arch=b64 -S unlink -S unlinkat -S rename -S renameat -F auid=$USER_ID -k rm_commands" /etc/audit/audit.rules
echo "-a always,exit -F arch=b64 -S unlink -S unlinkat -S rename -S renameat -F auid=$USER_ID -k rm_commands" >> /etc/audit/audit.rules

# history 명령어 칠 때 명령어를 입력한 시간이 같이 나오게끔 하는 명령어
echo 'HISTTIMEFORMAT="[%Y-%m-%d %H:%M:%S] "' >> /etc/profile
echo 'export HISTTIMEFORMAT' >> /etc/profile

# history -w 현재시간.txt파일을 만들고, /var/log/audit로 이동하는 부분임. 사용자가 로그아웃 할 때
=======

# /etc/audit/audit.rules 파일에 줄 추가
# sed -i "/^#-a always,exit -F arch=b64 -S unlink -S unlinkat -S rename -S renameat -F auid=$USER_ID -k rm_commands" /etc/audit/audit.rules
echo "-a always,exit -F arch=b64 -S unlink -S unlinkat -S rename -S renameat -F auid=$USER_ID -k rm_commands" >> /etc/audit/audit.rules

# xrdp를 자동으로 시작
service xrdp-sesman start
service xrdp start
# Add the HISTTIMEFORMAT setting to /etc/profile
echo 'HISTTIMEFORMAT="[%Y-%m-%d %H:%M:%S] "' >> /etc/profile
# Export the HISTTIMEFORMAT variable
echo 'export HISTTIMEFORMAT' >> /etc/profile

>>>>>>> 7250ac3299e92efeadffb93324e4d7caed5ee25f
echo 'cd ~' >> /home/$USER_ID/.bash_logout
echo 'current_time=$(date +%Y-%m-%d_%H-%M-%S)' >> /home/$USER_ID/.bash_logout
echo 'history -w $current_time.txt' >> /home/$USER_ID/.bash_logout
echo 'sudo mv $current_time.txt /var/log/audit/' >> /home/$USER_ID/.bash_logout

# 유저 개인폴더 안에 프로그램을 모두 설치하고 나면, 유저 개인폴더의 모든 파일의 소유자를 유저로 변경. 시간이 약간 소요됨(재귀로 모든 파일의 권한을 변경.)
chown -R "$UID:$UID" "/home/$USER_ID"
chmod -R 700 "/home/$USER_ID"
echo "decs chown change done..."

# 재시작 오류를 자동으로 해결
pid_file="/var/run/xrdp/xrdp.pid"
if [ -f "$pid_file" ]; then
rm -f "$pid_file"
fi
sesman_file="/var/run/xrdp/xrdp-sesman.pid"
if [ -f "$sesman_file" ]; then
rm -f "$sesman_file"
fi
<<<<<<< HEAD


=======
>>>>>>> 7250ac3299e92efeadffb93324e4d7caed5ee25f

#entrypoint.sh 를 실행하고 나서 컨테이너가 Exit 하지 않게함
tail -F /dev/null
tail -F /dev/null