R
Railway•11mo ago
zbellay

Django Project is Built as Node.js Project

Hello! I am in the process of adding a build step in my django project by building javascript code via vite.js. However, no matter what I do the build process thinks my project is a nodejs project: See attached photo In the settings tab, I have set "Railway Config File Path" to my nixpacks.toml file. In my nixpacks.toml I have the following file:
providers = ['python']

[phases.setup]
cmds = ['cd ./money && npm install']

[phases.build]
cmds = ['cd ./money && vite build']

[start]
cmds = 'python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi'
providers = ['python']

[phases.setup]
cmds = ['cd ./money && npm install']

[phases.build]
cmds = ['cd ./money && vite build']

[start]
cmds = 'python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi'
I'd appreciate getting help to get my deployment to actually listen to my nixpacks.toml file! Service ID: abfcdf55-e734-425a-8e4f-094f7c8e5d8c Github Link: https://github.com/zachbellay/fun3
GitHub
GitHub - zachbellay/fun3
Contribute to zachbellay/fun3 development by creating an account on GitHub.
No description
17 Replies
Percy
Percy•11mo ago
Project ID: abfcdf55-e734-425a-8e4f-094f7c8e5d8c
Fragly
Fragly•11mo ago
it's weird that it's ignoring the providers option in nixpacks toml 🤔
Brody
Brody•11mo ago
so you have a frontend built with vite, and then a backend built with django?
zbellay
zbellay•11mo ago
Right, the frontend should get built and then served as a static asset by django
Brody
Brody•11mo ago
from my experience, thats not a good idea, django should not serve the frontend, thats not what its designed for would you like my help to set it up properly?
zbellay
zbellay•11mo ago
What approach would you suggest?
Brody
Brody•11mo ago
an isolated monorepo. a repo that contains two folders: /frontend and /backend you would separate your frontend and backend code out into their respective folders. then from the railway side of things you would have a service that runs your frontend and another to run the backend.
zbellay
zbellay•11mo ago
I see, yeah in my case I'm not using django rest framework so I don't have a JSON API or anything. All I'm trying to do is serve these static assets, I am partial to my current approach. With that said, how can I get the build to recognize my project as a python project instead of a node project?
Brody
Brody•11mo ago
ah you said "right" to this question, but i wasnt right in that case i will go look at your repo so i can hopefully work out a build plan
zbellay
zbellay•11mo ago
Thank you @Brody, I appreciate it!
Brody
Brody•11mo ago
new railway.json
{
"$schema": "https://schema.up.railway.app/railway.schema.json",
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi"
}
}
{
"$schema": "https://schema.up.railway.app/railway.schema.json",
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi"
}
}
new nixpacks.toml
providers = ['python']

[phases.setup]
nixPkgs = ['...', 'nodejs']

[phases.money-install]
dependsOn = ['setup']
cmds = ['npm install --prefix money']

[phases.money-build]
dependsOn = ['money-install']
cmds = ['npm run build --prefix money']
providers = ['python']

[phases.setup]
nixPkgs = ['...', 'nodejs']

[phases.money-install]
dependsOn = ['setup']
cmds = ['npm install --prefix money']

[phases.money-build]
dependsOn = ['money-install']
cmds = ['npm run build --prefix money']
and lastly, move the package.json from the root into the money folder, with this the build did go through, but i got postgres connection errors but thats normal since i dont have any of that setup
zbellay
zbellay•11mo ago
@Brody I went ahead and updated my nixpacks.toml and railway.json, and also moved my package.json into the money directory But it's still not recognizing the build as a python build.
No description
Brody
Brody•11mo ago
let me check your repo, one sec repo looks fine, theres a chance the railway service itself has gotten stuck on node as the provider, can you try deploying your repo in a new service?
zbellay
zbellay•11mo ago
For whatever reason it seems like that fixed it, thank you @Brody !
Brody
Brody•11mo ago
app deploys and displays just fine?
zbellay
zbellay•11mo ago
Yup! There are some things I have to debug now but the build works ok. Thanks again!!
Brody
Brody•11mo ago
no problem!
Want results from more Discord servers?
Add your server