-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
134 lines (117 loc) · 3.28 KB
/
Taskfile.yml
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
version: "3"
silent: true
vars:
DOCKER_REPO: ghcr.io
DOCKER_OWNER: ilyes512
DOCKER_IMAGE_NAME: kubico
# Latatest version of Hadolint: https://hub.docker.com/r/hadolint/hadolint/tags or https://github.com/hadolint/hadolint/releases
HADOLINT_TAG_VERSION: v2.12.0
EXE: kubico{{exeExt}}
# Latest version of Node: https://hub.docker.com/_/node/
NODE_TAG_VERSION: 18.18.0-bullseye
NODE_NPM_VOLUME: kubico_node_npm
tasks:
run:
desc: Build and run the web app
interactive: true
cmds:
- go run .
build:
desc: Build the web app
cmds:
- go generate
- go build -v -o {{.EXE}}
cleanup:
desc: Cleanup workspace
cmds:
- docker volume rm {{.NODE_NPM_VOLUME}} > /dev/null 2>&1 || true
- git clean -Xd --force
go-get:
cmds:
- go get -u {{.REPO}}
########################################################################################################################
#
# Docker
#
########################################################################################################################
d:build:
desc: Build docker container
deps: [d:lint]
cmds:
- docker build
--tag {{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:debian
--build-arg=GOARCH={{ARCH}}
--target debian
.
- docker build
--tag {{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:scratch
--build-arg=GOARCH={{ARCH}}
.
d:run:
desc: Run the container
deps: [d:build]
interactive: true
vars:
ENV_EXISTS:
sh: if [ -s .env ]; then echo 1; else echo 0; fi
cmds:
- docker run
--tty
--interactive
--rm
--publish 8080:8080
{{if eq .ENV_EXISTS "1"}} --volume $(pwd)/.env:/.env {{end}}
{{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:scratch
d:lint:
desc: Apply a Dockerfile linter (https://github.com/hadolint/hadolint)
cmds:
- docker run
--interactive
--rm
--volume $(pwd)/.hadolint.yml:/.hadolint.yml
hadolint/hadolint:{{.HADOLINT_TAG_VERSION}}
hadolint
-
< Dockerfile
########################################################################################################################
#
# NODE / NPM
#
########################################################################################################################
node:run:
cmds:
- docker run
--rm
--interactive
--tty
--env npm_config_cache=/tmp/npmcache
--user $(id -u):$(id -g)
--volume $(pwd):/src
--workdir /src/assets
node:{{.NODE_TAG_VERSION}} {{.RUN_CMD}}
node:shell:
desc: Opens up "assets"-dir in a container with NodeJS
interactive: true
cmds:
- task: node:run
vars: { RUN_CMD: bash }
node:install:
desc: Run "npm install"
cmds:
- task: node:run
vars: { RUN_CMD: npm ci }
node:update:
desc: Run "npm update"
cmds:
- task: node:run
vars: { RUN_CMD: npm update }
node:dev:
desc: Run "npm run development"
cmds:
- task: node:run
vars: { RUN_CMD: npm run dev }
node:prd:
desc: Run "npm run production"
cmds:
- task: node:run
vars: { RUN_CMD: npm run prod }