Deploying Multiple Containers from a Single GitHub Repo on Railway
lorenzogentili1
PROOP

a year ago

Hey everyone,

I'm working on deploying my Docker-based application from a GitHub repository to Railway. The project consists of:

  • Telegraf (consuming production data from MQTT)

  • InfluxDB (storing the time-series data).

I want to deploy both services from the same GitHub repository. Is there a way to define a JSON or configuration schema on Railway to build and deploy multiple containers from a single repo? If not, what’s the most efficient approach to achieve this?

Thank you very much in advance,

Lorenzo

20 Replies

lorenzogentili1
PROOP

a year ago

N/A


a year ago

do you have the repo setup in a monorepo structure


lorenzogentili1
PROOP

a year ago

yes, I've created the repo like this:

  • influxdb/: Contains the configuration and a Dockerfile for InfluxDB.

  • telegraf/: Contains the configuration and a Dockerfile for Telegraf.

  • railway.json: ideally define how Railway should deploy both services.


a year ago

railway.json can only define the config for a single service, so you would need to deploy the two services manually, here's a guide on how to deploy a monorepo for a frontend and backend, that's obviously not quite what you have, but read through it because it will give you a great overview on what you need to do -


lorenzogentili1
PROOP

a year ago

thanks Brody, actually selecting the root directory for each services i'm able to start the deploying, but then both services crash, I guess something is not right for the configfile. I will look into it, thanks again.


a year ago

what do the deploy logs say about the crash?


lorenzogentili1
PROOP

a year ago

Hez, sorry for the delay, I've managed, but I wasn't able to use env varibale to define the broker url and influx url. I had to add them manually in telegraf configuration:

[agent]
flush_interval = "10s"

MQTT Consumer Configuration

[[inputs.mqttconsumer]] servers = ["emqx:1883"] topics = [ "*" ] qos = 0 connectiontimeout = "30s"
data_format = "json"

InfluxDB v2 Configuration

[[outputs.influxdbv2]] urls = ["http://influxdbrealtime.railway.internal:8086"]
token = "$TELEGRAFINFLUXDBAPITOKEN" organization = "$TELEGRAFINFLUXDBORG" bucket = "$TELEGRAFINFLUXDB_BUCKET"

While I wanted to use:

  • servers = ["$MQTT_SERVICE"] for MQTT broker connection

  • urls = ["$TELEGRAFINFLUXDBURL"] for influxDB url.


infomiho
PRO

a year ago

Is running railway up the way to go in these kind of situations?


a year ago

do you have any association with Lorenzo?


infomiho
PRO

a year ago

Not really 🙂 I'm just wondering about the same topic


a year ago

then I would personally deploy from GitHub with root directories set


infomiho
PRO

a year ago

I have a specific case of having the src files in Github, but then I generate two different apps by running wasp build first - I want to deploy the resulting folders which don't live in Github 😦


a year ago

mind opening your own help thread?


a year ago

@miho - never got around to openeing a help thread? we want to help you with the cli issue!


infomiho
PRO

a year ago

It boils down to this Github issue (there I have described the setup in detail), so I didn't want to duplicate the info: https://github.com/railwayapp/cli/issues/595 thanks for reaching out!


a year ago

right but full disclosure I'm not too sure if we can change that behavior, people may be relying on its behavior and that could break the workflows for other users


infomiho
PRO

a year ago

I get that this behaviour is something the users expect so it maybe can't be changed (as per Hyrum's Law) but could you maybe try and see if this is maybe really a bug?

It feels like a bug to me because when I run railway up ./folder and it packages it in a way that e.g. the Dockerfile in ./folder is no longer in root and the deployment fails. The only workaround I found is to run railway link multiple times (in each subfolder) which feels like it shouldn't be necessary in a monorepo situation. It's a single project with multiple services.

Again, I'm an outsider and maybe the `railway up


a year ago

it's definitely a bug, no doubt about that, but it's a bug that's been in the CLI likely since early v2 when it was written in Go, so yeah that law states that it will break something for someone if we change it.

unfortunately we have no metrics on how many people specify a path for railway up, if we did have that kind of metrics and it was only a handful of people then I'd have no problem changing it, but we don't know how many people depend on it, so we can't make assumptions that it won't break a lot of people's CI.

so yes it may be more messy but we would have to introduce a flag to update it's behavior, like we did with no_gitignore


infomiho
PRO

a year ago

Sounds reasonable 👍 I'll take another stab at it and propose something in the issue that would hopefully satisfy both use cases, you can let me know what you think


a year ago

sounds good, thank you for understanding


Loading...