-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yaml
93 lines (81 loc) · 3.14 KB
/
Taskfile.yaml
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
version: 3
silent: true
env:
CI_PROJECT_NAME: demo
CI_PROJECT_KEY: demo
CI_PROJECT_DOMAIN: example.com
CI_SERVICE_NAME: demo
CI_SERVICE_IMAGE_REPOSITORY_URL: docker.io/services
CI_SERVICE_URL_TYPE: 'path'
tasks:
default:
desc: Service Tasks
cmds:
- |
source ./docker/scripts/utils.sh
print_info "Available tasks:"
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 "service:get-metadata - Get Service Metadata for current environment (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"
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"
service:get-metadata:
desc: Get Service Metadata
cmds:
- ./docker/scripts/get-service-metadata.sh
service:run:
desc: Run the service locally
description: Run the service locally using Docker
cmds:
- |
SERVICE_IMAGE=$(./docker/scripts/cicd-entrypoint.sh | grep -E 'SERVICE\ IMAGE:' | awk -F': +' '{print $2}')
docker run --rm --name demo-app -p 8000:8000 $SERVICE_IMAGE
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:build
- task: service:run