#Running Yarn in a Python build

6 messages · Page 1 of 1 (latest)

uncut venture
#

I have a Django+Vue app. Once the Vue bit is built with Yarn, everything is handled with Whitenoise+Django. This works locally, and if I build my Vue stuff before sending it to Railway, it also works. But, I don't want to do this manually every time. I do not check my built files into source control. I would like the Build process to include running yarn build

My understanding is that Railway is automatically determining that my project is a Python project by the root directory. It is not looking into the frontend directory to see a yarn.lock or package.json in there.

How can I resolve this? In the ideal situation, when the build is triggered with a branch change, yarn build will be run sometime before Django's runserver command. Unfortunately, just putting this as part of, say, the Procfile just gives yarn: command not found.

Some non-ideal solutions would be: Checking my files into source control. Having a separate project for the frontend. Putting dummy files into root to "trick" it into recognizing that it's got a Javascript component. However, if any of these are necessary, I can use those workarounds...

project id: 00e357e0-9d2a-45be-8a64-a58b8ee28694
(What can you see with this? Does this even help?)

hollow pecanBOT
#

Project ID: 00e357e0-9d2a-45be-8a64-a58b8ee28694

swift igloo
uncut venture
#

It was this:

║ setup      │ python37, gcc                                                   ║
║──────────────────────────────────────────────────────────────────────────────║
║ install    │ python -m venv /opt/venv && . /opt/venv/bin/activate && pip     ║
║            │ install -r requirements.txt                                     ║
║──────────────────────────────────────────────────────────────────────────────║
║ start      │ python manage.py migrate && python manage.py collectstatic      ║
║            │ --noinput && gunicorn scorepost.wsgi                            ║
╚══════════════════════════════════════════════════════════════════════════════╝```
I changed it to this:
```╔═══════════════════════════════ Nixpacks v1.0.5 ══════════════════════════════╗
║ setup      │ python37, gcc                                                   ║
║──────────────────────────────────────────────────────────────────────────────║
║ install    │ python -m venv /opt/venv && . /opt/venv/bin/activate && pip     ║
║            │ install -r requirements.txt                                     ║
║──────────────────────────────────────────────────────────────────────────────║
║ build      │ cd frontend && yarn run build                                   ║
║──────────────────────────────────────────────────────────────────────────────║
║ start      │ python manage.py migrate && python manage.py collectstatic      ║
║            │ --noinput && gunicorn scorepost.wsgi                            ║
╚══════════════════════════════════════════════════════════════════════════════╝```
However, I still see this on the last step: `/bin/bash: line 1: yarn: command not found`
I suspect I need something else in the `setup` but I'm not sure what. I'll try just `yarn`
#

Moving forward 😄
Got this now: vue-cli-service: not found but I'm pretty sure I can figure it out from here.
As an aside, is there a way to manually build from a (remote) github branch without the trigger?