...
Commit and push the repo.
On the gitlab repo web page, go to Settings → Repository.
Expand the Deploy keys section.
Click the Add new key button.
Enter the Title field (e.g.
Run-time environment
).Copy and paste the contents of the SSH key
.pub
file into the Key field.Depending on whether or not you wish to develop in another environment and only deploy to the run-time environment, or whether you wish to use the container to make changes to the codebase, select whether or not to grant write privileges to the deploy key.
Create Dockerfile
Add the deploy key to the container and setup the key inside the container.
The main steps for the Dockerfile are:
Create a
.ssh
folder.Copy the deploy key into the
.ssh
folder.Add gitlab server to
known_hosts
file.Setup
.ssh/config
file to explicitly specify the deploy key and username to be used.Clone the repo.
Here is some example Dockerfile code.
Code Block RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh ADD id_rsa_ece_li_scheduling_deploy /root/.ssh/id_rsa_ece_li_scheduling_deploy RUN chmod 600 /root/.ssh/id_rsa_ece_li_scheduling_deploy RUN ssh-keyscan -H git.uwaterloo.ca >> /root/.ssh/known_hosts RUN echo "Host git.uwaterloo.ca\n\ HostName git.uwaterloo.ca\n\ IdentityFile /root/.ssh/id_rsa_ece_li_scheduling_deploy\n\ StrictHostKeyChecking no\n\ User ist-git" >> /root/.ssh/config RUN chmod 600 /root/.ssh/config RUN git clone ist-git@git.uwaterloo.ca:d24lau/ece_li_scheduling.git
Add gitlab deploy key.
Modify ALLOWED_HOSTS.
...