Last active
May 27, 2019 12:11
-
-
Save dainiusjocas/c81b39d1e9bd2e1bceed7c5162ece7a1 to your computer and use it in GitHub Desktop.
Clojure private Git deps Docker usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -f Dockerfile --build-arg ssh_prv_key="$(cat ~/.ssh/id_rsa)" --build-arg ssh_pub_key="$(cat ~/.ssh/id_rsa.pub)" -t clojure-private-git-deps:test . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM clojure:tools-deps-alpine | |
RUN apk add --no-cache openssh-client | |
# Authorize SSH Host | |
RUN mkdir -p /root/.ssh && \ | |
chmod 0700 /root/.ssh && \ | |
ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && \ | |
ssh-keyscan bitbucket.com >> /root/.ssh/known_hosts && \ | |
ssh-keyscan github.com >> /root/.ssh/known_hosts | |
# Create a wrapper for clojure binary | |
RUN mkdir -p /usr/local/sbin/ && \ | |
echo -e '#!/bin/sh \n eval $(ssh-agent -s) && ssh-add -k ~/.ssh/id_rsa && exec /usr/local/bin/clojure "$@"' >> /usr/local/sbin/clojure && \ | |
chmod +x /usr/local/sbin/clojure | |
ARG ssh_prv_key | |
ARG ssh_pub_key | |
# Add the keys and set permissions | |
RUN echo "$ssh_prv_key" > /root/.ssh/id_rsa && \ | |
echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub && \ | |
chmod 600 /root/.ssh/id_rsa && \ | |
chmod 600 /root/.ssh/id_rsa.pub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment