-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathTaskfile.docker.yml
More file actions
69 lines (62 loc) · 2.34 KB
/
Taskfile.docker.yml
File metadata and controls
69 lines (62 loc) · 2.34 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
version: '3'
silent: true
tasks:
docker:login:
desc: Login to hub.docker.com and ghcr.io
cmds:
- |
set -eu
docker_username='{{.DOCKER_USERNAME}}'
github_username='{{.GITHUB_USERNAME}}'
has_dockerhub=false
has_ghcr=false
if [ -n "$docker_username" ] && [ -n "${DOCKER_TOKEN:-}" ]; then
has_dockerhub=true
fi
if [ -n "$github_username" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
has_ghcr=true
fi
if [ "$has_dockerhub" = false ] && [ "$has_ghcr" = false ]; then
echo "❌ No registry credentials provided. Set DOCKER_USERNAME/DOCKER_TOKEN or GITHUB_USERNAME/GITHUB_TOKEN."
exit 1
fi
if [ "$has_dockerhub" = true ]; then
echo "Logging into Docker Hub as $docker_username"
printf '%s' "${DOCKER_TOKEN}" | docker login -u "$docker_username" --password-stdin
else
echo "⚠️ Skipping Docker Hub login (missing DOCKER_USERNAME/DOCKER_TOKEN)"
fi
if [ "$has_ghcr" = true ]; then
echo "Logging into GHCR as $github_username"
printf '%s' "${GITHUB_TOKEN}" | docker login ghcr.io -u "$github_username" --password-stdin
else
echo "⚠️ Skipping GHCR login (missing GITHUB_USERNAME/GITHUB_TOKEN)"
fi
docker:cmds:
desc: Show docker build command for plain flavor
cmds:
- task terragrunt:build:plain --dry VERSION_PREFIX='{{.CI_VERSION_PREFIX}}'
docker:build:
desc: Build Docker image (plain flavor)
cmds:
- task terragrunt:build:plain VERSION_PREFIX='{{.CI_VERSION_PREFIX}}'
docker:build:inspect:
desc: Inspect built Docker image (plain latest)
cmds:
- |
set -eu
image="{{.DOCKER_NAME}}:{{.CI_VERSION_PREFIX}}plain-latest"
echo "Inspecting image: ${image}"
docker image inspect "$image" | jq || true
docker:push:
desc: Build and push Docker images (plain flavor)
cmds:
- task terragrunt:push:plain VERSION_PREFIX='{{.CI_VERSION_PREFIX}}'
docker:push:inspect:
desc: Inspect pushed Docker image (plain latest)
cmds:
- |
set -eu
image="{{.DOCKER_NAME}}:{{.CI_VERSION_PREFIX}}plain-latest"
echo "Inspecting pushed image: ${image}"
docker buildx imagetools inspect "$image" || docker manifest inspect "$image"