-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
125 lines (108 loc) · 3.67 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
version: '3'
vars:
IMAGE: toshy/ffconv
env:
UID:
sh: id -u
GID:
sh: id -g
DOCKER_COMPOSE_RUN: docker compose --progress quiet run --rm --build
tasks:
default:
cmds:
- task --list
# Docker
build:
desc: Build local images
vars:
TARGETS: [ 'dev', 'prod' ]
cmds:
- for:
var: TARGETS
cmd: docker buildx build --target {{.ITEM}} --tag {{.IMAGE}}:{{.ITEM}} .
down:
desc: Down service
cmds:
- docker compose down --remove-orphans
# Shell
shell:dev:
desc: Container shell
vars:
TARGET: 'dev'
cmds:
- $DOCKER_COMPOSE_RUN {{.TARGET}} {{.CLI_ARGS | default "/bin/bash"}}
shell:prod:
desc: Container shell prod
vars:
TARGET: 'prod'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
FONTS_DIRECTORY: '{{.o | default "fonts"}}'
cmds:
- docker buildx build --quiet --target {{.TARGET}} --tag {{.IMAGE}}:{{.TARGET}} .
- docker run -it -u $(id -u):$(id -g) -v ${PWD}/{{.INPUT_DIRECTORY}}:/app/input -v ${PWD}/{{.OUTPUT_DIRECTORY}}:/app/output -v ${PWD}/{{.FONTS_DIRECTORY}}:/app/fonts --entrypoint="/bin/bash" --rm {{.IMAGE}}:{{.TARGET}} {{.CLI_ARGS}}
# Test
dev:
desc: Test dev image (compose)
vars:
TARGET: 'dev'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
cmds:
- mkdir -p ${PWD}/{{.INPUT_DIRECTORY}} ${PWD}/{{.OUTPUT_DIRECTORY}}
- $DOCKER_COMPOSE_RUN -u $(id -u):$(id -g) {{.TARGET}} python -m ffconv {{.CLI_ARGS}}
prod:
desc: Test prod image (docker)
silent: true
vars:
TARGET: 'prod'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
FONTS_DIRECTORY: '{{.o | default "fonts"}}'
cmds:
- docker buildx build --quiet --target {{.TARGET}} --tag {{.IMAGE}}:{{.TARGET}} .
- mkdir -p ${PWD}/{{.INPUT_DIRECTORY}} ${PWD}/{{.OUTPUT_DIRECTORY}} ${PWD}/{{.FONTS_DIRECTORY}}
- docker run -it -u $(id -u):$(id -g) -v ${PWD}/{{.INPUT_DIRECTORY}}:/app/input -v ${PWD}/{{.OUTPUT_DIRECTORY}}:/app/output -v ${PWD}/{{.FONTS_DIRECTORY}}:/app/fonts --rm {{.IMAGE}}:{{.TARGET}} {{.CLI_ARGS}}
prod:gpu:
desc: Test prod image with GPU (docker)
silent: true
vars:
TARGET: 'prod'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
FONTS_DIRECTORY: '{{.o | default "fonts"}}'
cmds:
- docker buildx build --quiet --target {{.TARGET}} --tag {{.IMAGE}}:{{.TARGET}} .
- mkdir -p ${PWD}/{{.INPUT_DIRECTORY}} ${PWD}/{{.OUTPUT_DIRECTORY}} ${PWD}/{{.FONTS_DIRECTORY}}
- docker run -it --gpus all -u $(id -u):$(id -g) -v ${PWD}/{{.INPUT_DIRECTORY}}:/app/input -v ${PWD}/{{.OUTPUT_DIRECTORY}}:/app/output -v ${PWD}/{{.FONTS_DIRECTORY}}:/app/fonts --rm {{.IMAGE}}:{{.TARGET}} {{.CLI_ARGS}}
# Development tools
ruff:
desc: Run ruff
cmds:
- $DOCKER_COMPOSE_RUN dev ruff check .
ruff:fix:
desc: Run ruff fix
cmds:
- $DOCKER_COMPOSE_RUN dev ruff check --fix .
black:
desc: Run black
cmds:
- $DOCKER_COMPOSE_RUN dev black . --check --diff --color
black:fix:
desc: Run black fix
cmds:
- $DOCKER_COMPOSE_RUN dev black .
mypy:
desc: Run mypy
cmds:
- $DOCKER_COMPOSE_RUN dev mypy .
mkdocs:
desc: MkDocs build
cmds:
- docker run --rm -it -v ${PWD}:/docs ghcr.io/squidfunk/mkdocs-material:9.5 build
mkdocs:live:
desc: MkDocs development server
vars:
PORT: '{{.p | default "8001"}}'
cmds:
- docker run --rm -it -p {{.PORT}}:8000 -v ${PWD}:/docs ghcr.io/squidfunk/mkdocs-material:9.5