Created
August 10, 2021 15:31
-
-
Save magickatt/27a762140ce518aef58f53c4e596de34 to your computer and use it in GitHub Desktop.
Add deploy key to SSH agent forwarding for Docker build in Google Cloud Build
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
- name: 'gcr.io/cloud-builders/git' | |
secretEnv: ['SSH_KEY'] | |
entrypoint: 'bash' | |
args: | |
- -c | |
- | | |
echo "$$SSH_KEY" >> /root/.ssh/id_rsa | |
chmod 400 /root/.ssh/id_rsa | |
volumes: | |
- name: 'ssh' | |
path: /root/.ssh | |
- name: "gcr.io/cloud-builders/docker" | |
args: | |
[ | |
"build", | |
"--ssh", | |
"default=/root/.ssh/id_rsa", | |
".", | |
] | |
env: | |
- "DOCKER_BUILDKIT=1" | |
volumes: | |
- name: 'ssh' | |
path: /root/.ssh | |
availableSecrets: | |
secretManager: | |
- versionName: projects/$PROJECT_ID/secrets/machineuser-ssh-key/versions/latest | |
env: 'SSH_KEY' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment