Guest User

Untitled

a guest
Jun 25th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. FROM debian
  2.  
  3. RUN apt-get update -y && \
  4.  
  5. # SSH and git binaries are required
  6. apt-get install -y curl ssh git && \
  7.  
  8. # Prepare required configurations and directories
  9. mkdir -p ~/.ssh && \
  10. git config --global user.name "example" && \
  11. git config --global user.email "git@example.com" && \
  12. touch /root/.ssh/known_hosts && \
  13.  
  14. # We must add our git host to known_hosts file
  15. ssh-keyscan github.com >> ~/.ssh/known_hosts
  16.  
  17. # Here is the most important yet tricky part.
  18. # When you add secrets to a BuildConfig with Docker strategy,
  19. # the secrets are being copied over relative to the actual Dockerfile,
  20. # so you would need to ADD/COPY the secrets to docker context (i.e. inside the container)
  21. ADD secrets /etc/secrets
  22.  
  23. # Since git will use ssh-agent binary we must identify our SSH private key
  24. RUN eval "$(ssh-agent)" && ssh-agent -s && \
  25. chmod -R 0600 /etc/secrets && \
  26. ssh-add /etc/secrets/**/* && \
  27.  
  28. # Use ssh remote to clone as usual
  29. git clone git@github.com:my-org/my-library.git && \
  30. ls -lash my-library/ && \
  31.  
  32. # Do not keep SSH keys inside the image and remove them for better security
  33. rm -rf /etc/secrets
Add Comment
Please, Sign In to add comment