Skip to content

Commit cad1cd8

Browse files
committed
Add script to show why cannot clone private git repo via SSH
1 parent 2a6af92 commit cad1cd8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
IMG_NAME=docker.tutorials:build-path-git-ssh-private
2+
export DOCKER_BUILDKIT=1
3+
4+
# By using this to build docker image, a `Dockerfile` is
5+
# required at root directory.
6+
#
7+
## This build will fail because the SSH key is not
8+
## provided. It's not recommended adding SSH key via
9+
## `Dockerfile` because it can be seen in the build log
10+
## as plain text.
11+
## The best practice is using `--ssh` to pass SSH clinet
12+
## agent to docker deamon and use `git clone` in the
13+
## `Dockerfile`.
14+
REPO=git@github.com:OttoHung/private-test.git#main
15+
16+
echo "Start to build docker image from: ${REPO}"
17+
18+
# Build docker image from public git repository via HTTPS
19+
#
20+
# The path of `Dockerfile` is not required because this
21+
# approach gathers `Dockerfile` from repository.
22+
docker build \
23+
--secret id=npm,src=$HOME/.npmrc \
24+
--no-cache \
25+
-t ${IMG_NAME} \
26+
${REPO}

0 commit comments

Comments
 (0)