R
Railway11mo ago
Tockus

Can't figure out how to deploy Node.js project from CLI.

Good day everyone, I'm having issues figuring out how to deploy project from local terminal using railway CLI. I'm new to Railway, but I've went through docs. Basically I have files (.js, .json) inside /build folder that I would like to just deploy, but I can't understand how to do that locally. Why do I need to do that locally -- I have .json file that is .gitignored and should not go into git repo, so running build command from GitHub repo won't work in my case. What I tried: I tried linking project, service with railway link, then running railway up that seems to run build script, which is great, but then it can't finish build as it can't locate gitignored files. Maybe there would be a flag to include gitignored files into building scope?
5.762 ERROR in unable to locate '/app/config/chatgpt-presets.local.json' glob
5.762 ERROR in unable to locate '/app/config/chatgpt-presets.local.json' glob
And I'm trying to copy that file into /build folder via webpack script:
new CopyPlugin({
patterns: [
{from: path.join('config', 'chatgpt-presets.local.json')},
new CopyPlugin({
patterns: [
{from: path.join('config', 'chatgpt-presets.local.json')},
Solution:
I have removed .gitignore, have run railway up, so it succesfully built, deployed my app to remote and now I can revert removal with 2 clicks.
Jump to solution
25 Replies
Percy
Percy11mo ago
Project ID: N/A
Tockus
TockusOP11mo ago
N/A
Brody
Brody11mo ago
if your code needs these files, why are you gitignore'ing them?
Tockus
TockusOP11mo ago
@Brody So I have a couple of files:
chatgpt-presets.local.json // not ignored
chatgpt-presets.default.json // ignored
chatgpt-presets.local.json // not ignored
chatgpt-presets.default.json // ignored
chatgpt-presets.default.json is file with default strings I use to prompt ChatGPT. Basically usecase for that file is to be used by other devs when they are trying out my application. chatgpt-presets.local.json is "production" file that I put personalized prompts inside. I don't want to share these on web with anyone, this file is for local development only and it happens that I want to deploy build with using that file instead default one. basically same principle as with .env, .env.default, .env.dev files is there a way I can just scoop everything from /build and deploy it to remote via CLI? or is there a way I can provide that file to deployment via website interface? I haven't seen such an option, only env variables can be set, but that's it
Brody
Brody11mo ago
can you cd into the build folder locally and then link to that folder, then railway up from that folder?
Tockus
TockusOP11mo ago
doesn't look like, that is what I've got:
PS C:\Users\user\Stash\git\shizo-bot> cd build
PS C:\Users\user\Stash\git\shizo-bot\build> railway link
> Select a project unhealthy-plough
> Select an environment production
> Select a service cli deploys
PS C:\Users\user\Stash\git\shizo-bot\build> railway up
Indexed Compressed [====================] 100%
Uploaded
Build Logs:
[Region: us-west1]
==============
Using Nixpacks
==============
context: 589e11df9e77597373d50c82d4b491f0
Nixpacks build failed

Nixpacks was unable to generate a build plan for this app.
Please check the documentation for supported languages: https://nixpacks.com

The contents of the app directory are:

bundle.js
.env.local
chatgpt-presets.local.json
node_modules_formdata-node_lib_esm_fileFromPath_js.bundle.js

Build failed
PS C:\Users\user\Stash\git\shizo-bot\build>
PS C:\Users\user\Stash\git\shizo-bot> cd build
PS C:\Users\user\Stash\git\shizo-bot\build> railway link
> Select a project unhealthy-plough
> Select an environment production
> Select a service cli deploys
PS C:\Users\user\Stash\git\shizo-bot\build> railway up
Indexed Compressed [====================] 100%
Uploaded
Build Logs:
[Region: us-west1]
==============
Using Nixpacks
==============
context: 589e11df9e77597373d50c82d4b491f0
Nixpacks build failed

Nixpacks was unable to generate a build plan for this app.
Please check the documentation for supported languages: https://nixpacks.com

The contents of the app directory are:

bundle.js
.env.local
chatgpt-presets.local.json
node_modules_formdata-node_lib_esm_fileFromPath_js.bundle.js

Build failed
PS C:\Users\user\Stash\git\shizo-bot\build>
Same thing on railway logs from website. But when I was creating service on website, I have selected "empty service", could that be a problem?
Brody
Brody11mo ago
ah yeah railway isn't knowing what to do with the contents of that folder maybe find another way to provide that json file to your app? like through S3 storage
Tockus
TockusOP11mo ago
Lmao that is out of scope of my competence. I've developed simple telegram bot in a couple of hours and don't want to go as far as spreading project files across multiple webservices :D I just hope to deploy it remotely so it won't be spinning on my local machine )
Brody
Brody11mo ago
you need another way to provide this file to your app that isn't through your project files, maybe a private gist or something
Tockus
TockusOP11mo ago
So there's no way of including gitignored files in build process? I guess I will try to remove gitignore just for railway up command
Brody
Brody11mo ago
nope that's what gitignore is there for
Tockus
TockusOP11mo ago
hell yeah, it works at least!
Solution
Tockus
Tockus11mo ago
I have removed .gitignore, have run railway up, so it succesfully built, deployed my app to remote and now I can revert removal with 2 clicks.
Tockus
TockusOP11mo ago
I guess if there's no other way to seed files into deployments yet, then that is one of few ways to make it work :)
Brody
Brody11mo ago
sounds good, happy you found a solution that worked for you
Tockus
TockusOP11mo ago
@Brody thank you too! and have a good evening
Brody
Brody11mo ago
you can put files onto a volume, but that's pretty convoluted tbh
Tockus
TockusOP11mo ago
hm I haven't seen how to do that
Brody
Brody11mo ago
does that json file ever change?
Tockus
TockusOP11mo ago
Sometimes it does, yes, when I edit prompts and such, so as often as code changes damn could you quickly remind me how to mark problem as resolved?
Brody
Brody11mo ago
then it isn't worth it to put it onto a volume since it's a hassle
Tockus
TockusOP11mo ago
thank you)
Brody
Brody11mo ago
users can't do that anymore, sorry no problem!
Tockus
TockusOP11mo ago
@Brody sorry for off-topic question, but do you know how to access deployed files as my bot writes some files and I would like to have access to them? Or is deployment basically unaccessible?
Brody
Brody11mo ago
basically, yes
Want results from more Discord servers?
Add your server