How to connect to private network on Image Builds?
takodotid
PROOP

2 years ago

My NextJS requires connection to Redis on next build. How do I use the new builder environment that can use Railway private networking from railway.toml file?

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

Solved

24 Replies

brody
EMPLOYEE

2 years ago

Simply enable the new builder from the service settings.


takodotid
PROOP

2 years ago

I can't it doesn't show up If I use railway.toml config, I've found buildEnvironment from the JSON schema, not sure if that would work on toml, currently trying.


brody
EMPLOYEE

2 years ago

It would be named the same, yeah.


takodotid
PROOP

2 years ago

Didn't work. I also tried JSON. I'm using the Dockerfile builder


brody
EMPLOYEE

2 years ago

Is `V2` a valid config for the build environment? does your IDE validate the json for you?


takodotid
PROOP

2 years ago

It did, that's what it said on the schema


takodotid
PROOP

2 years ago

"buildEnvironment":{"anyOf":[{"anyOf":[{"not":{}},{"type":"string","const":"V2","description":"Build environment to be used for the build process"}]}

takodotid
PROOP

2 years ago

It's currently 1:30 AM here in Jakarta time, probably would come back 6 or 7 hours later. Hopefully also got answer from the Railway team.


brody
EMPLOYEE

2 years ago

What makes you think your build is not being done with the V2 builder?

Can you provide some build logs? -

https://bookmarklets.up.railway.app/log-downloader/


takodotid
PROOP

2 years ago

Does the V2 Builder works with Railway Private Networking? Mine didn't, at least DNS isn't working on the BuildKit builder.

The bookmarklet didn't save the older logs

Attachments


brody
EMPLOYEE

2 years ago

Does the V2 Builder works with Railway Private Networking?

Yes.

at least DNS isn't working on the BuildKit builder.

Aka the legacy builder, the V2 builder doesn't use BuildKit anymore.


takodotid
PROOP

2 years ago

Well, I don't know what the V2 builder uses, but I know that it supports Railway Private Networking.

For clarity, I used Dockerfile instead of Nixpacks, and use railway.json to set the builder settings including buildEnvironment to V2.

I know what I'm doing and have 5 years of experience with Docker. So not an issue from my Dockerfile

The option of V2 builder in the UI dissapeared, so I can't verify if it really turned on or not.

No, I didn't use Alpine-based images.

I'm going away for now, thanks for the help, I appreciate your time. Let's see what the Railway teams response.


itsrems
EMPLOYEE

2 years ago

Hi, could you try adding RAILWAY_BETA_ENABLE_BUILD_V2=1 to your env ?

Thanks,

Nicolas


takodotid
PROOP

2 years ago

Hi, could you try adding RAILWAY_BETA_ENABLE_BUILD_V2=1 to your env ?

Thanks,

Nicolas

Hi, I've added that to my environment variables, still the same error.


brody
EMPLOYEE

2 years ago

Ah I think I know the issue, the V2 builder is only available in the us-west region.


takodotid
PROOP

2 years ago

Ah, when is the ETA for it to be available in Southeast Asia region?


brody
EMPLOYEE

2 years ago

I just asked five, the developer in charge of the V2 builder, will update you when I hear back.


takodotid
PROOP

2 years ago

Okay thanks


brody
EMPLOYEE

2 years ago

In the mean time you can use the public network during build and the private network during runtime, or run the task that requires connecting to redis during the runtime before starting your app, but be sure to use a readiness type health check if you do, or just always use one because that's good practice :)


takodotid
PROOP

2 years ago

Hi, I used the public network for the build time for now.

But on runtime, the database can connect via private network but Redis fails to resolve redis.railway.internal domain somehow.


brody
EMPLOYEE

2 years ago

Is your service on the V2 runtime?

Are you using ioredis?


takodotid
PROOP

2 years ago

Yes I'm using the V2 runtime, set from railway.json.

Yes I'm using ioredis, does the library have any issues with the private DNS?


brody
EMPLOYEE

2 years ago

Kinda, ioredis assumes the hostname will resolve to an IPv4 address by default, but the private network is IPv6 only, so you would need to append ?family=0 if you are using the URL or set family: 0 in the config.


takodotid
PROOP

2 years ago

I see, that fixes it, thanks.


Status changed to Solved Railway over 1 year ago


Loading...