Skip to content

Commit cbcfa5d

Browse files
committed
Move most of the ssh key munging out into the workflow.
1 parent 4ea3afd commit cbcfa5d

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

.github/workflows/build_test.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,37 @@ jobs:
9595
echo "=== Git Config URL Rewrites ==="
9696
git config --global --get-regexp 'url\..*\.insteadof' || echo "No git URL rewrites found"
9797
98-
# Write SSH keys to files for use inside Docker container
99-
# The SSH agent runs on the runner but we need actual key files inside the
100-
# Docker container to create SSH config with host aliases. We write the keys
101-
# to .docker-ssh/ which gets copied into the container during build.
98+
# Prepare all SSH configuration files for Docker build
99+
# The SSH agent runs on the runner but we need actual key files and config
100+
# inside the Docker container. We pre-build everything here in the workflow
101+
# to keep the Dockerfile simple and free of CI-specific logic.
102102
- name: Prepare SSH keys for Docker build
103103
run: |
104104
mkdir -p .docker-ssh
105+
106+
# Write SSH private keys
105107
echo "${{ secrets.DEPLOY_KEY_FOR_OLMOEARTH_PRETRAIN_CLONE }}" > .docker-ssh/olmoearth_pretrain_key
106108
echo "${{ secrets.DEPLOY_KEY_FOR_OLMOEARTH_RUN_CLONE }}" > .docker-ssh/olmoearth_run_key
107-
chmod 600 .docker-ssh/*
109+
chmod 600 .docker-ssh/*_key
110+
111+
# Create SSH config with host aliases
112+
cat > .docker-ssh/config << 'EOF'
113+
Host github-olmoearth-pretrain
114+
HostName github.com
115+
IdentityFile /root/.ssh/olmoearth_pretrain_key
116+
IdentitiesOnly yes
117+
118+
Host github-olmoearth-run
119+
HostName github.com
120+
IdentityFile /root/.ssh/olmoearth_run_key
121+
IdentitiesOnly yes
122+
EOF
123+
124+
# Create modified requirements files with host aliases
125+
sed 's|git@github\.com/allenai/olmoearth_pretrain|git@github-olmoearth-pretrain/allenai/olmoearth_pretrain|g' \
126+
requirements-olmoearth_pretrain.txt > .docker-ssh/requirements-olmoearth_pretrain.txt
127+
sed 's|git@github\.com/allenai/olmoearth_run|git@github-olmoearth-run/allenai/olmoearth_run|g' \
128+
requirements-olmoearth_run.txt > .docker-ssh/requirements-olmoearth_run.txt
108129
109130
## REMOVE BEFORE MERGE! ####
110131
# - name: Clone olmoearth repositories and update requirements-extra.txt

Dockerfile

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,11 @@ COPY . /opt/rslearn_projects/
8989
ARG USE_SSH_KEYS_FROM_BUILD=false
9090
RUN if [ "$USE_SSH_KEYS_FROM_BUILD" = "true" ] && [ -d /opt/rslearn_projects/.docker-ssh ]; then \
9191
echo "Setting up SSH keys from build context..." && \
92-
cp /opt/rslearn_projects/.docker-ssh/* /root/.ssh/ && \
93-
chmod 600 /root/.ssh/*_key && \
94-
echo "Host github-olmoearth-pretrain" >> /root/.ssh/config && \
95-
echo " HostName github.com" >> /root/.ssh/config && \
96-
echo " IdentityFile /root/.ssh/olmoearth_pretrain_key" >> /root/.ssh/config && \
97-
echo " IdentitiesOnly yes" >> /root/.ssh/config && \
98-
echo "" >> /root/.ssh/config && \
99-
echo "Host github-olmoearth-run" >> /root/.ssh/config && \
100-
echo " HostName github.com" >> /root/.ssh/config && \
101-
echo " IdentityFile /root/.ssh/olmoearth_run_key" >> /root/.ssh/config && \
102-
echo " IdentitiesOnly yes" >> /root/.ssh/config && \
103-
chmod 600 /root/.ssh/config && \
104-
sed -i 's|git@github\.com/allenai/olmoearth_pretrain|git@github-olmoearth-pretrain/allenai/olmoearth_pretrain|g' /opt/rslearn_projects/requirements-olmoearth_pretrain.txt && \
105-
sed -i 's|git@github\.com/allenai/olmoearth_run|git@github-olmoearth-run/allenai/olmoearth_run|g' /opt/rslearn_projects/requirements-olmoearth_run.txt && \
92+
cp /opt/rslearn_projects/.docker-ssh/*_key /root/.ssh/ && \
93+
cp /opt/rslearn_projects/.docker-ssh/config /root/.ssh/config && \
94+
chmod 600 /root/.ssh/*_key /root/.ssh/config && \
95+
cp /opt/rslearn_projects/.docker-ssh/requirements-olmoearth_pretrain.txt /opt/rslearn_projects/requirements-olmoearth_pretrain.txt && \
96+
cp /opt/rslearn_projects/.docker-ssh/requirements-olmoearth_run.txt /opt/rslearn_projects/requirements-olmoearth_run.txt && \
10697
echo "SSH multi-key setup complete."; \
10798
else \
10899
echo "Using default SSH configuration (single key or SSH agent)."; \

0 commit comments

Comments
 (0)