File tree Expand file tree Collapse file tree 4 files changed +18
-1
lines changed
Expand file tree Collapse file tree 4 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,11 @@ version is the image's digest.
260260* `pull_tag`: *Optional.* **DEPRECATED. Use `get` and `load` instead.** Default
261261 ` latest` . The tag of the repository to pull down via `pull_repository`.
262262
263+ * `ssh_identity`: *Optional.* Only applies when `docker_buildkit` is set to `1`.
264+ Set to an openssh private SSH key (i.e. -----BEGIN OPENSSH PRIVATE KEY----- ...),
265+ this identity will be passed to `docker build` via the `--ssh default` argument
266+ through a temporary `ssh-agent` instance.
267+
263268* `tag`: **DEPRECATED - Use `tag_file` instead**
264269* `tag_file`: *Optional.* The value should be a path to a file containing the name
265270 of the tag. When not set, the Docker build will be pushed with tag value set by
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ import_file=$(jq -r '.params.import_file // ""' < $payload)
113113
114114pull_repository=$( jq -r ' .params.pull_repository // ""' < $payload )
115115pull_tag=$( jq -r ' .params.pull_tag // "latest"' < $payload )
116+ ssh_identity=$( jq -r ' .params.ssh_identity // ""' < $payload )
116117target_name=$( jq -r ' .params.target_name // ""' < $payload )
117118
118119if [ -n " $load " ]; then
@@ -224,6 +225,15 @@ elif [ -n "$build" ]; then
224225 fi
225226 fi
226227
228+ ssh_args=()
229+ if [ -n " $ssh_identity " ] && [ " $DOCKER_BUILDKIT " -eq 1 ]; then
230+ eval " $( ssh-agent) "
231+ trap " ssh-agent -k; $( trap -p EXIT | cut -f2 -d \' ) " EXIT
232+ ssh-add <( echo " $ssh_identity " )
233+ ssh_args+=(" --ssh" )
234+ ssh_args+=(" default" )
235+ fi
236+
227237 target=()
228238 if [ -n " ${target_name} " ]; then
229239 target+=(" --target" )
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ RUN apk --no-cache add \
3030 xz \
3131 util-linux \
3232 tar \
33+ openssh-client \
3334 ;
3435COPY --from=builder /assets /opt/resource
3536RUN ln -s /opt/resource/ecr-login /usr/local/bin/docker-credential-ecr-login
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ RUN apt-get update; \
3030 ca-certificates \
3131 curl \
3232 gnupg-agent \
33- software-properties-common; \
33+ software-properties-common \
34+ openssh-client; \
3435 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - ; \
3536 add-apt-repository \
3637 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
You can’t perform that action at this time.
0 commit comments