R
Railway3mo ago
Danny

deploy template api

Hi everyone! I'm attempting to use a template via the API, but am running into some issues. Firstly, i (for some reason) need to pass in the entire template data when publishing a template, while the templateid is sent along with the request? thats kinda weird. Also, i filled out the entire request, only to get a vague "Failed to process request" error. Any ideas?
Solution:
Should be fixed in the latest release. Could you try it and let me know?
Jump to solution
108 Replies
Percy
Percy3mo ago
Project ID: N/A
Danny
Danny3mo ago
N/A
Danny
Danny3mo ago
Here's my fetch
Danny
Danny3mo ago
and here's the result
No description
Brody
Brody3mo ago
you are calling templateDeploy aka v1, you should call templateDeployV2 with the correct serialized config structure
Danny
Danny3mo ago
aah, didnt know there was a v2 thanks, ill look into it! i cant seem to find templatedeployv2 in the graphiql docs?
Danny
Danny3mo ago
it really does not want me to use it
No description
Brody
Brody3mo ago
use the internal endpoint
Danny
Danny3mo ago
Where is the internal endpoint?
Danny
Danny3mo ago
Aha, thanks! I hope i can figure it out :happi:
Brody
Brody3mo ago
a surefire way would be just to simply watch the network calls the dashboard makes i would love to know your usecase though?
Danny
Danny3mo ago
Yeah, i tried that, but it uses the v1 deployment which is a bit weird We're making a SaaS app, that has a seperate instance per customer We've already got r2 buckets + turnstile working, so railways the last step to get the db + front & back up
Brody
Brody3mo ago
and you want to deploy a template automatically on sign up or something?
Danny
Danny3mo ago
So we can just click 1 button that sets up an entire instance Yea Or well, we click the create button
Brody
Brody3mo ago
single tenant app eh?
Danny
Danny3mo ago
Yeah, we built an app for 1 client and are scaling it to work for multiple And we thought this'd be cool ( and look good on our portfolios )
Brody
Brody3mo ago
you dont think your time would be better spent converting it to a multi tenant app for better scalability?
Danny
Danny3mo ago
Ehh, maybe But it'd take a while Cause its a pretty big app Entire radio management system And we're not planning on a lot of clientd
Brody
Brody3mo ago
fair enough
Danny
Danny3mo ago
And we just thought this would be fun haha
Danny
Danny3mo ago
Danny
Danny3mo ago
This is only the sidebar :NM_PepeExplode:
Brody
Brody3mo ago
damn hey i have an idea
Danny
Danny3mo ago
👂
Brody
Brody3mo ago
lol my cli is out of date, one sec
> railway deploy --help
Provisions a template into your project

Usage: railway deploy [OPTIONS]

Options:
-t, --template <TEMPLATE>
The code of the template to deploy

-v, --variable <VARIABLE>
The "{key}={value}" environment variable pair to set the template variables

To specify the variable for a single service prefix it with "{service}." Example:

bash railway deploy -t postgres -v "MY_SPECIAL_ENV_VAR=1" -v "Backend.Port=3000"

--json
Output in JSON format

-h, --help
Print help (see a summary with '-h')

-V, --version
Print version
> railway deploy --help
Provisions a template into your project

Usage: railway deploy [OPTIONS]

Options:
-t, --template <TEMPLATE>
The code of the template to deploy

-v, --variable <VARIABLE>
The "{key}={value}" environment variable pair to set the template variables

To specify the variable for a single service prefix it with "{service}." Example:

bash railway deploy -t postgres -v "MY_SPECIAL_ENV_VAR=1" -v "Backend.Port=3000"

--json
Output in JSON format

-h, --help
Print help (see a summary with '-h')

