R
Railway7mo 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
Percy7mo ago
Project ID: 88291032-3a21-4fc7-9023-7e430df5bc64
Metru
Metru7mo ago
88291032-3a21-4fc7-9023-7e430df5bc64
Brody
Brody7mo ago
does surrealdb communicate over http?
Metru
Metru7mo ago
Oh, no it does not. It uses ws
Brody
Brody7mo ago
websockets?
Metru
Metru7mo ago
Yes The surreal SDK will attempt to connect via http://localhost:8000/rpc which will then get upgraded to a ws connection
Brody
Brody7mo 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
Metru7mo ago
Wheres $PORT being defined?
Brody
Brody7mo ago
it's automatically generated by railway
Metru
Metru7mo 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
Metru7mo ago
And I'm getting
No description
Brody
Brody7mo ago
don't use the array syntax
Metru
Metru7mo ago
How should I wrte it out?
Brody
Brody7mo ago
exactly like I have
Metru
Metru7mo ago
So does this mean: Like this? CMD "start --bind 0.0.0.0:$PORT"
Brody
Brody7mo ago
don't quote anything
Metru
Metru7mo ago
No description
Metru
Metru7mo ago
Seems the array syntax is needed here From what I understand docker will always use /bin/sh if not using array
Brody
Brody7mo 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
Metru7mo 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
Brody7mo ago
within your railway service under the variables tab
Metru
Metru7mo 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
Brody7mo ago
^
beuz
beuz7mo ago
like
No description
No description
Metru
Metru7mo 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
Brody7mo ago
youre welcome lol
Metru
Metru7mo 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
Brody7mo 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
Metru7mo ago
Does the generated port not work with dockerfiles though?
Brody
Brody7mo ago
environment variables are not expanded when using the array syntax
Metru
Metru7mo ago
Oh, that makes sense
Brody
Brody7mo ago
so the actually command ran was the literally string start --bind 0.0.0.0:$PORT