-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.tex.yaml
More file actions
126 lines (119 loc) · 5.14 KB
/
Copy pathcloudbuild.tex.yaml
File metadata and controls
126 lines (119 loc) · 5.14 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
options:
logging: CLOUD_LOGGING_ONLY
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- -f
- Dockerfile.tex
- -t
- ${_IMAGE_URI}
- .
- name: gcr.io/cloud-builders/docker
args:
- push
- ${_IMAGE_URI}
- name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
entrypoint: bash
args:
- -ceu
- |
if [ -z "${_TEX_PREVIEW_BUCKET}" ] || [ "${_TEX_PREVIEW_BUCKET}" = "__SET_ME__" ]; then
echo "_TEX_PREVIEW_BUCKET must be configured for Cloud Run deployments." >&2
exit 1
fi
if [ -z "${_TEX_TASK_QUEUE}" ] || [ -z "${_TEX_TASK_LOCATION}" ]; then
echo "Cloud Tasks queue is not configured. TeX service will use local background processing."
elif ! gcloud tasks queues describe "${_TEX_TASK_QUEUE}" --location="${_TEX_TASK_LOCATION}" >/dev/null 2>&1; then
gcloud tasks queues create "${_TEX_TASK_QUEUE}" --location="${_TEX_TASK_LOCATION}"
fi
cat > /workspace/tex-worker-env.yaml <<EOF
TEX_COMPILE_TIMEOUT_MS: "${_TEX_COMPILE_TIMEOUT_MS}"
TEX_MAX_SOURCE_BYTES: "${_TEX_MAX_SOURCE_BYTES}"
TEX_MAX_REQUEST_BYTES: "${_TEX_MAX_REQUEST_BYTES}"
TEX_MAX_CONCURRENCY: "${_TEX_MAX_CONCURRENCY}"
TEX_ALLOW_ALL_PACKAGES: "${_TEX_ALLOW_ALL_PACKAGES}"
TEX_ALLOW_RAW_DOCUMENT: "${_TEX_ALLOW_RAW_DOCUMENT}"
TEX_ALLOW_RESTRICTED_COMMANDS: "${_TEX_ALLOW_RESTRICTED_COMMANDS}"
TEX_ALLOWED_PACKAGES: "${_TEX_ALLOWED_PACKAGES}"
TEX_PREVIEW_BUCKET: "${_TEX_PREVIEW_BUCKET}"
TEX_PREVIEW_URL_TTL_SECONDS: "${_TEX_PREVIEW_URL_TTL_SECONDS}"
NODE_OPTIONS: "${_WORKER_NODE_OPTIONS}"
EOF
gcloud run deploy "${_WORKER_SERVICE_NAME}" \
--image="${_IMAGE_URI}" \
--region="${_REGION}" \
--platform=managed \
--allow-unauthenticated \
--port=8082 \
--command=node \
--args=server-dist/texWorker.js \
--memory="${_WORKER_RUN_MEMORY}" \
--cpu="${_WORKER_RUN_CPU}" \
--concurrency="${_WORKER_RUN_CONCURRENCY}" \
--max-instances="${_WORKER_RUN_MAX_INSTANCES}" \
--ingress=all \
--service-account="${_RUN_SERVICE_ACCOUNT}" \
--env-vars-file=/workspace/tex-worker-env.yaml \
--update-secrets="TEX_SERVICE_AUTH_TOKEN=${_TEX_SERVICE_AUTH_TOKEN_SECRET}:latest"
WORKER_URL="$(gcloud run services describe "${_WORKER_SERVICE_NAME}" --region="${_REGION}" --format='value(status.url)')"
cat > /workspace/tex-service-env.yaml <<EOF
TEX_COMPILE_TIMEOUT_MS: "${_TEX_COMPILE_TIMEOUT_MS}"
TEX_MAX_SOURCE_BYTES: "${_TEX_MAX_SOURCE_BYTES}"
TEX_MAX_REQUEST_BYTES: "${_TEX_MAX_REQUEST_BYTES}"
TEX_MAX_CONCURRENCY: "${_TEX_MAX_CONCURRENCY}"
TEX_ALLOW_ALL_PACKAGES: "${_TEX_ALLOW_ALL_PACKAGES}"
TEX_ALLOW_RAW_DOCUMENT: "${_TEX_ALLOW_RAW_DOCUMENT}"
TEX_ALLOW_RESTRICTED_COMMANDS: "${_TEX_ALLOW_RESTRICTED_COMMANDS}"
TEX_ALLOWED_PACKAGES: "${_TEX_ALLOWED_PACKAGES}"
TEX_PREVIEW_BUCKET: "${_TEX_PREVIEW_BUCKET}"
TEX_PREVIEW_URL_TTL_SECONDS: "${_TEX_PREVIEW_URL_TTL_SECONDS}"
TEX_TASK_QUEUE: "${_TEX_TASK_QUEUE}"
TEX_TASK_LOCATION: "${_TEX_TASK_LOCATION}"
TEX_JOB_WORKER_URL: "$${WORKER_URL}"
NODE_OPTIONS: "${_NODE_OPTIONS}"
EOF
gcloud run deploy "${_SERVICE_NAME}" \
--image="${_IMAGE_URI}" \
--region="${_REGION}" \
--platform=managed \
--no-allow-unauthenticated \
--port=8081 \
--memory="${_RUN_MEMORY}" \
--cpu="${_RUN_CPU}" \
--concurrency="${_RUN_CONCURRENCY}" \
--max-instances="${_RUN_MAX_INSTANCES}" \
--ingress=all \
--service-account="${_RUN_SERVICE_ACCOUNT}" \
--env-vars-file=/workspace/tex-service-env.yaml \
--update-secrets="TEX_SERVICE_AUTH_TOKEN=${_TEX_SERVICE_AUTH_TOKEN_SECRET}:latest"
substitutions:
_REGION: asia-northeast3
_SERVICE_NAME: docsy-tex
_WORKER_SERVICE_NAME: docsy-tex-worker
_RUN_MEMORY: 4Gi
_RUN_CPU: "2"
_RUN_CONCURRENCY: "1"
_RUN_MAX_INSTANCES: "5"
_WORKER_RUN_MEMORY: 4Gi
_WORKER_RUN_CPU: "2"
_WORKER_RUN_CONCURRENCY: "1"
_WORKER_RUN_MAX_INSTANCES: "5"
_TEX_COMPILE_TIMEOUT_MS: "15000"
_TEX_MAX_SOURCE_BYTES: "300000"
_TEX_MAX_REQUEST_BYTES: "300000"
_TEX_MAX_CONCURRENCY: "1"
_TEX_ALLOW_ALL_PACKAGES: "true"
_TEX_ALLOW_RAW_DOCUMENT: "true"
_TEX_ALLOW_RESTRICTED_COMMANDS: "false"
_TEX_ALLOWED_PACKAGES: "amsmath,amssymb,amsthm,array,booktabs,caption,enumitem,etoolbox,fancyhdr,float,fontspec,geometry,graphicx,hyperref,inputenc,latexsym,listings,longtable,makecell,mathtools,multirow,setspace,soul,tabularx,tcolorbox,titlesec,ulem,xcolor,xeCJK"
_TEX_PREVIEW_BUCKET: "__SET_ME__"
_TEX_PREVIEW_URL_TTL_SECONDS: "900"
_TEX_TASK_QUEUE: tex-compile
_TEX_TASK_LOCATION: asia-northeast3
_TEX_SERVICE_AUTH_TOKEN_SECRET: tex-service-auth-token
_NODE_OPTIONS: "--max-old-space-size=512"
_WORKER_NODE_OPTIONS: "--max-old-space-size=512"
_RUN_SERVICE_ACCOUNT: "399359781191-compute@developer.gserviceaccount.com"
images:
- ${_IMAGE_URI}