Server Error 503

Mmatifali3/29/2023
I am setting my access url inside the app to 0.0.0.0:${{PORT}} Where PORT is automatically injected by railway.

Deploy logs are healthy but still I get a Server Error Page
Mmatifali3/29/2023
54cd68ae-8dc4-4d04-b044-17564e857147
Bbrody3/29/2023
34777 isn't a port that railway would generate
Mmatifali3/29/2023
I also tried manullay overwriting it
Mmatifali3/29/2023
by setting PORT=3000 environment varibale
Mmatifali3/29/2023
same effect
Bbrody3/29/2023
where is it getting 34777 from then
Mmatifali3/29/2023
Let me fix something. Do I need port INSIDE my Dockerfile?
Bbrody3/29/2023
not unless you need to reference it during build, otherwise you don't need any arg or expose for the port stuff
Mmatifali3/29/2023
I have an environment variable
ACCESS_URL=0.0.0.0:${{PORT}}
Mmatifali3/29/2023
in my service config
Mmatifali3/29/2023
and That variable is being used in the Dockerfile
Bbrody3/29/2023
that's definitely unorthodox
Bbrody3/29/2023
ideally you shouldn't need to set anything up with ports in the dockerfile
Mmatifali3/29/2023
Mmatifali3/29/2023
The container actually runs the servive on a port
Bbrody3/29/2023
remove both PORT and CODER_HTTP_ADDRESS
Mmatifali3/29/2023
trying will update
Bbrody3/29/2023
then just simply listen on the auto generated PORT, no need to complicate things like that
Mmatifali3/29/2023
It worked
Bbrody3/29/2023
yay
Mmatifali3/29/2023
But Why?
Bbrody3/29/2023
because you are now listening on the port railway wants you to
Mmatifali3/29/2023
Again 503
Bbrody3/29/2023
then why did you say that it worked
Mmatifali3/29/2023
I removed CODER_ACCESS_URL it worked
Mmatifali3/29/2023
I removed PORT it is back to 503
Mmatifali3/29/2023
I do not know
Mmatifali3/29/2023
railway deployed on every varibale delete or add
Mmatifali3/29/2023
It does not wait for you to finihs adding or deleting all varibales
Bbrody3/29/2023
yes it does
Bbrody3/29/2023
theres a toast with a timer, it has a button that says cancel
Mmatifali3/29/2023
it turns out I need PORT
Bbrody3/29/2023
you shouldn't
Bbrody3/29/2023
but if the broken code works with a PORT set then all good
Mmatifali3/29/2023
I will experiment more
Bbrody3/29/2023
sounds good
Mmatifali3/29/2023
Thanks a lot for the quick response
Mmatifali3/29/2023
I appreaciate.
Bbrody3/29/2023
no problem!
Mmatifali3/29/2023
Seems like I need PORT even I am not using it anywhere
Mmatifali3/29/2023
just deleting the varibale gives me 503
Bbrody3/29/2023
what framework is this anyway?
Mmatifali3/29/2023
It is a Dockerfile based on Coder.com
Mmatifali3/29/2023
ghcr.io/coder/coder
Mmatifali3/29/2023
using this image
Bbrody3/29/2023
railway has a template for coder
Mmatifali3/29/2023
that is code-server
Mmatifali3/29/2023
I am from Coder community
Mmatifali3/29/2023
and I want to publish a new template for oour product Coder Server
Bbrody3/29/2023
looked like the same logo to me 🤷
Mmatifali3/29/2023
yeah
Bbrody3/29/2023
my bad
Mmatifali3/29/2023
code-server is a product
Mmatifali3/29/2023
this one is named coder
Bbrody3/29/2023
interesting, lots of stars
Mmatifali3/29/2023
By the way I figured it out
Bbrody3/29/2023
what was it
Mmatifali3/29/2023
in the coder image port 3000 is kind of hardocded. like it listens on 127.0.0.1:3000
Mmatifali3/29/2023
But railway expects 0.0.0.0
Mmatifali3/29/2023
so I set 0.0.0.0:3000
Mmatifali3/29/2023
Now Railway does not know which port to connect to if I do not set PORT=3000
Bbrody3/29/2023
make it also listen on the railways injected PORT so you won't have to set your own, much better portability that way especially for templates
Mmatifali3/29/2023
We have a variable CODER_HTTP_ADDRESS that defaults to 127.0.0.1:3000
Mmatifali3/29/2023
I overrode that to 0.0.0.0:3000 and then I need PORT=3000 varibale
Bbrody3/29/2023
I bet you could do better
Mmatifali3/29/2023
other thing I can do is,
define ENV PORT= in my Dockerfile
and then set CODER_HTTP_ADDRESS=0.0.0.0:$PORT
Mmatifali3/29/2023
then Coder will listen on railway injected port
Bbrody3/29/2023
yay that's what I like to hear
Mmatifali3/29/2023
But don't you think railway should allow directly using images from a registry?
Mmatifali3/29/2023
Instead of a repo that has a minimal Dockerfile
Bbrody3/29/2023
this has been asked before, and I forget the answer a team member gave
Mmatifali3/29/2023
the 2nd method didn't work. railway is not passing any PORT
Bbrody3/29/2023
personally I don't see a problem with a repo that has just a dockerfile for a template
Mmatifali3/29/2023
and it is defaulting to 3000
Mmatifali3/29/2023
FROM ghcr.io/coder/coder:v0.21.1
ENV PORT=3000
ENV CODER_HTTP_ADDRESS=0.0.0.0:$PORT
ENV CODER_ACCESS_URL=
ENV CODER_PG_CONNECTION_URL=
ENV CODER_EXPERIMENTS=*
ENV CODER_DEBUG=false
ENV CODER_TELEMETRY_INSTALL_SOURCE=
Bbrody3/29/2023
you'd likely need to do a ARG PORT in the dockerfile
Mmatifali3/29/2023
didn't work
Bbrody3/29/2023
instead of the ENV PORT=3000
Mmatifali3/29/2023
FROM ghcr.io/coder/coder:v0.21.1
ARG PORT=3000
ENV CODER_HTTP_ADDRESS=0.0.0.0:$PORT
ENV CODER_ACCESS_URL=
ENV CODER_PG_CONNECTION_URL=
ENV CODER_EXPERIMENTS=*
ENV CODER_DEBUG=false
ENV CODER_TELEMETRY_INSTALL_SOURCE=
Bbrody3/29/2023
haha no not like that
Bbrody3/29/2023
just ARG PORT
Mmatifali3/29/2023
Then why if there is no PORT?
Mmatifali3/29/2023
or PORT is empty
Bbrody3/29/2023
there will be if it's ran on railway
Mmatifali3/29/2023
I would like to use the same Dockerfile for other deployments
Mmatifali3/29/2023
other platforms locally
Mmatifali3/29/2023
And also, even if default is set
Bbrody3/29/2023
then you can specify the port in the docker run command
Mmatifali3/29/2023
It should be overridden, when passed from outside
Bbrody3/29/2023
don't know if that's how ARG works but sounds plausible
Mmatifali3/29/2023
What I mean is even if we set an ARG to a deafult value it should take the value passed by railway
Mmatifali3/29/2023
wait
Bbrody3/29/2023
waiting
Mmatifali3/29/2023
Tried
ARG PORT
ENV PORT=${PORT:-3000}
ENV CODER_HTTP_ADDRESS=0.0.0.0:$PORT
Mmatifali3/29/2023
didn't work
Mmatifali3/29/2023
ARG PORT
ENV CODER_HTTP_ADDRESS=0.0.0.0:$PORT

Also did not work