2022-12-28 19:22:54 +00:00
|
|
|
import { ServiceDeployment } from '../utils/service-deployment';
|
2022-11-07 13:27:19 +00:00
|
|
|
import type { Broker } from './cf-broker';
|
2024-03-04 12:56:12 +00:00
|
|
|
import { Docker } from './docker';
|
|
|
|
|
import { Environment } from './environment';
|
2024-04-07 08:57:03 +00:00
|
|
|
import { Observability } from './observability';
|
2022-12-28 19:22:54 +00:00
|
|
|
import { Redis } from './redis';
|
2024-03-04 12:56:12 +00:00
|
|
|
import { Sentry } from './sentry';
|
2022-05-18 07:26:57 +00:00
|
|
|
|
|
|
|
|
export type Webhooks = ReturnType<typeof deployWebhooks>;
|
|
|
|
|
|
|
|
|
|
export function deployWebhooks({
|
2024-03-04 12:56:12 +00:00
|
|
|
environment,
|
2022-06-27 11:17:32 +00:00
|
|
|
heartbeat,
|
2022-11-07 13:27:19 +00:00
|
|
|
broker,
|
2022-12-20 14:34:46 +00:00
|
|
|
image,
|
2024-03-04 12:56:12 +00:00
|
|
|
docker,
|
|
|
|
|
redis,
|
|
|
|
|
sentry,
|
2024-04-07 08:57:03 +00:00
|
|
|
observability,
|
2022-05-18 07:26:57 +00:00
|
|
|
}: {
|
2024-04-07 08:57:03 +00:00
|
|
|
observability: Observability;
|
2022-12-20 14:34:46 +00:00
|
|
|
image: string;
|
2024-03-04 12:56:12 +00:00
|
|
|
environment: Environment;
|
2022-06-27 11:17:32 +00:00
|
|
|
heartbeat?: string;
|
2024-03-04 12:56:12 +00:00
|
|
|
docker: Docker;
|
|
|
|
|
broker: Broker;
|
|
|
|
|
redis: Redis;
|
|
|
|
|
sentry: Sentry;
|
2022-05-18 07:26:57 +00:00
|
|
|
}) {
|
2022-12-20 14:34:46 +00:00
|
|
|
return new ServiceDeployment(
|
2022-05-18 07:26:57 +00:00
|
|
|
'webhooks-service',
|
|
|
|
|
{
|
2024-03-04 12:56:12 +00:00
|
|
|
imagePullSecret: docker.secret,
|
2022-05-18 07:26:57 +00:00
|
|
|
env: {
|
2024-03-04 12:56:12 +00:00
|
|
|
...environment.envVars,
|
|
|
|
|
SENTRY: sentry.enabled ? '1' : '0',
|
2022-06-27 11:17:32 +00:00
|
|
|
HEARTBEAT_ENDPOINT: heartbeat ?? '',
|
2022-11-07 13:27:19 +00:00
|
|
|
REQUEST_BROKER: '1',
|
2024-04-07 08:57:03 +00:00
|
|
|
OPENTELEMETRY_COLLECTOR_ENDPOINT:
|
|
|
|
|
observability.enabled && observability.tracingEndpoint
|
|
|
|
|
? observability.tracingEndpoint
|
|
|
|
|
: '',
|
2022-05-18 07:26:57 +00:00
|
|
|
},
|
|
|
|
|
readinessProbe: '/_readiness',
|
|
|
|
|
livenessProbe: '/_health',
|
2024-02-29 15:41:57 +00:00
|
|
|
startupProbe: '/_health',
|
2022-05-18 07:26:57 +00:00
|
|
|
exposesMetrics: true,
|
2024-03-04 12:56:12 +00:00
|
|
|
replicas: environment.isProduction ? 3 : 1,
|
2022-12-20 14:34:46 +00:00
|
|
|
image,
|
2022-05-18 07:26:57 +00:00
|
|
|
},
|
2022-11-24 10:00:41 +00:00
|
|
|
[redis.deployment, redis.service],
|
2024-03-04 12:56:12 +00:00
|
|
|
)
|
|
|
|
|
.withSecret('REDIS_HOST', redis.secret, 'host')
|
|
|
|
|
.withSecret('REDIS_PORT', redis.secret, 'port')
|
|
|
|
|
.withSecret('REDIS_PASSWORD', redis.secret, 'password')
|
|
|
|
|
.withSecret('REQUEST_BROKER_ENDPOINT', broker.secret, 'baseUrl')
|
|
|
|
|
.withSecret('REQUEST_BROKER_SIGNATURE', broker.secret, 'secretSignature')
|
|
|
|
|
.withConditionalSecret(sentry.enabled, 'SENTRY_DSN', sentry.secret, 'dsn')
|
|
|
|
|
.deploy();
|
2022-05-18 07:26:57 +00:00
|
|
|
}
|