Skip to content

Commit 0c49ecc

Browse files
authored
more fixes to work with runpod + skypilot (axolotl-ai-cloud#1629)
1 parent 6011343 commit 0c49ecc

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

docker/Dockerfile-cloud-no-tmux

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ ENV HF_HUB_ENABLE_HF_TRANSFER="1"
1010
EXPOSE 8888
1111
EXPOSE 22
1212

13-
COPY scripts/cloud-entrypoint.sh /root/cloud-entrypoint.sh
13+
COPY scripts/cloud-entrypoint-term.sh /root/cloud-entrypoint.sh
1414
COPY scripts/motd /etc/motd
1515

1616
RUN pip install jupyterlab notebook ipywidgets && \
1717
jupyter lab clean
18-
RUN apt install --yes --no-install-recommends openssh-server tmux && \
18+
RUN apt install --yes --no-install-recommends openssh-server tmux sudo && \
19+
pip3 install -U --no-cache-dir grpcio ray==2.9.3 && \
1920
mkdir -p ~/.ssh && \
2021
chmod 700 ~/.ssh && \
2122
printf "[ ! -z \"\$TERM\" -a -r /etc/motd ] && cat /etc/motd\n" >> ~/.bashrc && \

scripts/cloud-entrypoint-term.sh

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
# Export specific ENV variables to /etc/rp_environment
4+
echo "Exporting environment variables..."
5+
printenv | grep -E '^RUNPOD_|^PATH=|^_=' | sed 's/^\(.*\)=\(.*\)$/export \1="\2"/' >> /etc/rp_environment
6+
conda init
7+
# this needs to come after conda init
8+
echo 'source /etc/rp_environment' >> ~/.bashrc
9+
10+
add_keys_to_authorized() {
11+
local key_value=$1
12+
13+
# Create the ~/.ssh directory and set permissions
14+
mkdir -p ~/.ssh
15+
chmod 700 ~/.ssh
16+
17+
# Create the authorized_keys file if it doesn't exist
18+
touch ~/.ssh/authorized_keys
19+
20+
# Initialize an empty key variable
21+
local key=""
22+
23+
# Read the key variable word by word
24+
for word in $key_value; do
25+
# Check if the word looks like the start of a key
26+
if [[ $word == ssh-* ]]; then
27+
# If there's a key being built, add it to the authorized_keys file
28+
if [[ -n $key ]]; then
29+
echo $key >> ~/.ssh/authorized_keys
30+
fi
31+
# Start a new key
32+
key=$word
33+
else
34+
# Append the word to the current key
35+
key="$key $word"
36+
fi
37+
done
38+
39+
# Add the last key to the authorized_keys file
40+
if [[ -n $key ]]; then
41+
echo $key >> ~/.ssh/authorized_keys
42+
fi
43+
44+
# Set the correct permissions
45+
chmod 600 ~/.ssh/authorized_keys
46+
chmod 700 -R ~/.ssh
47+
}
48+
49+
if [[ $PUBLIC_KEY ]]; then
50+
# runpod
51+
add_keys_to_authorized "$PUBLIC_KEY"
52+
# Start the SSH service in the background
53+
service ssh start
54+
elif [[ $SSH_KEY ]]; then
55+
# latitude.sh
56+
add_keys_to_authorized "$SSH_KEY"
57+
# Start the SSH service in the background
58+
service ssh start
59+
else
60+
echo "No PUBLIC_KEY or SSH_KEY environment variable provided, not starting openSSH daemon"
61+
fi
62+
63+
# Check if JUPYTER_PASSWORD is set and not empty
64+
if [ -n "$JUPYTER_PASSWORD" ]; then
65+
# Set JUPYTER_TOKEN to the value of JUPYTER_PASSWORD
66+
export JUPYTER_TOKEN="$JUPYTER_PASSWORD"
67+
fi
68+
69+
if [ "$JUPYTER_DISABLE" != "1" ]; then
70+
# Run Jupyter Lab in the background
71+
jupyter lab --port=8888 --ip=* --allow-root --ServerApp.allow_origin=* &
72+
fi
73+
74+
if [ ! -d "/workspace/data/axolotl-artifacts" ]; then
75+
mkdir -p /workspace/data/axolotl-artifacts
76+
fi
77+
if [ ! -L "/workspace/axolotl/outputs" ]; then
78+
ln -sf /workspace/data/axolotl-artifacts /workspace/axolotl/outputs
79+
fi
80+
81+
# Execute the passed arguments (CMD)
82+
exec "$@"

0 commit comments

Comments
 (0)