Hi!
I have a problem trying to deploy my app. I recognize is quite tricky but it's the best solution I found to have the structure I need.
My app it's a Vite/ReactJS app and it runs perfectly, but I need to create a blog so I decide to create a solution with Astro inside my Vite/ReactJS app.
So my structure looks like a tipical ReactJS app but I created a
/blog
folder with a Astro project and I modified my build script and looks like this
"build": "vite build && cd blog && npm run build"
vite build
works fine but I have a problem with Astro
Looks like astro build
it's not working. I try to add engine: 18
on my package.json but it doesn't works.
Thanks for your help and patienceSolution:Jump to solution
yes but thats not a good idea in my opinion, can we instead have your react app on domain.com, and your blog on blog.domain.com?
81 Replies
Project ID:
863d09e4-f366-4c2c-90bc-5991b840e2a0
could you share your repo, that would give us the best possible overview of what you are trying to do
863d09e4-f366-4c2c-90bc-5991b840e2a0
It's private but If you want I can share with your github user
yes please, brody192
Ok I just added you
any specific branch i should be looking at?
main
directlyso you just want to deploy the app within /blog and dont care about anything in the root?
yeah my idea it's to deploy the asto into the dist folder like an static project
so I think this approach it was the best to achive it
making both builds at the same time
does anything in /blog depend on anything outside of /blog?
nope
It's independent
perfect, so first things first, you will need to configure your blog app to use the node adapter
makes sense ok
example https://github.com/brody192/astrowind-template/blob/main/astro.config.mjs#L34-L40
let me know when done!
there is steps after this, but one thing at a time
ok, I just pushed the node adapter
that was fast, ill take a look
missed the server object
ok added
okay in the blog's package.json set the start script to
node dist/server/entry.mjs
and also remove any build or start commands you may have set in your services settings👍🏻
OK the scripts in the blog looks like this
looks good, now just set the root directory in the service settings to
/blog
ok its redeploying
it fails
no worries, lets work through it, can you send me the build logs please https://bookmarklets.up.railway.app/log-downloader/
sorry the tool doesn't works but heres the log
what browser are you using?
chrome
ok now works
always has
it was my fault sorry
can you run
npm run build
locally?ok
on root right?
i have an error
in the blog folder run
npm run build
ah ok
same issue
okay please get your app building locally
i'm adding this package
mmm looks like i need to install multiple packages but not sure if do it on blog or root directory
blog is isolated from the rest as youve said
oki
ok looks like locally runs fine I just pushed
it fails again
in the blog folder, can you run
npm run build
locally?yes, I just pushed again with the yarn.lock file
locally do you use yarn or npm?
I used to use yarn
what do you use now?
If i try yarn build in the root I see this error
I prefer yarn
im not sure why you are trying to do stuff in the root? this thread is about running the blog on railway, right?
yes sorry
can you build the blog locally with yarn?
yes
works fine in my local
what command do you run locally yo build blog?
and what folder are in you when you do that?
npm run build
???
maybe I missunderstand something sorry
what version of node are you using locally
v18.18.0
i saw this in the build log
I added in my local and the build works fine
but It doesn't work on server 😦
whats your root directory set to on your railway service?
unfortunately i dont know why you get that error, but it is a code issue, so please try your best to resolve it
mmm looks like it´s something related with the adapter
if I set it to static it deploys fine, but it crash because the adapter node its for output server
so I think its not a code issue it works fine in my local
for railway, it needs to use a node adapter
this isnt an issue with railway, i know that much
maybe its not compatible
also it's so strange i need to add packages manually that I dont use in my code
i have an astro template and it works just fine, this isnt an issue with railway
looks like astro in server output needs something that it´s not compatible with the build process
mmm if I put your template into the blog folder should be fine?
some kinda of config / code issue on your part
yeah theoretically
I'll try
it fails
i just deployed the template, no issues https://astrowind-site-production-b7e0.up.railway.app/
mmm yes but my configuration its something more complex. I have my reactJs and the astro blog
you said blog is completely separate and doesn’t rely on anything outside of the blog folder
you cant copy in 1/4 of the astrowind project and expect it to build
sorry maybe I didn't explain what I need.
1. Build my Vite/React app
2.Build my Astro blog and put it into the Vite/React
/dist/blog
folder
That's why my first idea was change my build script into the React app into this
Is it possible?Solution
yes but thats not a good idea in my opinion, can we instead have your react app on domain.com, and your blog on blog.domain.com?
Well I'm planning to have a great url
domain.com/blog/first-blog
domain.com/blog/es/primer-blog
domain.com/blog/en/primer-blog
I get it
ok
thats the better solution in my opinion, its how railway does it too
but why it's not a good idea my first approach?
you are building two completely separate apps and then combining them, im sure i could work out a decent way to do that, but blog.domain.com is far better and more appropriate
mmm ok. I'll think about it. Thanks for your time @Brody . I really appreciate it ❤️
for the record, in my experience, it is never a good idea to be cd'ing around like this, and when cd is used like this, it usually means you are doing something wrong.
My other idea was to move everything to NextJS but it's to hard to move everything to NextJS just because I need a blog in my project agree. It was the first time I used this kind of solution
so yeah, going forward you want an isolated mono repo.
in the repo you want two folders
/blog
and
/mysite
(or whatever you wanna name it)
then in railway you will have two services, each set with the appropriate root dir and with the applicable domain added
astro still needs to build with the node adapter though, so you still need to sort those build errors outOk will try your solution creating a subdomain. Thanks