-V, --version
Print version
Danny
Danny3mo ago
oooo Yea that'd be way easier
Brody
Brody3mo ago
what language where you planning to write the code to deploy a template in?
Danny
Danny3mo ago
Node
Brody
Brody3mo ago
then you could call out to the cli
Danny
Danny3mo ago
(or bun if we're specific :bun: ) Yeah, i'll try that probablh
Brody
Brody3mo ago
bun has great support for calling out to cli apps doesnt it?
Danny
Danny3mo ago
Oh yeah they introduced that lately I'll see how it goes!
Brody
Brody3mo ago
let me know too!
Danny
Danny3mo ago
Bun
$ Shell – API | Bun Docs
Bun's cross-platform shell-scripting API makes shell scripting with JavaScript fun
Danny
Danny3mo ago
Will do hi @Brody im continuing to harrass you, we got it (mostly) working, however the deployed template is deploying everything with docker instead of github for some reason. so for example, we have a github repo called user/repo, but its instead read as dockerhub user/repo is that a bug with railway(cli) or an issue on our end
Brody
Brody3mo ago
let's see a service source in your template?
Danny
Danny3mo ago
No description
Brody
Brody3mo ago
then yeah it's an issue with the cli, please open an issue on the repo and I will notify the person who implemented the command
Danny
Danny3mo ago
GitHub
Template github source gets converted to dockerhub when using CLI t...
Hello, I'm attempting to deploy a user template using the Railway CLI. However, the GitHub source i gave to the template, gets converted to a docker source when using the Railway CLI railway de...
Duchess
Duchess3mo ago
New reply sent from Help Station thread:
Thanks for your help, hope this gets fixed.
You're seeing this because this thread has been automatically linked to the Help Station thread.
Brody
Brody3mo ago
perfect thanks! @Danny just to confirm again, you have deployed this exact same template in the dashboard just fine?
Danny
Danny3mo ago
yep
Brody
Brody3mo ago
@evan - the cli's deploy command is deploying GitHub repo's as docker images !t
Duchess
Duchess3mo ago
New reply sent from Help Station thread:
This thread has been escalated to the Railway team.
You're seeing this because this thread has been automatically linked to the Help Station thread.
evan
evan3mo ago
ack’d this may just be a visual bug
Brody
Brody3mo ago
oh yeah? I'm out so I can't test right now
evan
evan3mo ago
thanks for the deets - i’ll follow up later tonight once i’ve dug in a bit more
Brody
Brody3mo ago
I'll test when I can and update with more info too
evan
evan3mo ago
:hmm: looking at this again - i think the UI might make sense here? since you're deploying via CLI, we're keying off of that (even though it is a template)
Danny
Danny3mo ago
sorry but im not quite getting you, what do you mean exactly
evan
evan3mo ago
this template is getting deployed via the cli, right? (like, that is the trigger)
Danny
Danny3mo ago
yea thats correct
evan
evan3mo ago
so - even though it is connected to a source repository (ie. the template), you're manually triggering a CLI deployment so we're keying off of that does that make sense?
Danny
Danny3mo ago
yeh, that makes sense, but i still think its a bug. when i deployed it did show some connection to a source, but it was dockerhub user/repo instead of github user/repo
evan
evan3mo ago
do you mind sending me a link to the project?
Danny
Danny3mo ago
a thanks, yh thats basically the same
evan
evan3mo ago
o ye das weird thx brody will dive in 🏊‍♂️
Danny
Danny3mo ago
heya, sorry for the ping but any updates just yet? we're kinda stuck with our project right now, no pressure of course :happi:
evan
evan3mo ago
this shouldn’t be blocking - the deploy still goes out?
Danny
Danny3mo ago
it blocks our deploy, because it attempts do deploy via docker, which wil lalways fail
evan
evan3mo ago
hmm ok i thought it was just a visual thing - do you have the link to your project?
Danny
Danny3mo ago
give me a sec, ill generate one
evan
evan3mo ago
can just copy the url and send it here
Danny
Danny3mo ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Danny
Danny3mo ago
while its set to gh from the templates
Danny
Danny3mo ago
its not a visual bug, because it actually deploys images via docker
No description
evan
evan3mo ago
lookin
Danny
Danny3mo ago
oh and it also seems like its not even trying to deploy? that might just be from the missing docker image tho
No description
evan
evan3mo ago
so how do you actually want this to deploy?
Danny
Danny3mo ago
i want this to deploy via my github repo i have set in the template it is a private repo, but it should work fine as im authorized to access it from my acc might be causing the issue tho
evan
evan3mo ago
it says "source image" in the config
evan
evan3mo ago
No description
evan
evan3mo ago
so that's why it is trying to deploy as an image
Danny
Danny3mo ago
yh thats the issue
evan
evan3mo ago
swap that to be source repo can you link me to the template? you can unblock yourself here by swapping to the gh repo?
Danny
Danny3mo ago
yea i can, but we're creating these projects programmatically, so that wouldnt really solve the main issue. ill do it ig so i can continue testng on 1 instance could i send it in DM? its not really a public template
evan
evan3mo ago
if it isn't a public template, nobody will be able to access it (i will be able to see it b/c admin)
Danny
Danny3mo ago
oh i can access it from incognito, prob didnt set it as a private template then :PES3_Smile:
evan
evan3mo ago
will need to see the template to understand further
evan
evan3mo ago
404?
evan
evan3mo ago
is it a published template? ok got it now
Danny
Danny3mo ago
idk whats different bout the urls but the second one works somehow :NM_peepoIdk:
evan
evan3mo ago
second character is i vs l in second link i think hmm nvm case sensitivity
Danny
Danny3mo ago
aaa my clipboard lowercased it for some reason haha nice
evan
evan3mo ago
and you said if you deploy through the dashboard, its fine?
Danny
Danny3mo ago
yep
evan
evan3mo ago
odd ok i've captured this all and the team member who has built all of the template stuff is on-call starting tmrw, so they should have some better context on what's going wrong here than myself
Danny
Danny3mo ago
alrighty, thanku :happi:
evan
evan3mo ago
but if you want to unblock any dev beyond deploying the template, just swap it in the dashboard to be the gh repo source obvi
Danny
Danny3mo ago
yep, will do
evan
evan3mo ago
also - you may want to look into environments depending on your use case? may be more helpful than creating projects
Danny
Danny3mo ago
hmm yh that might be a good one ill look into it
Faraz
Faraz3mo ago
. Confirming I understand correctly. There is a template which works fine upon deploying via the dashboard but doesn't work properly when deploying via the CLI.
Brody
Brody3mo ago
Correct, the template has a service with a GitHub source, when deployed from the dashboard the service is deployed from GitHub, but when deploying the same template from the cli it's treated as an image source and it tries to pull it from the registry
Faraz
Faraz3mo ago
Seems like the attached repos don't exist anymore? Is this using private repos?
Brody
Brody3mo ago
example project and template yeah it's private, not sure if that's a factor
Faraz
Faraz3mo ago
Could you check if you can reproduce it with a template with a public repo?
Brody
Brody3mo ago
I can tomorrow as it's quite late for me (3:40am)
Faraz
Faraz3mo ago
You should sleep. 😴 I've checked + reproduced with a template with a public repo. I've PR-ed a fix (https://github.com/railwayapp/cli/pull/523). Will merge upon review as I've never written Rust before.
Solution
Faraz
Faraz3mo ago
Should be fixed in the latest release. Could you try it and let me know?
Brody
Brody3mo ago
(v3.11.2) - release is still running
Faraz
Faraz3mo ago
Was fixed in 3.11.1 no? .2 is JRs.
Brody
Brody3mo ago
haha i know but it caught me off guard :kekw:
No description
Brody
Brody3mo ago
update, works!
Want results from more Discord servers?
Add your server