🌳
pt0/deployF/getDefaultEnvF.mts
1import * as _ from 'lodash-es'
8export const runtimeOnlyDockerEnvKeys = ['PT_DEPLOY_NAME', 'PT_DEPLOY_HOSTNAME']
9// FYI: these vary per deploy target; omitting from nextbuild dockerEnv keeps image tags
10// identical across deploys of the same commit (avoiding redundant kaniko rebuilds)
12export const getDefaultEnv = () => {
13 const {git_sha, prebuildEnvConfH={}, defaultSsTz, publicJsonH={}, name, wcHostname, nonWcHostname} = getAppCfg()
14 const action = getAction()
15 const isDev = getIsDevAction({action})
17 Object.assign(publicJsonH, {isDev})
19 let retH: Record<string, string | undefined> = {
20 NEXT_PUBLIC_GIT_SHA: git_sha,
21 NEXT_PUBLIC_JSON: JSON.stringify({
22 ...publicJsonH,
23 }),
24 PREBUILD_ENVJSON: JSON.stringify(prebuildEnvConfH),
25 PT_DEPLOY_NAME: name,
26 PT_DEPLOY_HOSTNAME: nonWcHostname || wcHostname,
27 }
28 if (defaultSsTz) {
29 retH = {...retH,
30 NEXT_PUBLIC_DEFAULTTZ: defaultSsTz,
31 }
32 }
33 return _.omitBy(retH, _.isUndefined) as Record<string, string>
36export const getIsDevAction = ({action}: {action?: string} = {}): boolean => {
37 // true -> dev action below, false -> actually deploying
38 if (isRunningDevCtx.getStore()) return true
39 const resolvedAction = action ?? getAction()
40 assertDefined(resolvedAction)
41 return _.includes([
42 'dockerfile',
43 'setenv', 'setprocenv',
44 ...devActionNames,
45 ], resolvedAction)