-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
70 lines (59 loc) · 1.61 KB
/
Taskfile.yml
File metadata and controls
70 lines (59 loc) · 1.61 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
version: '3'
vars:
IMAGE_NAME: next-js-app
IMAGE_TAG: latest
CONTAINER_NAME: next-js-app-container
HOST_PORT: 3000
CONTAINER_PORT: 8080
DOCKERFILE: Dockerfile.export
NODE_VERSION: 22.14.0-alpine
NGINX_VERSION: alpine3.21
NODE_ENV: production
tasks:
build:
desc: "Build the Docker image"
cmds:
- docker build
--build-arg NODE_VERSION={{.NODE_VERSION}}
--build-arg NGINX_VERSION={{.NGINX_VERSION}}
-f {{.DOCKERFILE}} -t {{.IMAGE_NAME}}:{{.IMAGE_TAG}} .
run:
desc: "Run the Docker container"
cmds:
- docker rm -f {{.CONTAINER_NAME}} 2>/dev/null
- docker run -d --name {{.CONTAINER_NAME}} -p {{.HOST_PORT}}:{{.CONTAINER_PORT}} {{.IMAGE_NAME}}:{{.IMAGE_TAG}}
build-run:
desc: "Build and run the Docker container in one step"
cmds:
- task: build
- task: run
stop:
desc: "Stop the running Docker container"
cmds:
- docker stop {{.CONTAINER_NAME}}
restart:
desc: "Restart the Docker container"
cmds:
- task: stop
- task: run
logs:
desc: "Show real-time logs from the Docker container"
cmds:
- docker logs -f {{.CONTAINER_NAME}}
clean:
desc: "Remove the Docker container and image"
cmds:
- task: clean-container
- task: clean-image
clean-container:
desc: "Remove the Docker container only"
cmds:
- docker rm -f {{.CONTAINER_NAME}} 2>/dev/null
clean-image:
desc: "Remove the Docker image only"
cmds:
- docker rmi {{.IMAGE_NAME}}:{{.IMAGE_TAG}} 2>/dev/null
default:
desc: "Show available commands"
cmds:
- task --list