Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

chore(server): downscale non-prod env (#8493)

darkskygit49478638bc6f
diff --git a/.github/actions/deploy/deploy.mjs b/.github/actions/deploy/deploy.mjs
index 43e9bee706..36fe91d1dd 100644
--- a/.github/actions/deploy/deploy.mjs
+++ b/.github/actions/deploy/deploy.mjs
@@ -40,6 +40,37 @@ const isProduction = buildType === 'stable';
const isBeta = buildType === 'beta';
const isInternal = buildType === 'internal';
+const replicaConfig = {
+ production: {
+ web: 3,
+ graphql: Number(process.env.PRODUCTION_GRAPHQL_REPLICA) || 3,
+ sync: Number(process.env.PRODUCTION_SYNC_REPLICA) || 3,
+ },
+ beta: {
+ web: 2,
+ graphql: Number(process.env.BETA_GRAPHQL_REPLICA) || 2,
+ sync: Number(process.env.BETA_SYNC_REPLICA) || 2,
+ },
+ canary: {
+ web: 2,
+ graphql: 2,
+ sync: 2,
+ },
+};
+
+const cpuConfig = {
+ beta: {
+ web: '500m',
+ graphql: '1',
+ sync: '1',
+ },
+ canary: {
+ web: '500m',
+ graphql: '1',
+ sync: '1',
+ },
+};
+
const createHelmCommand = ({ isDryRun }) => {
const flag = isDryRun ? '--dry-run' : '--atomic';
const imageTag = `${buildType}-${GIT_SHORT_HASH}`;
@@ -67,17 +98,18 @@ const createHelmCommand = ({ isDryRun }) => {
`--set-json cloud-sql-proxy.nodeSelector=\"{ \\"iam.gke.io/gke-metadata-server-enabled\\": \\"true\\" }\"`,
]
: [];
- const webReplicaCount = isProduction ? 3 : isBeta ? 2 : 2;
- const graphqlReplicaCount = isProduction
- ? Number(process.env.PRODUCTION_GRAPHQL_REPLICA) || 3
- : isBeta
- ? Number(process.env.isBeta_GRAPHQL_REPLICA) || 2
- : 2;
- const syncReplicaCount = isProduction
- ? Number(process.env.PRODUCTION_SYNC_REPLICA) || 3
- : isBeta
- ? Number(process.env.BETA_SYNC_REPLICA) || 2
- : 2;
+
+ const cpu = cpuConfig[buildType];
+ const resources = cpu
+ ? [
+ `--set web.resources.requests.cpu="${cpu.web}"`,
+ `--set graphql.resources.requests.cpu="${cpu.graphql}"`,
+ `--set sync.resources.requests.cpu="${cpu.sync}"`,
+ ]
+ : [];
+
+ const replica = replicaConfig[buildType] || replicaConfig.canary;
+
const namespace = isProduction
? 'production'
: isBeta
@@ -100,9 +132,9 @@ const createHelmCommand = ({ isDryRun }) => {
`--set-string global.objectStorage.r2.secretAccessKey="${R2_SECRET_ACCESS_KEY}"`,
`--set-string global.version="${APP_VERSION}"`,
...redisAndPostgres,
- `--set web.replicaCount=${webReplicaCount}`,
+ `--set web.replicaCount=${replica.web}`,
`--set-string web.image.tag="${imageTag}"`,
- `--set graphql.replicaCount=${graphqlReplicaCount}`,
+ `--set graphql.replicaCount=${replica.graphql}`,
`--set-string graphql.image.tag="${imageTag}"`,
`--set graphql.app.host=${host}`,
`--set graphql.app.captcha.enabled=true`,
@@ -124,11 +156,12 @@ const createHelmCommand = ({ isDryRun }) => {
`--set graphql.app.experimental.enableJwstCodec=${namespace === 'dev'}`,
`--set graphql.app.features.earlyAccessPreview=false`,
`--set graphql.app.features.syncClientVersionCheck=true`,
- `--set sync.replicaCount=${syncReplicaCount}`,
+ `--set sync.replicaCount=${replica.sync}`,
`--set-string sync.image.tag="${imageTag}"`,
`--set-string renderer.image.tag="${imageTag}"`,
`--set renderer.app.host=${host}`,
...serviceAnnotations,
+ ...resources,
`--timeout 10m`,
flag,
].join(' ');