Environment Variables
Hello everyone, I'm coming from Digital Ocean, and am very confused as to how to set environment variables. I have an API to deploy that I wrote in Rust. I can get the Dockerfile up and my app deployed using the Railway CLI. I need to set an environment variable called APP_APPLICATION__BASE_URL, which I believe corresponds to RAILWAY_STATIC_URL. Nothing I enter in the "Settings > Variables" page of my deployed app seems to work. In Digital Ocean, you'd get the deployment URL by using ${{APP_URL}}. Any tips would be appreciated.
50 Replies
Project ID:
05c1b2d1-7483-4da5-9ed4-41c5a5e55ba2
I don't see a project ID, but the service ID is 05c1b2d1-7483-4da5-9ed4-41c5a5e55ba2
may I ask what's wrong with grabbing the url from
RAILWAY_STATIC_URL
?
maybe I should mention that this variable is set automatically, there's nothing you need to do for that variable to exist, this may give you a better idea of what's going on with variables in the container
https://utilities.up.railway.app/env-varsIf I specify a key value pair, APP_APPLICATION__BASE_URL (which is the format my code wants) and make that correspond to RAILWAY_STATIC_URL, the health check fails, presumably because the /health_check endpoint is not reachable.
oh I take it you do not want to change that environment variables name?
No, no, just trying to understand how to use it correctly.
Hey there @Jeff Mitchell! https://docs.railway.app/develop/variables#railway-provided-variables You can see all the Railway provided variables here.
Yep, found that and read through it.
In your case, the healthcheck endpoint doesn't need to know the root of your app, you just point it to the route that you expect to return 200
if you wanna remap a var you can do something like
Right, which is /health_check...I entered that in the settings.
APP_APPLICATION__BASE_URL
and set that to ${{ RAILWAY_STATIC_URL }}
You need to template the stringGot it...trying again.
for the record, this value shouldn't affect healthchecks, so curious to see your config there
App didn't need a rebuild, but I'm still getting a failed health check. Maybe I've entered the endpoint wrong.
do you have an endpoint registered at that endpoint?
(yes I am bad at English)
are you serving from
/health_check
?I think so? If I run the app in dev, and go to that endpoint it returns a 200 OK with no body.
remove the slash at the start?
I'm serving a simple page with a login button from the / route.
I s2g if it's this
okay million dollar question, what host and what port is your app currently running on?
Don't worry, if it is I'll shoot myself 🙂
me first
also this
Can you give me a link to your application?
Still failing
Doing so means I can check your project
crusty-rustacean-api-production.up.railway.app
Should add that I used the Railway CLI to deploy my docker file.
just your project url
(can you believe I can't easily search via url?)
the project ID you gave me doesn't lead anywhere 😢
👋
that was a service id
oh wow
I can look that up
one sec
Going to remove the healthcheck- my guess here is that you aren't serving at root...
I like my guess better
Jeff, your app builds properly, are you listening on
0.0.0.0
?Checking...
Looking at the spec.yaml for Digital Ocean, which is irrelevant I know, the app should be using 8000...I'm not sure I specified that anywhere when I deployed via the Railway CLI. Just logged in, did init, then link, then up.
That can help!
Adding a
PORT
varthen you'd need to tell railway what port your app is listening on, set a PORT variable to 8000
Ok, that must be what I'm missing then. Will look that up in the docs.
a service variable
oh wow
Railway
404 - Page not found
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
logs is showing your app is panicking on request
anyway- heres more docs, but I don't think its us
https://docs.railway.app/deploy/exposing-your-app
when you visit root- something must be happening
it seems like it's expecting redis?
Ok, that's better! I need to finish the rest of the config then.
(also sorry for looking at your logs- just wanna help you out here)
How did you get those logs? If I'd been able to see that I wouldn't have wasted your time.
No worries at all, looking at the logs, it was very helpful.
Clicking the service
Opens the logs view
(Not a waste, I learn a lot of from these interactions. Still a lot we can do in terms of education)
🙂 Noobie noobs like me must drive you guys crazy.
Only Brody
Anyways, thanks so much, the PORT is up there now, and you've helped me out tremendously.
BTW, love that the Railway CLI is written in Rust 🙂
All good now, thanks again guys. Postgres is hooked up, solved the Redis panic (was a typo in how I'd defined the environment variable).