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