Z
Zerops5w ago
Dally

Cannot build due to app not reading env vars

Hello, i restrucutred my project because i needed to separate some logic to some packages. I got to the point where the packages are build, but the Astro app fails with the following error Login required! which basically means that the ASTRO_DB_APP_TOKEN env var is missing. I've checked the build container and echoing the env vars seems OK, they both are printed out and set. If i attempt to build the application in the container with the env vars, everything seems fine (e.g. sudo ASTRO_DB_REMOTE_URL=db/dev.db ASTRO_DB_APP_TOKEN="" pnpm astro build --remote). Do i have something wrong? The env var is supposed to be secret (see screenshot) and i have it in the zerops.yaml from runtime.
- setup: fepreview
build:
base: nodejs@22
envVariables:
ASTRO_DB_REMOTE_URL: ${RUNTIME_ASTRO_DB_REMOTE_URL}
ASTRO_DB_APP_TOKEN: ${RUNTIME_ASTRO_DB_APP_TOKEN}
buildCommands:
- pnpm install --shamefully-hoist
- pnpm run build # Building remote, but using local preseeded file
cache:
- .turbo
- node_modules
- packages/*/node_modules
- apps/*/node_modules
deployFiles:
- apps/frontend/~dist
- apps/frontend/~node_modules
- apps/frontend/~package.json
- apps/frontend/~src/assets/fonts
- apps/frontend/~db/dev.db
run:
base: nodejs@22
ports:
- port: 4321
httpSupport: true
envVariables:
HOST: 0.0.0.0
APP_VERSION_NAME: ${appVersionName}
ASTRO_DB_REMOTE_URL: file:db/dev.db
PREVIEW: true # Builds preview posts
start: pnpm start
healthCheck:
httpGet:
port: 4321
path: /api/status
- setup: fepreview
build:
base: nodejs@22
envVariables:
ASTRO_DB_REMOTE_URL: ${RUNTIME_ASTRO_DB_REMOTE_URL}
ASTRO_DB_APP_TOKEN: ${RUNTIME_ASTRO_DB_APP_TOKEN}
buildCommands:
- pnpm install --shamefully-hoist
- pnpm run build # Building remote, but using local preseeded file
cache:
- .turbo
- node_modules
- packages/*/node_modules
- apps/*/node_modules
deployFiles:
- apps/frontend/~dist
- apps/frontend/~node_modules
- apps/frontend/~package.json
- apps/frontend/~src/assets/fonts
- apps/frontend/~db/dev.db
run:
base: nodejs@22
ports:
- port: 4321
httpSupport: true
envVariables:
HOST: 0.0.0.0
APP_VERSION_NAME: ${appVersionName}
ASTRO_DB_REMOTE_URL: file:db/dev.db
PREVIEW: true # Builds preview posts
start: pnpm start
healthCheck:
httpGet:
port: 4321
path: /api/status
No description
8 Replies
Dally
DallyOP5w ago
Log output from when i was trying some things:
buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$ sudo ASTRO_DB_REMOTE_URL=db/dev.db ASTRO_DB_APP_TOKEN="" pnpm astro build --remote

> @daliborhon.dev/[email protected] astro /build/source/apps/frontend
> astro "build" "--remote"

22:43:57 [INFO] [astro-config] Using environment: 'production'
22:43:57 [INFO] [astro-config] Using SITE_URL: 'https://daliborhon.dev'
22:43:57 [INFO] [astro-config] Using PORT: '4321'
22:43:57 [INFO] [astro-config] Using PREVIEW: 'undefined'
22:43:57 [vite] Re-optimizing dependencies because vite config has changed
22:43:59 [INFO] [content-config] Using prod as path (ENV -> preview: undefined, dev: false).
22:43:59 [content] Syncing content
... build log
buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$ echo $ASTRO_DB_APP_TOKEN

buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$ sudo pnpm build

> @daliborhon.dev/[email protected] build /build/source/apps/frontend
> astro build --remote

