-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
78 lines (70 loc) · 2.64 KB
/
Taskfile.yml
File metadata and controls
78 lines (70 loc) · 2.64 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
---
version: "3"
vars:
CNTRCTL:
sh: which docker || which nerdctl
tasks:
# go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
generate-openapi:
sources:
- openapi/packages.yaml
generates:
- internal/openapi/api.gen.go
cmds:
- mkdir -p internal/openapi
- go tool oapi-codegen -package api -o internal/openapi/api.gen.go openapi/packages.yaml
#- oapi-codegen -generate types -package api -o internal/openapi/types.gen.go openapi/packages.yaml
#- oapi-codegen -generate client -package api -o internal/openapi/client.gen.go openapi/packages.yaml
#- oapi-codegen -generate server -package api -o internal/openapi/server.gen.go openapi/packages.yaml
# - docker run -it --rm -v $PWD:/local openapitools/openapi-generator-cli generate \
# -i openapi/packages.yaml \
# -g go \
# -o /local/gen/packages
build:
env:
CGO_ENABLED: 0
cmds:
- go build -ldflags="-extldflags=-static -w -s" ./cmd/api
- go build -ldflags="-extldflags=-static -w -s" ./cmd/cli
test:
cmds:
- go test ./cmd/api ./internal/openapi
# build and push the latest, sha, and version tag
# this only gets run on tags
docker:release-prod:
deps: [generate-openapi]
cmds:
- |
{{- .CNTRCTL }} build \
-f Dockerfile \
--tag ghcr.io/atlascloud/packages:latest \
--tag ghcr.io/atlascloud/packages:$GITHUB_SHA \
--tag ghcr.io/atlascloud/packages:$GITHUB_REF \
.
# --cache-from ghcr.io/atlascloud/packages:latest .
# nerdctl doesn't have --pull
# --pull \
# - docker push ghcr.io/atlascloud/packages --all-tags
# push with just the sha tagged (no latest or version)
# this gets run on every push
# this has a soft dep on the build step, but I don't want to set it here in
# case I decide to split these docker steps into separate file(s)
docker:push-sha:
cmds:
- |
{{- .CNTRCTL }} build --pull -f Dockerfile --tag ghcr.io/atlascloud/packages:$GITHUB_SHA --cache-from ghcr.io/atlascloud/packages:latest .
- |
{{- .CNTRCTL }} push ghcr.io/atlascloud/packages:$GITHUB_SHA
docker:build:
deps: [generate-openapi]
cmds:
# this extra line is needed for some weird task reason /shrug
- |
{{- .CNTRCTL }} build -f Dockerfile.local -t packages .
docker:run:
deps: [docker:build]
cmds:
# 8008 is a special port on chromebooks
# https://www.reddit.com/r/Crostini/wiki/index/well-known-ports
- |
{{- .CNTRCTL }} run -it --rm -v $(pwd):/app -v /srv/packages:/srv/packages -p 8888:8888 packages