Skip to content

Commit e44e60f

Browse files
authored
Add a Dockerfile (#192)
* Add Dockerfile * Add authentication section
1 parent abc1cf9 commit e44e60f

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Build stage
2+
FROM golang:1.23 as build
3+
WORKDIR /go/src/spanner-cli
4+
COPY . .
5+
RUN go mod download
6+
RUN CGO_ENABLED=0 go build -o /go/bin/spanner-cli
7+
8+
# Final stage
9+
FROM gcr.io/distroless/static-debian12
10+
COPY --from=build /go/bin/spanner-cli /
11+
ENTRYPOINT ["/spanner-cli"]

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ go install github.com/cloudspannerecosystem/spanner-cli@latest
2222
go get -u github.com/cloudspannerecosystem/spanner-cli
2323
```
2424

25-
Or you can download the old binary from the [releases](https://github.com/cloudspannerecosystem/spanner-cli/releases).
25+
Or you can build a docker image.
26+
27+
```
28+
git clone https://github.com/cloudspannerecosystem/spanner-cli.git
29+
cd spanner-cli
30+
docker build -t spanner-cli .
31+
```
2632

2733
## Usage
2834

@@ -50,9 +56,21 @@ Help Options:
5056
-h, --help Show this help message
5157
```
5258

59+
### Authentication
60+
5361
Unless you specify a credential file with `--credential`, this tool uses [Application Default Credentials](https://cloud.google.com/docs/authentication/production?hl=en#providing_credentials_to_your_application) as credential source to connect to Spanner databases.
62+
5463
Please make sure to prepare your credential by `gcloud auth application-default login`.
5564

65+
If you're running spanner-cli in docker container on your local machine, you have to pass local credentials to the container with the following command.
66+
67+
```
68+
docker run -it \
69+
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/credentials.json \
70+
-v $HOME/.config/gcloud/application_default_credentials.json:/tmp/credentials.json:ro \
71+
spanner-cli --help
72+
```
73+
5674
## Example
5775

5876
### Interactive mode

0 commit comments

Comments
 (0)