R
Railway13mo ago
Metru

Having trouble deploying a Surrealdb instance

Heres my docker file
FROM surrealdb/surrealdb:latest
EXPOSE 8000
CMD ["start", "--bind", "0.0.0.0:8000"]
FROM surrealdb/surrealdb:latest
EXPOSE 8000
CMD ["start", "--bind", "0.0.0.0:8000"]
After generating a domain, I can't seem to reach the db. Trying surreal sql --conn <generated-url> seems to time out. The console shows the the web server is indeed running.
No description
32 Replies
Percy
Percy13mo ago
Project ID: 88291032-3a21-4fc7-9023-7e430df5bc64
Metru
MetruOP13mo ago
88291032-3a21-4fc7-9023-7e430df5bc64
Brody
Brody13mo ago
does surrealdb communicate over http?
Metru
MetruOP13mo ago
Oh, no it does not. It uses ws
Brody
Brody13mo ago
websockets?
Metru
MetruOP13mo ago
Yes The surreal SDK will attempt to connect via http://localhost:8000/rpc which will then get upgraded to a ws connection
Brody
Brody13mo ago
change the CMD command to
start --bind 0.0.0.0:$PORT
start --bind 0.0.0.0:$PORT
then you use https://<public domain, no port>/rpc
Metru
MetruOP13mo ago
Wheres $PORT being defined?
Brody
Brody13mo ago
it's automatically generated by railway
Metru
MetruOP13mo ago
Just for sanity, this is what I have now
FROM surrealdb/surrealdb:latest
EXPOSE 8000
CMD ["start", "--bind", "0.0.0.0:$PORT"]
FROM surrealdb/surrealdb:latest
EXPOSE 8000
CMD ["start", "--bind", "0.0.0.0:$PORT"]
Metru
MetruOP13mo ago
And I'm getting
No description
Brody
Brody13mo ago
don't use the array syntax
Metru
MetruOP13mo ago
How should I wrte it out?
Brody
Brody13mo ago
exactly like I have
Metru
MetruOP13mo ago
So does this mean: Like this? CMD "start --bind 0.0.0.0:$PORT"
Brody
Brody13mo ago
don't quote anything
Metru
MetruOP13mo ago
No description
Metru
MetruOP13mo ago
Seems the array syntax is needed here From what I understand docker will always use /bin/sh if not using array
Brody
Brody13mo ago
you're kinda right, I forget the proper way to fix this, so go back to the dockerfile you had in the message you opened the thread with and then just specify a PORT service variable as 8000
Metru
MetruOP13mo ago
just specify a PORT service variable as 8000
Where/how do I do this? I'm pretty new to railway. Oh as in an env var called PORT?
Brody
Brody13mo ago
within your railway service under the variables tab
Metru
MetruOP13mo ago
The $PORT in the docker file just doesn't want to be injected today error: invalid value '0.0.0.0:$PORT' for '--bind <LISTEN_ADDRESSES>': invalid socket address syntax
Brody
Brody13mo ago
^
beuz
beuz13mo ago
like
No description
No description
Metru
MetruOP13mo ago
I think I'm just dumb and I haven't been typing rpc Its now working, but technically, nothing changed? Its one of those days is it? Thanks for the help fellas!
Brody
Brody13mo ago
youre welcome lol
Metru
MetruOP13mo ago
Okay so I removed the PORT for a sanity check. Adding the PORT variable is the thing that fixed it. But why? If its needed for railway to know what port you're using, wouldn't it make more sense for that to be in settings?
Brody
Brody13mo ago
If its needed for railway to know what port you're using
correct, but thats why i first tried to get you to use the auto generated PORT variable first
wouldn't it make more sense for that to be in settings?
it is an environment variable after all, a lot of the time its not needed and listening on the auto generated PORT is always preferred
Metru
MetruOP13mo ago
Does the generated port not work with dockerfiles though?
Brody
Brody13mo ago
environment variables are not expanded when using the array syntax
Metru
MetruOP13mo ago
Oh, that makes sense
Brody
Brody13mo ago
so the actually command ran was the literally string start --bind 0.0.0.0:$PORT
Want results from more Discord servers?
Add your server