Skip to content

Commit 0611c3d

Browse files
committed
feat: adds a complete set of toolbox tasks
1 parent a4631cd commit 0611c3d

File tree

1 file changed

+65
-28
lines changed

1 file changed

+65
-28
lines changed

lib/toolbox/Taskfile.yaml

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,96 @@
11
# See more information in docs/toolbox.md
22
version: "3"
33
vars:
4-
IMAGE_NAME: toolbox
5-
LATEST_IMAGE_TAG: "{{.IMAGE_NAME}}:latest"
6-
VERSION_IMAGE_TAG: "{{.IMAGE_NAME}}:{{.VERSION}}"
74
VERSION:
85
sh: git rev-parse --short HEAD
9-
REGISTRY_URL_FULL: "{{.REGISTRY_URL}}/{{.LATEST_IMAGE_TAG}}"
10-
CONTAINERFILE_PATH: '{{.CONTAINERFILE_PATH | default "./Dockerfile"}}'
6+
TOOLBOX_NAME: '{{.TOOLBOX_NAME | default "toolbox"}}'
7+
LATEST_IMAGE_TAG: "{{.TOOLBOX_NAME}}:latest"
8+
VERSION_IMAGE_TAG: "{{.TOOLBOX_NAME}}:{{.VERSION}}"
9+
REGISTRY_LATEST_URL: "{{.REGISTRY_URL_BASE}}/{{.LATEST_IMAGE_TAG}}"
10+
REGISTRY_VERSION_URL: "{{.REGISTRY_URL_BASE}}/{{.VERSION_IMAGE_TAG}}"
11+
CONTAINERFILE_PATH: '{{.CONTAINERFILE_PATH | default "./Containerfile"}}'
1112
AWS_REGION: '{{.AWS_REGION | default "us-east-1"}}'
1213

1314
tasks:
14-
all:
15+
auth:
16+
desc: Authenticate to AWS ECR
17+
internal: true
18+
requires:
19+
vars:
20+
- AWS_REGION
21+
- REGISTRY_URL_BASE
22+
cmds:
23+
- aws ecr get-login-password --region {{.AWS_REGION}} | docker login --username AWS --password-stdin {{.REGISTRY_URL_BASE}}
24+
25+
install:
26+
desc: Install wrapper script from geodesic container
27+
internal: true
28+
requires:
29+
vars:
30+
- TOOLBOX_NAME
31+
cmds:
32+
- docker run --rm {{.REGISTRY_LATEST_URL}} init | bash -s {{.TOOLBOX_NAME}}
33+
34+
run:build:
1535
desc: Build, install, and run the toolbox image
1636
cmds:
1737
- task: build
18-
- task: install
1938
- task: run
2039

40+
run:pull:
41+
desc: Pull, install, and run the toolbox image
42+
cmds:
43+
- task: pull
44+
- task: run
45+
46+
clean:
47+
desc: Cleans all toolbox images off of the local machine
48+
prompt: Are you sure you want to clean all {{.TOOLBOX_NAME}} toolbox images off of the local machine?
49+
cmds:
50+
- docker rmi $(docker images --format '{{ "{{" }}.Repository{{ "}}" }}:{{ "{{" }}.Tag{{ "}}" }}' | grep '{{.TOOLBOX_NAME}}')
51+
2152
build:
2253
desc: Build and tag our toolbox image
2354
requires:
2455
vars:
25-
- IMAGE_NAME
56+
- TOOLBOX_NAME
2657
- CONTAINERFILE_PATH
2758
cmds:
28-
- "docker build --tag {{.LATEST_IMAGE_TAG}} --tag {{.VERSION_IMAGE_TAG}} -f {{.CONTAINERFILE_PATH}} ."
59+
- |
60+
docker build --tag {{.LATEST_IMAGE_TAG}} \
61+
--tag {{.VERSION_IMAGE_TAG}} \
62+
--tag {{.REGISTRY_LATEST_URL}} \
63+
--tag {{.REGISTRY_VERSION_URL}} \
64+
-f {{.CONTAINERFILE_PATH}} .
2965
- echo "Done building and tagging toolbox 💯 Tagged as {{.VERSION_IMAGE_TAG}} + {{.LATEST_IMAGE_TAG}}"
3066

31-
install:
32-
desc: Install wrapper script from geodesic container
33-
requires:
34-
vars:
35-
- IMAGE_NAME
67+
run:
68+
desc: Run our toolbox image while also mounting your $HOME folder to `/localhost` in the container
69+
deps:
70+
- install
3671
cmds:
37-
- docker run --rm {{.LATEST_IMAGE_TAG}} init | bash -s {{.IMAGE_NAME}} || (echo 'Try "sudo make install"'; exit 1)
72+
- "{{.TOOLBOX_NAME}}"
3873

3974
pull:
4075
desc: Pull our toolbox image from registry
76+
deps:
77+
- auth
4178
requires:
4279
vars:
4380
- REGISTRY_URL_BASE
44-
- REGISTRY_URL_FULL
81+
- REGISTRY_LATEST_URL
4582
cmds:
46-
- |
47-
aws ecr get-login-password --region $(AWS_REGION) | docker login --username AWS --password-stdin {{.REGISTRY_URL_BASE}}
48-
docker pull {{.REGISTRY_URL_FULL}}
83+
- docker pull {{.REGISTRY_LATEST_URL}}
84+
- docker tag {{.REGISTRY_LATEST_URL}} {{.LATEST_IMAGE_TAG}}
4985

50-
run:
51-
desc: Run our toolbox image while also mounting your $HOME folder to `/localhost` in the container
86+
publish:
87+
desc: Publish our toolbox image to the registry
88+
deps:
89+
- auth
90+
requires:
91+
vars:
92+
- REGISTRY_URL_BASE
93+
- REGISTRY_LATEST_URL
5294
cmds:
53-
- "{{.IMAGE_NAME}}"
54-
# TODO
55-
# ## Publish the toolbox image to our ECR repo
56-
# publish: build
57-
# @export VERSION=$(shell git rev-parse --short HEAD); \
58-
# make docker/image/push TARGET_VERSION=$$VERSION
59-
# make docker/image/push TARGET_VERSION=latest;
95+
- docker push {{.REGISTRY_LATEST_URL}}
96+
- docker push {{.REGISTRY_VERSION_URL}}

0 commit comments

Comments
 (0)