Running Yarn in a Python build

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?)
4 Replies
Percy
Percy2y ago
Project ID: 00e357e0-9d2a-45be-8a64-a58b8ee28694
Adam
Adam2y ago
If you take a look at your build logs on Railway you’ll find the build, start, and installation commands that Railway is automatically detecting. If you copy those into a nixpacks.toml, you can customize them however you’d like. https://nixpacks.com/docs/configuration/file
Configuration File Reference | Nixpacks
App source + Nix packages + Docker = Image
mystic
mysticOP2y ago
It was this:
╔═══════════════════════════════ Nixpacks v1.0.5 ══════════════════════════════╗
║ 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 ║
╚══════════════════════════════════════════════════════════════════════════════╝
╔═══════════════════════════════ Nixpacks v1.0.5 ══════════════════════════════╗
║ 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 ║
╚══════════════════════════════════════════════════════════════════════════════╝
╔═══════════════════════════════ 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? My main issue is now solved. Thank you !!
Want results from more Discord servers?
Add your server