I recently started working with the Earthly framework for our CI/CD pipelines. My previous pipelines were based on docker and had the following bootstrapping:
docker run \
-e GOOGLE_APPLICATION_CREDENTIALS \
-v ${GOOGLE_APPLICATION_CREDENTIALS}:${GOOGLE_APPLICATION_CREDENTIALS} \
--rm \
-i \
${IMAGE_NAME}:${IMAGE_TAG} \
deploy-${target}
}
What is the best practice for passing the google application credentials file to Earthly targe?
The
earthlycommand has a parameter--secret-file <secret-id>=<path>that loads the contents of a file located at<path>into a secret with ID<secret-id>for use within the build environments.The secret can be referenced within
Earthfilerecipes asRUN --secret <arbitrary-env-var-name>=+secrets/<secret-id>.A complete working example would be:
The executing command is:
Please note that compared to the docker flow, the updated one mounts the secret file into a default location for the google application credentials.