GoogleCloudPlatform / GoogleCloudPlatform/gsutil
gsutil + docker + GOOGLE_APPLICATION_CREDENTIALS help
- Dominant language
- Python
- Stars
- 918
- Forks
- 335
- PR merge metrics
- No merged PRs in 30d
Description
Hey guys. I commented before on #447 about this. Decided to open this as a separate issue. I'll describe my problem in as much detail with as much direct code as possible to alleviate confusion about what I am trying to do.
For this project I am working in docker containers solely. I want to be able to communicate with gsutil when running containers on my local machine, but also run them in my CI/CD environment, and production using the same container with minimal configuration.
I want to work under the following assumption. The user has the following environmental variables defined, conditional on environment:
```bash
# locally
export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/.config/gcloud/application_default_credentials.json
# ci/cd, production
export GOOGLE_APPLICATION_CREDENTIALS=/some-service-account.json
```
Here is an example of a docker-compose.yml
```yaml
version: 3.9
services:
gsutil_test_container:
build: .
volumes:
- $GOOGLE_APPLICATION_CREDENTIALS:/creds
environment:
GOOGLE_APPLICATION_CREDENTIALS: "/creds"
```
Here is my dockerfile:
```Dockerfile
FROM google/cloud-sdk
COPY docker-entrypoint.sh .
ENTRYPOINT [ "./docker-entrypoint.sh" ]
```
Here is my docker-entrypoint.sh:
```bash
#! /usr/bin/env bash
gsutil ls
```
What I want to do: `docker-compose run gsutil_test_container`
Contributor guide
Research direction
Start with the Dockerfile, docker-compose.yml, and docker-entrypoint.sh shown in the issue, then run the stated docker-compose command and inspect how GOOGLE_APPLICATION_CREDENTIALS is mounted and read by gsutil. Done means gsutil ls succeeds with the same container configuration locally and in CI/CD or production.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, docker, docker-compose, python
- Domain
- cli, cloud, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100