-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
194 lines (170 loc) · 6.42 KB
/
Taskfile.yaml
File metadata and controls
194 lines (170 loc) · 6.42 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
version: 3
silent: true
env:
CI_PROJECT_NAME: 4notes
CI_PROJECT_KEY: notes
CI_PROJECT_DOMAIN: graphql.4notes.app
CI_SERVICE_NAME: 4notes-graphql-api-service
CI_SERVICE_IMAGE_REPOSITORY_URL: docker.io/services
CI_SERVICE_URL_TYPE: 'path'
tasks:
default:
desc: 4Notes GraphQL API Service
cmds:
- |
source ./docker/scripts/utils.sh
print_info "Available tasks:"
print_info "start - Start local development server"
print_info ""
print_info "docker:login - Logging in to Docker Hub"
print_info "docker:login-ecr - Docker Login to Amazon ECR"
print_info "docker:build-preview - Preview Docker Build Environment"
print_info "docker:build - Build Docker Image"
print_info "docker:build-push - Build and Push Docker Images"
print_info ""
print_info "docker-compose - Docker Compose commands"
print_info "docker-compose:start - Start local development server with Docker Compose"
print_info "docker-compose:restart - Restart local development server with Docker Compose"
print_info "docker-compose:stop - Stop local development server with Docker Compose"
print_info "docker-compose:down - Stop and remove containers, networks, volumes created by Docker Compose"
print_info "docker-compose:build - Build Docker Compose services"
print_info "docker-compose:logs - Show logs of containers created by Docker Compose"
print_info ""
print_info "service - Run a command within the service container"
print_info "service:get-metadata - Get Service Metadata for current environment (JSON)"
print_info "service:get-environment - Get Service Environment Metadata for current environment as JSON"
print_info "service:run - Run the service locally using Docker"
print_info "service:run-build - Build image for current branch and run the service locally using Docker"
print_info "service:test - Run tests in the service container"
print_info ""
start:
desc: Start local development server
cmds:
- npm run start:dev -- -b swc
docker:login:
desc: Logging in to Docker Hub
requires:
vars: [DOCKER_HUB_USERNAME, DOCKER_HUB_PASSWORD]
cmds:
- echo "◈ Logging in to Docker Hub Registry"
- docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
docker:login-ecr:
desc: Docker Login to Amazon ECR
requires:
vars: [AWS_ECR_ACCOUNT_ID, AWS_ECR_REGION]
cmds:
- echo "◈ Logging in to Amazon ECR"
- |
aws ecr get-login-password --region $AWS_ECR_REGION | \
docker login --username AWS --password-stdin $AWS_ECR_ACCOUNT_ID.dkr.ecr.$AWS_ECR_REGION.amazonaws.com
docker:build-preview:
desc: Preview Docker Build Environment
required:
vars: [CI_SERVICE_IMAGE_REPOSITORY_URL]
cmds:
- echo "◈ Preview Docker Build Environment"
- ./docker/scripts/cicd-entrypoint.sh
docker:build:
desc: Build Docker Images
required:
vars: [CI_SERVICE_IMAGE_REPOSITORY_URL]
cmds:
- echo "◈ Building Docker Image"
- |
# IMPORTANT: We have to source scripts in a non-interactive sub-shell to avoid "unbound variable" errors
bash -c "source ./docker/scripts/cicd-entrypoint.sh && ./docker/scripts/docker-build.sh"
docker:build-push:
desc: Build and Push Docker Images
required:
vars: [CI_SERVICE_IMAGE_REPOSITORY_URL]
cmds:
- echo "◈ Building Docker Image and pushing to the registry..."
- |
bash -c "source ./docker/scripts/cicd-entrypoint.sh && ./docker/scripts/docker-build.sh --push"
# Example: task docker-compose -- build
docker-compose:
desc: Docker Compose commands
cmds:
- |
docker-compose \
--file ./docker/docker-compose.yaml \
--env-file ./docker/docker-compose.env \
--project-directory ./ \
{{.CLI_ARGS}}
docker-compose:start:
desc: Start local development server with Docker Compose
cmds:
- |
docker-compose \
--file ./docker/docker-compose.yaml \
--env-file ./docker/docker-compose.env \
--project-directory ./ \
up --detach --remove-orphans
docker-compose:restart:
desc: Restart local development server with Docker Compose
cmds:
- |
docker-compose \
--file ./docker/docker-compose.yaml \
--env-file ./docker/docker-compose.env \
--project-directory ./ \
restart
docker-compose:stop:
desc: Stop local development server with Docker Compose
cmds:
- |
docker-compose \
--file ./docker/docker-compose.yaml \
--env-file ./docker/docker-compose.env \
--project-directory ./ \
stop
docker-compose:down:
desc: Stop and remove containers, networks, volumes created by Docker Compose
cmds:
- |
docker-compose \
--file ./docker/docker-compose.yaml \
--env-file ./docker/docker-compose.env \
--project-directory ./ \
down
docker-compose:build:
desc: Build Docker Compose services
cmds:
- |
docker-compose \
--file ./docker/docker-compose.yaml \
--env-file ./docker/docker-compose.env \
--project-directory ./ \
build
docker-compose:logs:
desc: Show logs of containers created by Docker Compose
cmds:
- |
docker-compose \
--file ./docker/docker-compose.yaml \
--env-file ./docker/docker-compose.env \
--project-directory ./ \
logs -f
service:get-metadata:
desc: Get Service Metadata
cmds:
- ./docker/scripts/get-service-metadata.sh
service:get-environment:
desc: Get Service Environment Metadata as JSON
cmds:
- ./docker/scripts/get-service-environment.sh
service:run:
desc: Run the service locally
description: Run the service locally using Docker
cmds:
- task: docker-compose:start
service:run-build:
desc: Build image and run the service locally
description: Build image for current branch and run the service locally using Docker
cmds:
- task: docker-compose:build
- task: docker-compose:start
service:
desc: Run a command within the service container
cmds:
- docker exec 4notes-graphql-api-service {{.CLI_ARGS}}