22:44:36 [INFO] [astro-config] Using environment: 'production'
22:44:36 [INFO] [astro-config] Using SITE_URL: 'https://daliborhon.dev'
22:44:36 [INFO] [astro-config] Using PORT: '4321'
22:44:36 [INFO] [astro-config] Using PREVIEW: 'undefined'
▶ Login required!

To authenticate with Astro Studio, run
astro login

 ELIFECYCLE  Command failed with exit code 1.
buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$
buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$ sudo ASTRO_DB_REMOTE_URL=db/dev.db ASTRO_DB_APP_TOKEN="" pnpm astro build --remote

> @daliborhon.dev/[email protected] astro /build/source/apps/frontend
> astro "build" "--remote"

22:43:57 [INFO] [astro-config] Using environment: 'production'
22:43:57 [INFO] [astro-config] Using SITE_URL: 'https://daliborhon.dev'
22:43:57 [INFO] [astro-config] Using PORT: '4321'
22:43:57 [INFO] [astro-config] Using PREVIEW: 'undefined'
22:43:57 [vite] Re-optimizing dependencies because vite config has changed
22:43:59 [INFO] [content-config] Using prod as path (ENV -> preview: undefined, dev: false).
22:43:59 [content] Syncing content
... build log
buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$ echo $ASTRO_DB_APP_TOKEN

buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$ sudo pnpm build

> @daliborhon.dev/[email protected] build /build/source/apps/frontend
> astro build --remote

22:44:36 [INFO] [astro-config] Using environment: 'production'
22:44:36 [INFO] [astro-config] Using SITE_URL: 'https://daliborhon.dev'
22:44:36 [INFO] [astro-config] Using PORT: '4321'
22:44:36 [INFO] [astro-config] Using PREVIEW: 'undefined'
▶ Login required!

To authenticate with Astro Studio, run
astro login

 ELIFECYCLE  Command failed with exit code 1.
buildfepreviewv1738140278-runtime-1-34:/build/source/apps/frontend$
Jan Saidl
Jan Saidl5w ago
In the build phase, runtime environment variables are available with RUNTIME_ prefix. $RUNTIME_ASTRO_DB_APP_TOKEN
Dally
DallyOP5w ago
envVariables:
ASTRO_DB_REMOTE_URL: ${RUNTIME_ASTRO_DB_REMOTE_URL}
ASTRO_DB_APP_TOKEN: ${RUNTIME_ASTRO_DB_APP_TOKEN}
envVariables:
ASTRO_DB_REMOTE_URL: ${RUNTIME_ASTRO_DB_REMOTE_URL}
ASTRO_DB_APP_TOKEN: ${RUNTIME_ASTRO_DB_APP_TOKEN}
This should take care of it, no? it always worked for me like that
Jan Saidl
Jan Saidl5w ago
Sorry I missed that.In your zerops.yml file. I'll see if there's a problem. Give me a minute. It works as expected. Aaaa I see you are using sudo, try sudo -E because sudo doesn't propagate environment variables.
Jan Saidl
Jan Saidl5w ago
No description
Dally
DallyOP5w ago
Ah yeah thats my bad, however if i push the project the build fails with the login required error, in the build container i just wanted to confirm that the app builds fine when it is done manually (which it does), for example now a pipeline 1k0B2uo9T4Kv7OSYfzLhvw failed. Well, maybe its the ASTRO_DB_REMOTE_URL env var, when the app does not find it, it also wants me to login oh for sure it's the ASTRO_DB_REMOTE_URL not the other one, sorry for that
Jan Saidl
Jan Saidl5w ago
file:db/dev.db Is this value wrong? file://db/dev/db
Dally
DallyOP5w ago
i see it is an issue with turbo, running standalone build works Yeah my bad https://turbo.build/repo/docs/crafting-your-repository/using-environment-variables#environment-modes Sorry for the confusion here!

Did you find this page helpful?