R
Railway•13mo ago
Bread

Angular front-End

Hi, I try to make angular front end with spring back end. I tried to find on the internet how to deploy angular on railway, but i could not find any help. Could someone tell me how to deploy angular frontend on railway.
No description
59 Replies
Percy
Percy•13mo ago
Project ID: N/A
root
root•13mo ago
N/A Add a nixpacks.toml with this:
Brody
Brody•13mo ago
ng serve starts a development server, that definitely not what we want
Bread
BreadOP•13mo ago
coulkd you tell me where i am kinda new
root
root•13mo ago
providers = ['...', 'staticfile']

[phases.build]
cmds = ['npm run build']
providers = ['...', 'staticfile']

[phases.build]
cmds = ['npm run build']
In your project root
Brody
Brody•13mo ago
aleks do you mind if i take this thread over
root
root•13mo ago
alright
Brody
Brody•13mo ago
thank you
root
root•13mo ago
why the thumbs down though?
Bread
BreadOP•13mo ago
😭
Brody
Brody•13mo ago
not a good solution
root
root•13mo ago
oh, spring backend - is the backend in a separate service?
Bread
BreadOP•13mo ago
it is also in the same project but it is working nice
root
root•13mo ago
sorry, I know I said you could take this over, but I did write the Spring templates, so I know how to use Spring w/ Railway
Brody
Brody•13mo ago
this is angular
root
root•13mo ago
It's also Spring
Bread
BreadOP•13mo ago
i have problem with angular
root
root•13mo ago
Alright sorry, I'll pipe down now
Bread
BreadOP•13mo ago
my spring project is working but thanks for goodwill
Brody
Brody•13mo ago
okay bread, in your angular.json make sure your build outputPath is set to dist
Brody
Brody•13mo ago
No description
Bread
BreadOP•13mo ago
No description
Bread
BreadOP•13mo ago
okay
Brody
Brody•13mo ago
do you have a build script in your package.json?
Bread
BreadOP•13mo ago
No description
Bread
BreadOP•13mo ago
is it okay?
Brody
Brody•13mo ago
yep perfect https://github.com/brody192/angular-template copy the nixpacks.toml and Caddyfile from this repo into your angular projects folder then push the changes to github
Bread
BreadOP•13mo ago
No description
Bread
BreadOP•13mo ago
okay i copied them
Brody
Brody•13mo ago
railway should be rebuilding now right?
Bread
BreadOP•13mo ago
yeah oh it didn't crash
Brody
Brody•13mo ago
thats a good start lol
Bread
BreadOP•13mo ago
No description
Bread
BreadOP•13mo ago
is it good?
Brody
Brody•13mo ago
looks great does your service have a domain?
Bread
BreadOP•13mo ago
oh it works
Brody
Brody•13mo ago
awsome
Bread
BreadOP•13mo ago
i am sooo 😎 thank you so much
Brody
Brody•13mo ago
no problem!
Bread
BreadOP•13mo ago
i am so grateful
Brody
Brody•13mo ago
java is aleks's thing, and single page web apps are my thing
Bread
BreadOP•13mo ago
well spring boot was easier to deploy
Brody
Brody•13mo ago
yeah railway has a provider for java, they dont have one for single page apps like angular though so thats why we needed the nixpacks.toml file i wrote
Bread
BreadOP•13mo ago
thank you once again
Brody
Brody•13mo ago
no problem, happy to help 🙂
Bread
BreadOP•13mo ago
should i close this thread or something like that?
Brody
Brody•13mo ago
ive already marked as solved, its all good
Bread
BreadOP•13mo ago
thank you and have a good day
Brody
Brody•13mo ago
you too!
FerDev
FerDev•13mo ago
Hi, Brody. Could you explain me why this, please?
Brody
Brody•13mo ago
a development server uses significantly more resources and is also significantly less performant compared to a proper web server
FerDev
FerDev•13mo ago
But when you use Caddy you are depending on third party projects while with ng serve no
Brody
Brody•13mo ago
caddy is marketed as an enterprise grade web server, there's absolutely nothing wrong with depending on it ng serve can use up to 20 times more memory than caddy, and like mentioned ng serve is significantly slower, it's only meant to be used for development purposes and not for running in a production environment like railway
FerDev
FerDev•13mo ago
Only for learning and performance testing purposes can you explain me how to run the project with ng serve? I would like to compare both deployments
Brody
Brody•13mo ago
configure ng serve to listen on host 0.0.0.0 and the environment variable PORT through some command line flags in your start script but I promise you, it's not worth it, in fact the original thread creator was getting out of memory errors because ng serve was using more than 512mb of ram that means ng serve wanted to use even more than 512mb of ram, for context just 500mb of ram for a whole month is 5$ on railway, in contrast caddy uses around 30mb, that's less than 50 cents
FerDev
FerDev•13mo ago
I won't do it, I believe you. Without getting away from the focus of the conversation, my last question is how could you know about Caddy and were you able to implement it to Railway only with documentation from both parties?
Brody
Brody•13mo ago
ive used caddy for a very long time, long before i knew of railway and i didnt need to really read either railways or caddys docs to implement caddy since i have already read both docs before attempting this integration, only looked at them for quick references
FerDev
FerDev•13mo ago
Thanks, bro. You're amazing. No more for my side
Brody
Brody•13mo ago
if you have any questions on how ive done the integration feel free to ask, but both the nixpacks and caddyfiles i have written are filled with comment lines
Want results from more Discord servers?
Add your server