-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbatect.yml
More file actions
152 lines (151 loc) · 4.22 KB
/
Copy pathbatect.yml
File metadata and controls
152 lines (151 loc) · 4.22 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
containers:
build-env:
image: mcr.microsoft.com/dotnet/core/sdk:3.1
volumes:
- local: .
container: /code
options: cached
- type: cache
name: nuget-cache
container: /root/.nuget/packages
- type: cache
name: weatherApi-obj
container: /code/src/WeatherApi/obj
- type: cache
name: weatherApi-tests-obj
container: /code/src/WeatherApi.Tests/obj
working_directory: /code
postgres:
build_directory: db/tests
ports:
- local: 5432
container: 5432
setup_commands:
- command: /scripts/run-migrations-integration-tests.sh
volumes:
- local: db/migrations
container: /migrations
options: cached
- local: db/scripts
container: /scripts
options: cached
environment:
POSTGRES_DB: weather_db
POSTGRES_USER: weather_user
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
POSTGRES_HOST: postgres
POSTGRES_PORT: "5432"
POSTGRES_SCHEMA_NAME: public
POSTGRES_MIGRATIONS_LOCATION: filesystem:/migrations
flyway-migrator:
build_directory: db
volumes:
- local: db/migrations
container: /migrations
options: cached
- local: db/scripts
container: /scripts
options: cached
environment:
DB_PORT: "5432"
DB_SCHEMA_NAME: public
DB_MIGRATIONS_LOCATION: filesystem:/migrations
pulumi:
image: pulumi/pulumi:v3.10.3
working_directory: /app
volumes:
- local: infra
container: /app
options: cached
- local: /var/run/docker.sock
container: /var/run/docker.sock
environment:
APP_NAME: $APP_NAME
GOOGLE_CREDENTIALS: $GOOGLE_CREDENTIALS
GOOGLE_SERVICE_ACCOUNT: $GOOGLE_SERVICE_ACCOUNT
GOOGLE_PROJECT: $GOOGLE_PROJECT
GOOGLE_REGION: $GOOGLE_REGION
PULUMI_ACCESS_TOKEN: $PULUMI_ACCESS_TOKEN
GITHUB_SHA: $GITHUB_SHA
entrypoint: bash
gcloud-sdk:
image: google/cloud-sdk:353.0.0-alpine
working_directory: /app
volumes:
- local: .
container: /app
options: cached
- local: /var/run/docker.sock
container: /var/run/docker.sock
environment:
APP_NAME: $APP_NAME
GOOGLE_CREDENTIALS: $GOOGLE_CREDENTIALS
GOOGLE_PROJECT: $GOOGLE_PROJECT
GITHUB_SHA: $GITHUB_SHA
tasks:
build:
description: Build Weather API
run:
container: build-env
command: dotnet build
start-integration-test-db:
description: Start DB with migrations applied for locally running integration tests
run:
container: postgres
test:
description: Test Weather API
run:
container: build-env
command: dotnet test
environment:
ASPNETCORE_ENVIRONMENT: test
WEATHERDB__PASSWORD: $POSTGRES_PASSWORD
dependencies:
- postgres
deploy-iam:
description: Deploy IAM using Pulumi
run:
container: pulumi
command: deploy-iam.sh
deploy-infra:
description: Deploy infra using Pulumi
run:
container: pulumi
command: deploy-infra.sh
environment:
DB_NAME: $DB_NAME
DB_USERNAME: $DB_USERNAME
migrate-db:
description: Run database migrations
run:
container: flyway-migrator
entrypoint: /scripts/run-migrations-gcloud.sh
environment:
GOOGLE_PROJECT: $GOOGLE_PROJECT
GOOGLE_REGION: $GOOGLE_REGION
GOOGLE_CREDENTIALS: $GOOGLE_CREDENTIALS
DB_INSTANCE: $DB_INSTANCE
DB_HOST: localhost
DB_NAME: $DB_NAME
DB_USERNAME: $DB_USERNAME
DB_PASSWORD_SECRET_ID: $DB_PASSWORD_SECRET_ID
DB_PASSWORD_SECRET_VERSION: $DB_PASSWORD_SECRET_VERSION
build-scan-image:
description: Build and scan docker image for vulnerabilities
run:
container: gcloud-sdk
command: infra/build-scan-image.sh
push-image:
description: Push docker image to GCR
run:
container: gcloud-sdk
command: infra/push-image.sh
deploy:
description: Deploy Weather API to GCP Cloud Run using Pulumi
run:
container: pulumi
command: deploy-app.sh
environment:
GOOGLE_RUN_SERVICE_ACCOUNT: $GOOGLE_RUN_SERVICE_ACCOUNT
DB_INSTANCE: $DB_INSTANCE
ENVIRONMENT: $ENVIRONMENT