Skip to content

Instantly share code, notes, and snippets.

@dainiusjocas
Last active May 27, 2019 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dainiusjocas/c81b39d1e9bd2e1bceed7c5162ece7a1 to your computer and use it in GitHub Desktop.
Save dainiusjocas/c81b39d1e9bd2e1bceed7c5162ece7a1 to your computer and use it in GitHub Desktop.
Clojure private Git deps Docker usage
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 .
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