R
Railway•8mo 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•8mo ago
Project ID: N/A
root
root•8mo ago
N/A Add a nixpacks.toml with this:
Brody
Brody•8mo ago
ng serve starts a development server, that definitely not what we want
Bread
Bread•8mo ago
coulkd you tell me where i am kinda new
root
root•8mo ago
providers = ['...', 'staticfile']

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

[phases.build]
cmds = ['npm run build']
In your project root
Brody
Brody•8mo ago
aleks do you mind if i take this thread over
root
root•8mo ago
alright
Brody
Brody•8mo ago
thank you
root
root•8mo ago
why the thumbs down though?
Bread
Bread•8mo ago
😭
Brody
Brody•8mo ago
not a good solution
root
root•8mo ago
oh, spring backend - is the backend in a separate service?
Bread
Bread•8mo ago
it is also in the same project but it is working nice
root
root•8mo 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•8mo ago
this is angular
root
root•8mo ago
It's also Spring
Bread
Bread•8mo ago
i have problem with angular
root
root•8mo ago
Alright sorry, I'll pipe down now
Bread
Bread•8mo ago
my spring project is working but thanks for goodwill
Brody
Brody•8mo ago
okay bread, in your angular.json make sure your build outputPath is set to dist
Brody
Brody•8mo ago
No description
Bread
Bread•8mo ago
No description
Bread
Bread•8mo ago
okay
Brody
Brody•8mo ago
do you have a build script in your package.json?
Bread
Bread•8mo ago
No description
Bread
Bread•8mo ago
is it okay?
Brody
Brody•8mo 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
Bread•8mo ago
No description
Bread
Bread•8mo ago
okay i copied them
Brody
Brody•8mo ago
railway should be rebuilding now right?
Bread
Bread•8mo ago
yeah oh it didn't crash
Brody
Brody•8mo ago
thats a good start lol
Bread
Bread•8mo ago
No description
Bread
Bread•8mo ago
is it good?
Brody
Brody•8mo ago
looks great does your service have a domain?
Bread
Bread•8mo ago
oh it works
Brody
Brody•8mo ago
awsome
Bread
Bread•8mo ago
i am sooo 😎 thank you so much
Brody
Brody•8mo ago
no problem!
Bread
Bread•8mo ago
i am so grateful
Brody
Brody•8mo ago
java is aleks's thing, and single page web apps are my thing
Bread
Bread•8mo ago
well spring boot was easier to deploy
Brody
Brody•8mo 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
Bread•8mo ago
thank you once again
Brody
Brody•8mo ago
no problem, happy to help 🙂
Bread
Bread•8mo ago
should i close this thread or something like that?
Brody
Brody•8mo ago
ive already marked as solved, its all good
Bread
Bread•8mo ago
thank you and have a good day
Brody
Brody•8mo ago
you too!
FerDev
FerDev•8mo ago
Hi, Brody. Could you explain me why this, please?
Brody
Brody•8mo ago
a development server uses significantly more resources and is also significantly less performant compared to a proper web server
FerDev
FerDev•8mo ago
But when you use Caddy you are depending on third party projects while with ng serve no
Brody
Brody•8mo 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•8mo 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•8mo 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•8mo 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•8mo 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•8mo ago
Thanks, bro. You're amazing. No more for my side
Brody
Brody•8mo 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