-
Notifications
You must be signed in to change notification settings - Fork 3
/
skaffold.production.yaml
186 lines (173 loc) · 7.14 KB
/
skaffold.production.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
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
# Does the production setup, however for safety reasons, this defaults to the test enviroment and does not push images by default.
# If you want to do a production deploy or you want to push images, you have to activate profiles for those things.
# The filename has production instead of test because the test enviroment matches the production enviroment -- it just runs locally.
# How building works:
# For each deployed service, we build two images: a build cache image and a slim image that is used for the deployment. The slim image depends on the cache image and will be built after the cache image. The cache image can be very big (many gigabytes) and slim image should be much smaller (like a couple hunderd megabytes).
# The two different images are built with Docker's multi-stage builds (https://docs.docker.com/develop/develop-images/multistage-build/) -- we just specify which target we want for each image. The latter build will use the Docker build cache from the previous build so we don't execute the build steps twice.
apiVersion: skaffold/v3
kind: Config
build:
artifacts:
# headless-lms
- image: eu.gcr.io/moocfi-public/secret-project-headless-lms-production-build-cache
context: services/headless-lms
docker:
dockerfile: Dockerfile.production.cache.dockerfile
cacheFrom:
- eu.gcr.io/moocfi-public/secret-project-headless-lms-production-build-cache:latest
- image: eu.gcr.io/moocfi-public/secret-project-headless-lms-production-slim
context: services/headless-lms
docker:
dockerfile: Dockerfile.production.slim.dockerfile
requires:
- image: eu.gcr.io/moocfi-public/secret-project-headless-lms-production-build-cache
alias: BUILD_CACHE
# cms
- image: eu.gcr.io/moocfi-public/secret-project-cms-production-build-cache
context: services/cms
docker:
dockerfile: Dockerfile.production.cache.dockerfile
cacheFrom:
- eu.gcr.io/moocfi-public/secret-project-cms-production-build-cache:latest
- image: eu.gcr.io/moocfi-public/secret-project-cms-production-slim
context: services/cms
docker:
dockerfile: Dockerfile.production.slim.dockerfile
requires:
- image: eu.gcr.io/moocfi-public/secret-project-cms-production-build-cache
alias: BUILD_CACHE
# course-material
- image: eu.gcr.io/moocfi-public/secret-project-course-material-production-build-cache
context: services/course-material
docker:
dockerfile: Dockerfile.production.cache.dockerfile
cacheFrom:
- eu.gcr.io/moocfi-public/secret-project-course-material-production-build-cache:latest
- image: eu.gcr.io/moocfi-public/secret-project-course-material-production-slim
context: services/course-material
docker:
dockerfile: Dockerfile.production.slim.dockerfile
requires:
- image: eu.gcr.io/moocfi-public/secret-project-course-material-production-build-cache
alias: BUILD_CACHE
# main-frontend
- image: eu.gcr.io/moocfi-public/secret-project-main-frontend-production-build-cache
context: services/main-frontend
docker:
dockerfile: Dockerfile.production.cache.dockerfile
cacheFrom:
- eu.gcr.io/moocfi-public/secret-project-main-frontend-production-build-cache:latest
- image: eu.gcr.io/moocfi-public/secret-project-main-frontend-production-slim
context: services/main-frontend
docker:
dockerfile: Dockerfile.production.slim.dockerfile
requires:
- image: eu.gcr.io/moocfi-public/secret-project-main-frontend-production-build-cache
alias: BUILD_CACHE
# example-exercise
- image: eu.gcr.io/moocfi-public/secret-project-example-exercise-production-build-cache
context: services/example-exercise
docker:
dockerfile: Dockerfile.production.cache.dockerfile
cacheFrom:
- eu.gcr.io/moocfi-public/secret-project-example-exercise-production-build-cache:latest
- image: eu.gcr.io/moocfi-public/secret-project-example-exercise-production-slim
context: services/example-exercise
docker:
dockerfile: Dockerfile.production.slim.dockerfile
requires:
- image: eu.gcr.io/moocfi-public/secret-project-example-exercise-production-build-cache
alias: BUILD_CACHE
# quizzes
- image: eu.gcr.io/moocfi-public/secret-project-quizzes-production-build-cache
context: services/quizzes
docker:
dockerfile: Dockerfile.production.cache.dockerfile
cacheFrom:
- eu.gcr.io/moocfi-public/secret-project-quizzes-production-build-cache:latest
- image: eu.gcr.io/moocfi-public/secret-project-quizzes-production-slim
context: services/quizzes
docker:
dockerfile: Dockerfile.production.slim.dockerfile
requires:
- image: eu.gcr.io/moocfi-public/secret-project-quizzes-production-build-cache
alias: BUILD_CACHE
# tmc
- image: eu.gcr.io/moocfi-public/secret-project-tmc-production-build-cache
context: services/tmc
docker:
dockerfile: Dockerfile.production.cache.dockerfile
cacheFrom:
- eu.gcr.io/moocfi-public/secret-project-tmc-production-build-cache:latest
- image: eu.gcr.io/moocfi-public/secret-project-tmc-production-slim
context: services/tmc
docker:
dockerfile: Dockerfile.production.slim.dockerfile
requires:
- image: eu.gcr.io/moocfi-public/secret-project-tmc-production-build-cache
alias: BUILD_CACHE
tagPolicy:
# Default tag policy
gitCommit:
variant: CommitSha
local:
useDockerCLI:
true
# Allow parallel builds
concurrency: 0
push: false
manifests:
kustomize:
paths:
- kubernetes/test
deploy:
kubeContext: minikube
kubectl:
hooks:
before:
- host:
command:
[
"sh",
"-c",
"echo 'Waiting for the ingress to be ready.' && echo '> kubectl wait --namespace ingress-nginx --for=condition=available deployment/ingress-nginx-controller' && kubectl wait --namespace ingress-nginx --for=condition=available deployment/ingress-nginx-controller",
]
portForward:
- resourceType: statefulset
resourceName: postgres
namespace: default
port: 5432
localPort: 54328
- resourceType: statefulset
resourceName: redis
namespace: default
port: 6379
localPort: 63798
profiles:
# Push builds to moocfi-public
- name: push-images
patches:
- op: add
path: /build/local/push
value: true
- name: production
patches:
# Allow all kube contexes
- op: remove
path: /deploy/kubeContext
# Replace which folder to use
- op: replace
path: /manifests/kustomize/paths
value:
- kubernetes/production
# No need to wait for ingress in production
- op: remove
path: /deploy/kubectl
# Used to push the latest tag in ci, used for caching.
- name: latest-tag
patches:
- op: replace
path: /build/tagPolicy
value:
# sha256 tag policy pushes the latest tag, which is used for caching
sha256: {}