|
1 | 1 | (ns docker-clojure.config
|
2 | 2 | (:require [clojure.spec.alpha :as s]
|
| 3 | + [clojure.spec.gen.alpha :as gen] |
3 | 4 | [clojure.string :as str]
|
| 5 | + [com.gfredericks.test.chuck.generators :as gen'] |
4 | 6 | [docker-clojure.core :as-alias core]))
|
5 | 7 |
|
6 | 8 | (s/def ::non-blank-string
|
|
13 | 15 | (s/def ::base-image ::non-blank-string)
|
14 | 16 | (s/def ::base-images (s/coll-of ::base-image :distinct true :into #{}))
|
15 | 17 |
|
16 |
| -(s/def ::docker-image-name (s/and ::non-blank-string |
17 |
| - #(re-matches #"[-\w]+(?::[-\w.]+)?" %))) |
18 |
| -(s/def ::docker-tag (s/and ::non-blank-string |
19 |
| - #(re-matches #"[-\w.]+" %))) |
| 18 | +(def docker-image-name-re (re-pattern "[-\\w]+(?::[-\\w.]+)?")) |
| 19 | + |
| 20 | +(s/def ::docker-image-name |
| 21 | + (s/with-gen |
| 22 | + (s/and ::non-blank-string |
| 23 | + #(re-matches docker-image-name-re %)) |
| 24 | + #(gen'/string-from-regex docker-image-name-re))) |
| 25 | + |
| 26 | +(def docker-tag-re (re-pattern "[-\\w.]+")) |
| 27 | + |
| 28 | +(s/def ::docker-tag |
| 29 | + (s/with-gen |
| 30 | + (s/and ::non-blank-string |
| 31 | + #(re-matches docker-tag-re %)) |
| 32 | + #(gen'/string-from-regex docker-tag-re))) |
| 33 | + |
20 | 34 | (s/def ::base-image-tag ::docker-image-name)
|
21 | 35 |
|
22 |
| -(s/def ::distro qualified-keyword?) |
| 36 | +(def distro-component-re (re-pattern "[-_A-Za-z][-\\w.]+")) |
| 37 | + |
| 38 | +(s/def ::distro |
| 39 | + (s/with-gen |
| 40 | + (s/and qualified-keyword? |
| 41 | + #(->> % |
| 42 | + ((juxt namespace name)) |
| 43 | + ((fn [elements] |
| 44 | + (every? (fn [e] (re-matches distro-component-re e)) |
| 45 | + elements))))) |
| 46 | + #(gen/fmap (fn [[namespace local]] (keyword namespace local)) |
| 47 | + (gen/vector (gen'/string-from-regex distro-component-re) 2)))) |
| 48 | + |
23 | 49 | (s/def ::distros (s/coll-of ::distro :distinct true :into #{}))
|
24 | 50 |
|
25 |
| -(s/def ::build-tool (s/or ::specific-tool ::non-blank-string |
26 |
| - ::all-tools #(= ::core/all %))) |
| 51 | +(s/def ::specific-build-tool #{"lein" "tools-deps"}) |
| 52 | +(s/def ::build-tool (s/or ::specific-tool ::specific-build-tool |
| 53 | + ::all-tools #{::core/all})) |
| 54 | +(s/def ::specific-build-tool-version |
| 55 | + (s/with-gen |
| 56 | + (s/and ::non-blank-string |
| 57 | + #(re-matches #"(?:\d+\.)+\d+" %)) |
| 58 | + #(gen/fmap (fn [nums] (str/join "." nums)) |
| 59 | + (gen/vector (gen/int) 2 4)))) |
| 60 | + |
27 | 61 | (s/def ::build-tool-version
|
28 |
| - (s/nilable (s/and ::non-blank-string #(re-matches #"[\d\.]+" %)))) |
29 |
| -(s/def ::build-tools (s/map-of ::build-tool ::build-tool-version)) |
| 62 | + (s/nilable ::specific-build-tool-version)) |
| 63 | + |
| 64 | +(s/def ::build-tool-versions |
| 65 | + (s/map-of ::specific-build-tool ::specific-build-tool-version)) |
30 | 66 |
|
31 | 67 | (s/def ::maintainers
|
32 | 68 | (s/coll-of ::non-blank-string :distinct true :into #{}))
|
| 69 | +(s/def ::maintainer ::non-blank-string) |
33 | 70 |
|
34 |
| -(s/def ::architecture ::non-blank-string) |
| 71 | +(s/def ::architecture #{"amd64" "arm64v8"}) |
35 | 72 | (s/def ::architectures (s/coll-of ::architecture :distinct true :into #{}))
|
36 | 73 |
|
37 | 74 | (def git-repo "https://github.com/Quantisan/docker-clojure.git")
|
|
55 | 92 | "debian" #{:debian-slim/bookworm-slim :debian/bookworm
|
56 | 93 | :debian-slim/bullseye-slim :debian/bullseye}})
|
57 | 94 |
|
58 |
| -(def default-architectures |
| 95 | +(def architectures |
59 | 96 | #{"amd64" "arm64v8"})
|
60 | 97 |
|
61 |
| -(def distro-architectures |
62 |
| - "Map of distro types to architectures it supports if different from |
63 |
| - default-architectures." |
64 |
| - {:alpine #{"amd64"}}) |
65 |
| - |
66 | 98 | (def default-distros
|
67 | 99 | "The default distro to use for tags that don't specify one, keyed by jdk-version.
|
68 | 100 | :default is a fallback for jdk versions not o/w specified."
|
|
84 | 116 | "1.12.0.1530" "2a113e3a4f1005e05f4d6a6dee24ca317b0115cdd7e6ca6155a76f5ffa5ba35b"}})
|
85 | 117 |
|
86 | 118 | (def exclusions ; don't build these for whatever reason(s)
|
87 |
| - #{; no more jammy builds for JDK 23+ |
| 119 | + #{;; No more jammy builds for JDK 23+ |
88 | 120 | {:jdk-version #(>= % 23)
|
89 | 121 | :distro :ubuntu/jammy}
|
90 |
| - ;; commented out example |
91 |
| - #_{:jdk-version 8 |
92 |
| - :distro :alpine/alpine}}) |
| 122 | + ;; No upstream ARM alpine images available before JDK 21 |
| 123 | + {:jdk-version #(< % 21) |
| 124 | + :architecture "arm64v8" |
| 125 | + :distro :alpine/alpine}}) |
93 | 126 |
|
94 | 127 | (def maintainers
|
95 | 128 | [ "Paul Lam <[email protected]> (@Quantisan)"
|
|
0 commit comments