Skip to content

Instantly share code, notes, and snippets.

@dainiusjocas dainiusjocas/Dockerfile
Last active May 27, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.