-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJustfile
More file actions
91 lines (70 loc) · 2 KB
/
Justfile
File metadata and controls
91 lines (70 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
dockerfile := "Dockerfile"
image-name := "harbor.cyverse.org/de/apps"
tag := "latest"
platform := "linux/amd64"
build-context := "."
container-runtime := "docker"
build-flags := ""
default: uberjar
build: uberjar
uberjar:
lein do clean, uberjar
run:
lein ring server
repl:
lein repl
build-image:
{{ container-runtime }} build -f {{ build-context }}/{{ dockerfile }} -t {{ image-name }}:{{ tag }} --platform {{ platform }} {{ build-flags }} {{ build-context }}
push:
{{ container-runtime }} push {{ image-name }}:{{ tag }}
write-build-file output-file="build.json":
#!/usr/bin/env bash
set -euo pipefail
RUNTIME="{{ container-runtime }}"
IMAGE_NAME="{{ image-name }}"
IMAGE_TAG="{{ tag }}"
OUTPUT_FILE="{{ output-file }}"
FULL_IMAGE_TAG="${IMAGE_NAME}:${IMAGE_TAG}"
echo "Extracting sha256 digest from built image: ${FULL_IMAGE_TAG}"
SHA256_DIGEST=$($RUNTIME inspect --format='{{ "{{" }}index .RepoDigests 0{{ "}}" }}' "$FULL_IMAGE_TAG" 2>/dev/null || true)
# If RepoDigests is empty (image not pushed), get the image ID instead.
if [[ -z "$SHA256_DIGEST" ]]; then
IMAGE_ID=$($RUNTIME inspect --format='{{ "{{" }}.Id{{ "}}" }}' "$FULL_IMAGE_TAG" | cut -d: -f2)
if [[ -n "$IMAGE_ID" ]]; then
SHA256_DIGEST="${IMAGE_NAME}@sha256:${IMAGE_ID}"
echo "Using local image digest: $SHA256_DIGEST"
else
echo "Error: Failed to extract image digest for ${FULL_IMAGE_TAG}" >&2
exit 1
fi
else
echo "Using repo digest: $SHA256_DIGEST"
fi
echo "Writing build JSON to: $OUTPUT_FILE"
cat > "$OUTPUT_FILE" << EOF
{
"builds": [
{
"imageName": "$IMAGE_NAME",
"tag": "$SHA256_DIGEST"
}
]
}
EOF
test:
lein test
test-junit:
lein test2junit
lint:
lein eastwood
fmt-check:
lein cljfmt check
fmt-fix:
lein cljfmt fix
ancient:
lein ancient
deps:
lein deps
check: fmt-check lint test
clean:
lein clean