-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
64 lines (50 loc) · 2.4 KB
/
justfile
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
namespace := "dotmh"
devcontainer := "devcontainer"
default_dockerfile := "Dockerfile"
registry := "ghcr.io"
latest := "latest"
version_file := '.version'
version := `\cat .version`
reports := "./reports"
# Build a docker container
build CONTAINER=devcontainer DOCKERFILE=default_dockerfile BASE=devcontainer:
docker build -f ./containers/{{DOCKERFILE}} . --tag {{namespace}}/{{CONTAINER}}:{{version}} --tag {{registry}}/{{namespace}}/{{CONTAINER}}:{{version}} --tag {{registry}}/{{namespace}}/{{CONTAINER}}:latest --build-arg base={{BASE}}
# Runs a ZSH shell on a docker container
run CONTAINER=devcontainer:
@echo "running {{CONTAINER}} version {{version}}"
docker run -it {{namespace}}/{{CONTAINER}}:{{version}} /bin/zsh
# Runs a Trivy scan on the container
scan CONTAINER=devcontainer:
mkdir -p {{reports}}
which -s trivy && trivy image {{namespace}}/{{CONTAINER}} --output {{reports}}/{{CONTAINER}}-scan.log
# Publish a docker container to the registry
publish USERNAME CONTAINER=devcontainer: mac-unlock (login USERNAME) && (_publish CONTAINER)
# Publish within a Github action to the registry
action-publish CONTAINER USERNAME : (login USERNAME) && (_publish CONTAINER)
# Login to the registry within Github action to the registry
login USERNAME:
echo $DOCKER_GIT_LOGIN | docker login {{registry}} --username {{USERNAME}} --password-stdin
# Show the version of the repo
version:
./simver.bash validate {{version}}
@echo {{version}}
# Set the current version to a new version
version-set VERSION: && (_setTemplatesVersion)
./simver.bash validate {{VERSION}}
@echo {{VERSION}} > {{version_file}}
# Bump the major simver version
version-bump-major: version && (_setTemplatesVersion)
./simver.bash bump major {{version}} > {{version_file}}
# Bump the minor simver version
version-bump-minor: version && (_setTemplatesVersion)
./simver.bash bump minor {{version}} > {{version_file}}
# Bump the patch simver version
version-bump-patch: version && (_setTemplatesVersion)
./simver.bash bump patch {{version}} > {{version_file}}
# On MacOS __ONLY__ unlock the keychain, required for some docker interactions.
mac-unlock:
security unlock-keychain || true
_publish CONTAINER=devcontainer:
docker push -a {{registry}}/{{namespace}}/{{CONTAINER}}
_setTemplatesVersion:
find . -name 'devcontainer-template.json' -type f -exec sed -i '' -e 's/[0-9]\.[0-9]\.[0-9]/{{`\cat .version`}}/g' {} \;