R
Railway4mo 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
Percy4mo ago
Project ID: N/A
Danny
DannyOP4mo ago
N/A
Danny
DannyOP4mo ago
Here's my fetch
Danny
DannyOP4mo ago
and here's the result
No description
Brody
Brody4mo ago
you are calling templateDeploy aka v1, you should call templateDeployV2 with the correct serialized config structure
Danny
DannyOP4mo ago
aah, didnt know there was a v2 thanks, ill look into it! i cant seem to find templatedeployv2 in the graphiql docs?
Danny
DannyOP4mo ago
it really does not want me to use it
No description
Brody
Brody4mo ago
use the internal endpoint
Danny
DannyOP4mo ago
Where is the internal endpoint?
Danny
DannyOP4mo ago
Aha, thanks! I hope i can figure it out :happi:
Brody
Brody4mo 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
DannyOP4mo 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
Brody4mo ago
and you want to deploy a template automatically on sign up or something?
Danny
DannyOP4mo ago
So we can just click 1 button that sets up an entire instance Yea Or well, we click the create button
Brody
Brody4mo ago
single tenant app eh?
Danny
DannyOP4mo 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
Brody4mo ago
you dont think your time would be better spent converting it to a multi tenant app for better scalability?
Danny
DannyOP4mo 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
Brody4mo ago
fair enough
Danny
DannyOP4mo ago
And we just thought this would be fun haha
Danny
DannyOP4mo ago
Danny
DannyOP4mo ago
This is only the sidebar :NM_PepeExplode:
Brody
Brody4mo ago
damn hey i have an idea
Danny
DannyOP4mo ago
👂
Brody
Brody4mo 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
DannyOP4mo ago
oooo Yea that'd be way easier
Brody
Brody4mo ago
what language where you planning to write the code to deploy a template in?
Danny
DannyOP4mo ago
Node
Brody
Brody4mo ago
then you could call out to the cli
Danny
DannyOP4mo ago
(or bun if we're specific :bun: ) Yeah, i'll try that probablh
Brody
Brody4mo ago
bun has great support for calling out to cli apps doesnt it?
Danny
DannyOP4mo ago
Oh yeah they introduced that lately I'll see how it goes!
Brody
Brody4mo ago
let me know too!
Danny
DannyOP4mo ago
Bun
$ Shell – API | Bun Docs
Bun's cross-platform shell-scripting API makes shell scripting with JavaScript fun
Danny
DannyOP4mo 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
Brody4mo ago
let's see a service source in your template?
Danny
DannyOP4mo ago
No description
Brody
Brody4mo 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
DannyOP4mo 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
Duchess4mo 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
Brody4mo ago
perfect thanks! @Danny just to confirm again, you have deployed this exact same template in the dashboard just fine?
Danny
DannyOP4mo ago
yep
Brody
Brody4mo ago
@evan - the cli's deploy command is deploying GitHub repo's as docker images !t
Duchess
Duchess4mo 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
evan4mo ago
ack’d this may just be a visual bug
Brody
Brody4mo ago
oh yeah? I'm out so I can't test right now
evan
evan4mo ago
thanks for the deets - i’ll follow up later tonight once i’ve dug in a bit more
Brody
Brody4mo ago
I'll test when I can and update with more info too
evan
evan4mo 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
DannyOP4mo ago
sorry but im not quite getting you, what do you mean exactly
evan
evan4mo ago
this template is getting deployed via the cli, right? (like, that is the trigger)
Danny
DannyOP4mo ago
yea thats correct
evan
evan4mo 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
DannyOP4mo 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
evan4mo ago
do you mind sending me a link to the project?
Danny
DannyOP4mo ago
a thanks, yh thats basically the same
evan
evan4mo ago
o ye das weird thx brody will dive in 🏊‍♂️
Danny
DannyOP4mo 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
evan4mo ago
this shouldn’t be blocking - the deploy still goes out?
Danny
DannyOP4mo ago
it blocks our deploy, because it attempts do deploy via docker, which wil lalways fail
evan
evan4mo ago
hmm ok i thought it was just a visual thing - do you have the link to your project?
Danny
DannyOP4mo ago
give me a sec, ill generate one
evan
evan4mo ago
can just copy the url and send it here
Danny
DannyOP4mo 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
DannyOP4mo ago
while its set to gh from the templates
Danny
DannyOP4mo ago
its not a visual bug, because it actually deploys images via docker
No description
evan
evan4mo ago
lookin
Danny
DannyOP4mo 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
evan4mo ago
so how do you actually want this to deploy?
Danny
DannyOP4mo 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
evan4mo ago
it says "source image" in the config
evan
evan4mo ago
No description
evan
evan4mo ago
so that's why it is trying to deploy as an image
Danny
DannyOP4mo ago
yh thats the issue
evan
evan4mo 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
DannyOP4mo 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
evan4mo 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
DannyOP4mo ago
oh i can access it from incognito, prob didnt set it as a private template then :PES3_Smile:
evan
evan4mo ago
will need to see the template to understand further
evan
evan4mo ago
404?
Danny
DannyOP4mo ago
evan
evan4mo ago
is it a published template? ok got it now
Danny
DannyOP4mo ago
idk whats different bout the urls but the second one works somehow :NM_peepoIdk:
evan
evan4mo ago
second character is i vs l in second link i think hmm nvm case sensitivity
Danny
DannyOP4mo ago
aaa my clipboard lowercased it for some reason haha nice
evan
evan4mo ago
and you said if you deploy through the dashboard, its fine?
Danny
DannyOP4mo ago
yep
evan
evan4mo 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
DannyOP4mo ago
alrighty, thanku :happi:
evan
evan4mo 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
DannyOP4mo ago
yep, will do
evan
evan4mo ago
also - you may want to look into environments depending on your use case? may be more helpful than creating projects
Danny
DannyOP4mo ago
hmm yh that might be a good one ill look into it
Faraz
Faraz4mo 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
Brody4mo 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
Faraz4mo ago
Seems like the attached repos don't exist anymore? Is this using private repos?
Brody
Brody4mo ago
example project and template yeah it's private, not sure if that's a factor
Faraz
Faraz4mo ago
Could you check if you can reproduce it with a template with a public repo?
Brody
Brody4mo ago
I can tomorrow as it's quite late for me (3:40am)
Faraz
Faraz4mo 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
Faraz4mo ago
Should be fixed in the latest release. Could you try it and let me know?
Brody
Brody4mo ago
(v3.11.2) - release is still running
Faraz
Faraz4mo ago
Was fixed in 3.11.1 no? .2 is JRs.
Brody
Brody4mo ago
haha i know but it caught me off guard :kekw:
No description
Brody
Brody4mo ago
update, works!
Want results from more Discord servers?
Add your server