R
Railwayā€¢5mo ago
m1rza

SpringBoot and Vue3, separate repos

PID: 316b545c-54be-4dbc-a060-bd5b8345755a Hi, I'm struggling to get my Vue repo to build and deploy in Railway. I started out with a monorepo of two modules (didn't know better) and separated them into two repos to have it be compatible with Railway. I've tried different POMs, no POM, searching for similar issues. Nothing worked for me. Right now I'm getting this error [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.15.0:npm (npm run build) on project m1rza-sp-frontend: Failed to run task: 'npm run build' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1] which then causes more errors resulting in Error: Docker build failed. The execution of npm install seems to have worked though. I'd appreciate it if someone could point me in the right direction.
108 Replies
Percy
Percyā€¢5mo ago
Project ID: 316b545c-54be-4dbc-a060-bd5b8345755a
Brody
Brodyā€¢5mo ago
care to share your two repos?
root
rootā€¢5mo ago
Actually, a monorepo would have worked fine, most likely - just set the root directory.
Brody
Brodyā€¢5mo ago
you handle the java app, I'll handle the vue3 app šŸ¤
root
rootā€¢5mo ago
It looks like you're using Maven to build your frontend? If you're using two separate repos, you should consider using Vite sorry, I couldn't help noticing how did I end up as the Java guy, anyway? I don't think I even wrote the provider oh right the templates
Brody
Brodyā€¢5mo ago
exactly, I have the front-end templates so that's my thing šŸ¤£
m1rza
m1rzaā€¢5mo ago
Hello @Brody and @aleks, thanks for the quick response. I posted this issue and fell over asleep. šŸ˜„ I actually have 3 repos: 1 monorepo with SB and Vue, and 2 separate repos. I'm flexible on which to use. Ye, I've never really worked with frontend till now, so Idk a lot about frontend build tools and such.
m1rza
m1rzaā€¢5mo ago
frontend pom. It doesn't even need to be a Maven build, I picked Maven because some guide had me make a multimodule repo with maven and promised it "just works" but then it didn't "just work" so I thought I'd make it work by splitting the thing into two repos and two services.
m1rza
m1rzaā€¢5mo ago
How do I do that without making it completely public for everyone?
Brody
Brodyā€¢5mo ago
let's go ahead and use your isolated monorepo, so you can add us to the repo? my gh username is brody192 (I forgot alek's username)
m1rza
m1rzaā€¢5mo ago
aight, thats good, adding added in the monorepo mvn build fails with
m1rza
m1rzaā€¢5mo ago
No description
Brody
Brodyā€¢5mo ago
screenshot of the railway project please
m1rza
m1rzaā€¢5mo ago
this? monorepo + two standalone repos
No description
m1rza
m1rzaā€¢5mo ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Brody
Brodyā€¢5mo ago
oh you're already using vite for your frontend like aleks suggested!!
m1rza
m1rzaā€¢5mo ago
aye
m1rza
m1rzaā€¢5mo ago
mydeveloperplanet
How to Setup Spring Boot With Vue.js Frontend
In this blog, you will learn how to setup a Maven multi-module project which consists out of a Spring Boot backend and a Vue.js frontend. The application itself will not be created, only the setup ā€¦
m1rza
m1rzaā€¢5mo ago
(and a few very similar guides) but I just fails šŸ˜¦ note: no quasar
Brody
Brodyā€¢5mo ago
so either way, if you have a monorepo with two apps, or two repos with a single app per repo, you still have two apps, so you still need two services
m1rza
m1rzaā€¢5mo ago
oh
Brody
Brodyā€¢5mo ago
so you can delete that service called SteamPlanner
m1rza
m1rzaā€¢5mo ago
done the remaining two services are based on the two separate repos
Brody
Brodyā€¢5mo ago
we can leave them, they're perfectly named for what we want to do give me a few minutes to look over the frontend and advice further, I'd only be able to help you deploy the front-end though as aleks has the java experience not me
m1rza
m1rzaā€¢5mo ago
thats the only help i need šŸ˜„ sure thing, i'm standing by, take your time
Brody
Brodyā€¢5mo ago
I'm seeing some things that are out of place, let's delete the node folder and the pom.xml locally and on github from the frontend folder, this isn't all we'll need to do, but it's what I've seen so far
m1rza
m1rzaā€¢5mo ago
doing delete the pom inside the frontend module?
Brody
Brodyā€¢5mo ago
yeah it's a JavaScript app not a java app šŸ˜†
m1rza
m1rzaā€¢5mo ago
šŸ˜„ i just started doing vue stuff last friday man šŸ˜„ deleted
Brody
Brodyā€¢5mo ago
well then you already know more than me about vue
root
rootā€¢5mo ago
my github username is aleksrutins
m1rza
m1rzaā€¢5mo ago
there is also frontend\angular\node?
Brody
Brodyā€¢5mo ago
vite doesn't have a sufficient production ready web server, so we'll need to setup one ourselves, let's use caddy https://github.com/railwayapp-templates/vue-starter copy the nixpacks.toml and Caddyfile from this repo into your frontend folder what do you mean?
m1rza
m1rzaā€¢5mo ago
invited
m1rza
m1rzaā€¢5mo ago
No description
m1rza
m1rzaā€¢5mo ago
doing
Brody
Brodyā€¢5mo ago
yeah we don't want that in the repo
root
rootā€¢5mo ago
It looks like this guide doesn't actually require a separate server for the frontend, despite what it says at the top
Brody
Brodyā€¢5mo ago
in fact we don't even really want it locally either haha
m1rza
m1rzaā€¢5mo ago
done deleted that too
Brody
Brodyā€¢5mo ago
deleted locally too?
m1rza
m1rzaā€¢5mo ago
aye
Brody
Brodyā€¢5mo ago
you have a .txt extension on the Caddyfile, pro tip, turn on file extensions in windows
m1rza
m1rzaā€¢5mo ago
shit, fixed
Brody
Brodyā€¢5mo ago
add a service variable VITE_BACKEND_URL to the frontend service with https://${{SteamPlannerBackend.RAILWAY_PUBLIC_DOMAIN}}
m1rza
m1rzaā€¢5mo ago
added The current frontend service is based on the separated frontend repo.
Brody
Brodyā€¢5mo ago
then on line 28 of your SharedLibrary.vue file (and everywhere else you make a fetch call) change it to import.meta.env.VITE_BACKEND_URL + "/library/shared/" + this.steamIds (of course other fetch requests would have different paths, but you get the idea)
m1rza
m1rzaā€¢5mo ago
done
Brody
Brodyā€¢5mo ago
was that the only place you do a fetch to the backend?
m1rza
m1rzaā€¢5mo ago
nah, there was 4-5, i changed them all
Brody
Brodyā€¢5mo ago
okay perfect, you work fast
m1rza
m1rzaā€¢5mo ago
HOWEVER, i changed it in the monorepo gotta go fast
Brody
Brodyā€¢5mo ago
yeah that's what I'm shared to, and that's what we are going to use on railway
m1rza
m1rzaā€¢5mo ago
kk
Brody
Brodyā€¢5mo ago
so set the root directory on your frontend service to /frontend and then attach the monorepo to the service
m1rza
m1rzaā€¢5mo ago
done, i think i see where you're going with this
No description
m1rza
m1rzaā€¢5mo ago
No description
Brody
Brodyā€¢5mo ago
interesting I assume you can build the front-end locally without problems via npm run build right?
m1rza
m1rzaā€¢5mo ago
ye
Brody
Brodyā€¢5mo ago
can you send your build logs please https://bookmarklets.up.railway.app/log-downloader/
m1rza
m1rzaā€¢5mo ago
well now the local build fails because
No description
m1rza
m1rzaā€¢5mo ago
which is my mistake since i failed to use brain fixing
Brody
Brodyā€¢5mo ago
oh right you'd need a .env.local file with that variable defined to the local address of the backend http://127.0.0.1:8000 I think it was?
m1rza
m1rzaā€¢5mo ago
8080, but yes
Brody
Brodyā€¢5mo ago
close enough :kekw:
m1rza
m1rzaā€¢5mo ago
local npm run build works
m1rza
m1rzaā€¢5mo ago
No description
m1rza
m1rzaā€¢5mo ago
service still fails with MODULE_NOT_FOUND
Brody
Brodyā€¢5mo ago
can I see a screenshot of your local project files for frontend
m1rza
m1rzaā€¢5mo ago
No description
m1rza
m1rzaā€¢5mo ago
No description
Brody
Brodyā€¢5mo ago
looks good to me as far as I know what node version do you use locally?
m1rza
m1rzaā€¢5mo ago
20.11.0
m1rza
m1rzaā€¢5mo ago
There is this
No description
m1rza
m1rzaā€¢5mo ago
in the service build logs
Brody
Brodyā€¢5mo ago
build logs please
Brody
Brodyā€¢5mo ago
that's using node 18, but you use node 20 locally, so let's try getting your build on railway to use node 20 also. in your package.json set engines.node to just 20. delete your package lock file and run npm i --package-lock-only to re-generate it. push the changes, if the build fails, send log
m1rza
m1rzaā€¢5mo ago
doing
m1rza
m1rzaā€¢5mo ago
still fail, same error Tried with engines.node 20 and 20.11.0
Brody
Brodyā€¢5mo ago
you just sent the same file?
m1rza
m1rzaā€¢5mo ago
m1rza
m1rzaā€¢5mo ago
they have the same context
m1rza
m1rzaā€¢5mo ago
sent ya the marked one
No description
m1rza
m1rzaā€¢5mo ago
super fresh logs
m1rza
m1rzaā€¢5mo ago
ok trying šŸ˜®
m1rza
m1rzaā€¢5mo ago
No description
m1rza
m1rzaā€¢5mo ago
IT IS UP
Brody
Brodyā€¢5mo ago
woohoo
m1rza
m1rzaā€¢5mo ago
Do I set the Backend service to monorepo and set directory to /backend? ofc i do
Brody
Brodyā€¢5mo ago
yeah, but if theres build errors, i likely wont be able to help, java is alek's thing and i have never even touched a single line of java
m1rza
m1rzaā€¢5mo ago
smart man java makes me age
Brody
Brodyā€¢5mo ago
why use it lol
m1rza
m1rzaā€¢5mo ago
but then every language does that
Brody
Brodyā€¢5mo ago
you use ts for the frontend, just use ts for the backend too
m1rza
m1rzaā€¢5mo ago
and throw away the years spent paining through java? never!
Brody
Brodyā€¢5mo ago
fair enough
m1rza
m1rzaā€¢5mo ago
gonna have to teach the backend to talk to the service now CORS and shit but you did solve the problem i had thank you man trains for ya
Brody
Brodyā€¢5mo ago
thank you i appreciate that
m1rza
m1rzaā€¢5mo ago
Quick question, in the backend service I've gotta enable Private Networking and reference this value in the frondend service as a variable?
No description
Brody
Brodyā€¢5mo ago
this is a client side rendered app, you would need to use the public domain, wouldnt me much of a private network if a users browser could make requests to it.
m1rza
m1rzaā€¢5mo ago
aye ofc i knew that immediately
Brody
Brodyā€¢5mo ago
its easy to overlook
m1rza
m1rzaā€¢5mo ago
everything is up and running, working on new features now. thanks again to the both of you
Brody
Brodyā€¢5mo ago
happy to help ā¤ļø