Created
November 5, 2024 15:08
-
-
Save lyf2000/c6e39b7de67ee0ea9f26b9eef118cf83 to your computer and use it in GitHub Desktop.
docker compose build with ssh clone, install from private git repo
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
eval $(ssh-agent) | |
ssh-add ~/.ssh/id_rsa # pass own path | |
export COMPOSE_DOCKER_CLI_BUILD=1 | |
export DOCKER_BUILDKIT=1 | |
docker-compose build --ssh default=$SSH_AUTH_SOCK |
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
# Docs: https://docs.docker.com/reference/dockerfile/#run---mounttypessh | |
# req.txt: pckgname @ git+ssh://[email protected]/<repo>.git@<version if need> | |
# in terminal: | |
# syntax=docker/dockerfile:1 | |
FROM python:3.12-alpine AS build | |
RUN apk add --no-cache git openssh-client | |
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts | |
WORKDIR /app | |
COPY req.txt . | |
RUN --mount=type=ssh \ | |
pip install --user -r req.txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment