Skip to content

Commit

Permalink
[#1521] push to both registries
Browse files Browse the repository at this point in the history
  • Loading branch information
lispyclouds committed Mar 15, 2023
1 parent 651139e commit 94b4068
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions .circleci/script/docker.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
(or (System/getenv k)
default)))

(def image-name "ghcr.io/babashka/babashka")
(def image-name "babashka/babashka")

(def ghcr-image-name "ghcr.io/babashka/babashka")

(def image-tag (str/trim (slurp "resources/BABASHKA_VERSION")))

Expand Down Expand Up @@ -46,6 +48,7 @@
[username password]
(exec ["docker" "login" "ghcr.io" "-u" username "-p" password]))

;; TODO: Remove this when Dockerhub goes off
(defn build-push
[image-tag platform docker-file]
(println (format "Building and pushing %s Docker image(s) %s:%s"
Expand All @@ -59,6 +62,19 @@
"-f" docker-file]]
(exec (concat base-cmd label-args ["."]))))

(defn build-push-ghcr
[image-tag platform docker-file]
(println (format "Building and pushing %s Docker image(s) %s:%s to GHCR"
platform
ghcr-image-name
image-tag))
(let [base-cmd ["docker" "buildx" "build"
"-t" (str ghcr-image-name ":" image-tag)
"--platform" platform
"--push"
"-f" docker-file]]
(exec (concat base-cmd label-args ["."]))))

(defn build-push-images
[]
(doseq [platform (str/split platforms #",")]
Expand All @@ -74,8 +90,10 @@
; this overwrites, but this is to work around having built the uberjar/metabom multiple times
(fs/copy (format "/tmp/release/%s-metabom.jar" tarball-platform) "metabom.jar" {:replace-existing true})))
(build-push image-tag platforms "Dockerfile.ci")
(build-push-ghcr image-tag platforms "Dockerfile.ci")
(when-not snapshot?
(build-push latest-tag platforms "Dockerfile.ci")))
(build-push latest-tag platforms "Dockerfile.ci")
(build-push-ghcr latest-tag platforms "Dockerfile.ci")))

(defn build-push-alpine-images
"Build alpine image for linux-amd64 only (no upstream arm64 support yet)"
Expand All @@ -92,6 +110,7 @@
(if snapshot?
(println "This is a snapshot version")
(println "This is a non-snapshot version"))
(docker-login (read-env "DOCKERHUB_USER") (read-env "DOCKERHUB_PASS"))
(docker-login (read-env "CONTAINER_REGISTRY_USER") (read-env "BB_GHCR_TOKEN"))
(build-push-images)
(build-push-alpine-images))
Expand Down

0 comments on commit 94b4068

Please sign in to comment.