# ゲストOS: Ubuntu 22.04 LTS

FROM nvcr.io/nvidia/pytorch:23.07-py3

# Change Your Own UNAME, UID, GID, PASS

ENV UNAME=guest
ENV UID=3000
ENV GID=3000
ENV PASS=password

ENV SSHD_PORT=22

# 必要なパッケージのインストール

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y \
    sudo \
    bash \
    openssh-server \
    supervisor \
    && rm -rf /var/lib/apt/lists/*


# SSH 設定: パスワード認証を有効化

RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
    sed -i "s/^#Port.*/Port ${SSHD_PORT}/" /etc/ssh/sshd_config && \
    mkdir /var/run/sshd


# supervisord の設定ファイルを設置する (Daemon 起動用)

RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf


##### "Build a LLM from scratch"

WORKDIR /app

# RUN git clone https://github.com/rasbt/LLMs-from-scratch.git
COPY requirements_all.txt /app/

WORKDIR /app
RUN pip install --no-cache -r requirements_all.txt

#####

# ポート開放

EXPOSE 22


# Copy Shell Script "entrypoint.sh"

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh


######

ENTRYPOINT ["/entrypoint.sh"]

CMD []
