Last active
June 15, 2018 18:52
-
-
Save milosgajdos/0ca37bc08a28338d1475 to your computer and use it in GitHub Desktop.
Socat hack
This file contains hidden or 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 debian:jessie | |
RUN apt-get update && apt-get install -y socat && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* && rm -fr *Release* *Sources* *Packages* && \ | |
truncate -s 0 /var/log/*log | |
ENV SSH_AUTH_PROXY_PORT 1234 | |
COPY ./start / | |
RUN adduser vagrant --shell /bin/bash --disabled-password --gecos "" | |
RUN chown vagrant:vagrant /start && chmod 700 /start | |
USER vagrant | |
CMD ["/start"] |
This file contains hidden or 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
#!/usr/bin/env bash | |
socat TCP4-LISTEN:$SSH_AUTH_PROXY_PORT,fork UNIX-CLIENT:$SSH_AUTH_SOCK |
This file contains hidden or 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 -t gyre007/socat . | |
sudo docker run -d --net=host -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent gyre007/socat |
This file contains hidden or 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 rubyappimg:3.0 | |
# SSH proxy settings | |
ENV SSH_AUTH_SOCK /tmp/ssh-auth | |
ENV SSH_AUTH_PROXY_PORT 1234 | |
RUN mkdir -p /usr/src/app | |
WORKDIR /usr/src/app | |
ONBUILD COPY Gemfile /usr/src/app/ | |
ONBUILD COPY Gemfile.lock /usr/src/app/ | |
# Hack to install private gems | |
ONBUILD RUN socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork TCP4:$(ip route|awk '/default/ {print $3}'):$SSH_AUTH_PROXY_PORT & bundle install | |
ONBUILD COPY . /usr/src/app | |
CMD ["bundle", "exec"] |
This file contains hidden or 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
# You need to start SSH agent on the build host - Jenkins has a plugin for that | |
# eval `ssh-agent -s` && ssh-add | |
ssh-socat: | |
docker run -d --net=host --name ssh-socat -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent gyre007/socat | |
dockerbuild: ssh-socat | |
docker build -t "gyre007/app:onbuild" - < ./docker/Dockerfile.onbuild | |
docker build -t "gyre007/app:v1" . | |
docker stop ssh-socat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment