ENV Vars Not Accessible On Deployment
Attempting to deploy Astro app via Railway and seems like no ENV vars are being exposed.
Dockerfile as requested by @Brody
29 Replies
Project ID:
N/A
N/A
interesting dockerfile
please read this docs page - https://docs.railway.app/guides/dockerfiles#using-variables-at-build-time
Ah, gotcha!
I'll try that.
if that works, then we can move on to optimizing the dockerfile
but show me what changes you make to the dockerfile before trying another deployment please
Just adding ARG <name of variable I have set in the dashboard>
x 15, lol.
correct, but still send the dockerfile before deployment please
docker
@Brody
nope
haha exactly what I thought you'd do
Rekt
Guess I need to pass those ARGS somewhere
?
I was looking at one of your other responses, don't see much of a difference. What are you seeing?
hopefully there's no typos, edited on mobile
Hmm, ok so just cleaning it up a little? Seemed tow ork otherwise. Lemme try this though
you had your layers in a weird order
Gotcha.
Interesting. It failed based on one of my env vars.
Invalid define value (must be an entity name or valid JSON syntax): libsql://sderkaderka.turso.io
Do I need to wrap that shit in quotes or something?
how have you defined it in your railway service variables
Without quotes
TURSO_CONNECTION_URL=libsql://fesfesfsef.turso.io
(Like how I do on .env)
and what's the correct syntax?
That's what I use on dev.
And works fine.
(localhost, rather)
Hmm. Might be a VITE bundle thing, I'll try adding quotes I guess. EDIT: Probably what happens when you use ARG in Dockerfile
Just tripped on the URL environment variables. adding quotes allowed it to build.
railway strips quotes from environment variables fwiw
Gotcha.
@Brody Seems to be working now. Thank you.
Adding ARGS in the Dockerfile + quotes around necessary ENV vars seemed to do it.
For anyone looking for this in the future, still not sure if I needed to update my astro.config.mjs with vite define variables, but we'll see.
lets see your final dockerfile?
Same one you sent me.
I just added quotes in the Railway var settings in the dashboard.
interesting
Why’s that?
^
Maybe because I’m injecting them from docker it’s pulling the value before it’s stripped.
haha not how it works
I also hook into vite to define the variables in my config file, referencing process.env so maybe that’s it too.
we may never know