Fork me on GitHub
#google-cloud
<
2021-11-17
>
genekim17:11:32

@hannu.hartikainen Holy cow, I absolutely loved your article on Google Jib as a way to run Java/Clojure apps in production. I’ve gotten Google Cloud Build container build times down to 45 seconds, using just distroless and the uberjar file. https://www.vincit.fi/en/clojure-in-google-cloud-run-with-jib/ I used the jib CLI, and was amazed that incremental uploads can take less than 7 seconds. I tried last night to use the Google Jib Core API to upload images, using the fantastic work in @vvehvilainen’s lein-jib-build plugin, but couldn’t get credentials loaded, after a couple hours of trying. This morning, I confirmed that the Jib CLI works, so I know it can be done. Any chance anyone might want to collaborate to get a simple tools.build interface to Jib running? (I’ll post a gist of my attempts from last night shortly.) Thanks, all! https://github.com/vehvis/lein-jib-build

genekim17:11:28

Here’s the code I’m evaluating: https://gist.github.com/realgenekim/fdcad45286d065cc559cd75a8f946ad4#file-jib-build-clj-L45 And the error I’m getting is below. Any ideas?

Execution error (HttpResponseException) at com.google.api.client.http.HttpRequest/execute (HttpRequest.java:1113).
401 Unauthorized
GET 
{"errors":[{"code":"UNAUTHORIZED","message":"You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: "}]}
And yet, in the CLI, I see this: (6.8 seconds! Amazing!)
genekim@Genes-2020-M1-MacBook-Pro datomic-cloudrun % time make jibcli
bin/jib-0.5.0/bin/jib jar --target= \
		target/datomic-test-standalone.jar
[WARN] Base image 'adoptopenjdk:8-jre' does not use a specific image digest - build may not be reproducible
Using credentials from Docker config (/Users/genekim/.docker/config.json) for 
The base image requires auth. Trying again for adoptopenjdk:8-jre...
Using base image with digest: sha256:bf736024c65942ab045c497e408706f9e599651bf8c01a75ecb3d6971d66700d

Container entrypoint set to [java, -cp, /app/explodedJar:/app/dependencies/*, datomic_proxy.core]
Container program arguments set to []
Executing tasks:
[============================  ] 91.7% complete
> launching layer pushers

make jibcli  6.80s user 10.46s system 101% cpu 17.073 total
genekim@Genes-2020-M1-MacBook-Pro datomic-cloudrun % 

genekim18:11:28

Holy cow. I’m now getting credentials! Null Pointer Exception went away, when I passed in a real logger as an argument to CredentialRetrieverFactory. (Copied from JUXT Pack: https://github.com/juxt/pack.alpha/blob/master/src/mach/pack/alpha/jib.clj)

trying docker-credential-gcloud for 
Using credentials from Docker config (/Users/genekim/.docker/config.json) for 
I’ll update the gist with the working code later today. 🎉

😁 1
xlfe11:11:17

thanks for the tips - we do a bunch of stuff on GCP with Clojure - (currently cloud build with a simple distroless base after building a uberjar) so will have to look at jib

slimslenderslacks19:12:36

Ya, thanks for writing this up, this is really cool.