-
-
Save riyadparvez/6e52628f67b99caedb6a180de8652691 to your computer and use it in GitHub Desktop.
Makefile Docker Git GitHub multi-stage build ssh private key recipe
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 python:3 as build-system | |
RUN pip install -U pip | |
COPY requirements.txt requirements.txt | |
### create temporary image used to download and vendor packages using private key ### | |
FROM build-system as intermediate | |
# add credentials on build | |
ARG SSH_PRIVATE_KEY | |
RUN mkdir /root/.ssh/ | |
RUN echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa | |
RUN chmod 600 /root/.ssh/* | |
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts | |
# vendor python dependencies | |
RUN pip download -r requirements.txt -d /vendor/python | |
### create the runtime image ### | |
FROM build-system as runtime | |
# install vendored python dependencies | |
COPY --from=intermediate /vendor/python /vendor/python | |
RUN pip install /vendor/python/* |
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
SSH_PRIVATE_KEY=`cat ~/.ssh/id_rsa` | |
build-image: | |
docker build . --build-arg SSH_PRIVATE_KEY="${SSH_PRIVATE_KEY}" |
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
git+ssh://[email protected]/{user-or-group}/{repo}.git@{optional-tag-or-commit_hash}#egg={package_name} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment