14 days ago
Im having a monorepo urn with Turborepo and now want to deploy an express.js service (affects different types of services). Services and its dependecies are building just fine as intended but when running my service, the provided environment-variables (under "Variables" will not come into affect).
I've simply verified it by console.log(process.env) which gave me all the default environment variables for NodeJS, Railway and Turbo. During build variables like DO_NOT_TRACK=1 will be recognised and take effect.
I've read through the documentation of railpack (and propably missed a very obvious hint)
railway.json
{
"$schema": "https://railway.com/railway.schema.json",
"build": {
"builder": "RAILPACK",
"buildCommand": "npx turbo run build --filter=@budgetbuddyde/backend",
"watchPatterns": [
"/services/backend/**",
"/packages/**"
],
"buildEnvironment": "V3"
},
"deploy": {
"runtime": "V2",
"numReplicas": 1,
"startCommand": "echo $AWS_S3_BUCKET_NAME && npx turbo run start --filter=@budgetbuddyde/backend",
"healthcheckPath": "/api/health",
"sleepApplication": false,
"multiRegionConfig": {
"europe-west4-drams3a": {
"numReplicas": 1
}
},
"restartPolicyType": "ON_FAILURE"
}
}logs
@budgetbuddyde/backend:start: /app/services/backend/build/src/lib/s3.js:23
@budgetbuddyde/backend:start: throw new error_1.EnvironmentVariableNotSetError(missingEnvVars.join(', '));
@budgetbuddyde/backend:start: ^
@budgetbuddyde/backend:start:
@budgetbuddyde/backend:start: EnvironmentVariableNotSetError: Environment variable AWS_ENDPOINT_URL, AWS_S3_BUCKET_NAME, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY is not set
@budgetbuddyde/backend:start: at getS3Client (/app/services/backend/build/src/lib/s3.js:23:15)
@budgetbuddyde/backend:start: at new AttachmentHandler (/app/services/backend/build/src/lib/attachment/attachment.handler.js:23:46)
@budgetbuddyde/backend:start: at new TransactionAttachmentHandler (/app/services/backend/build/src/lib/attachment/transaction-attachment.handler.js:10:1)2 Replies
14 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 14 days ago
14 days ago
Turborepo uses strict mode for env variables by default. Which filters the environment variables available to a task's runtime to only those that are specified in the globalEnv and env keys in turbo.json.
You can bypass this by using loose mode instead, by just using turbo run build --env-mode=loose for example.
Status changed to Solved brody • 14 days ago