a year ago
My current project requires me to have Node, Python, and Ruby in the same environment. Node and Python and building and deploying without issue. However when I attempt to install Ruby, the build fails before it even gets to my build commands. From what I can tell it doesn't even get to the package installation process, it's simply unable to install Ruby. The output it very unhelpful, asking me to look at a log file I cannot access.
ERROR: failed to solve: process "/bin/bash -ol pipefail -c curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash -s stable && printf '\neval \"$(~/.rbenv/bin/rbenv init -)\"' >> /root/.profile && . /root/.profile && rbenv install 3.2.2 && rbenv global 3.2.2 && gem install bundler:2.2.26" did not complete successfully: exit code: 1
ⓘ Deployment information is only viewable by Project members and Railway admins.
24 Replies
a year ago
Node. I have strapi (Node) server running, and I have it setup to call a webhook on a tiny Flask (Python) server, that executes a command to build with Jekyll (Ruby)
a year ago
Though it sounds like you need a service with just Node to run Strapi and another service with Python and Ruby, it does not sound like you need the 3 languages in a single container?
a year ago
This was the file Railway generated. I tried specifying Ruby previously to no avail, so in my latest attempt I had it automatically detect Ruby, but no luck.
[build]
builder = "NIXPACKS"
buildCommand = "cd strapi/troop-cms && npm install && NODE_ENV=production npm run strapi build"
nixpacksPlan = {"providers":["node","python","..."]}
[deploy]
numReplicas = 1
startCommand = "cd strapi/troop-cms && NODE_ENV=production npm start"
sleepApplication = true
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 10
a year ago
For the record, it's rarely a good idea to use cd
in build or start commands since there is likely a better way to do it, in this case, you would want to set the root directory setting in your service settings.
Please also answer my other message if you could.
a year ago
I did originally have my root directory inside troop-cms, however I changed it when I was trying to get Ruby working. If I specified the language Ruby it would break because troop-cms doesn't contain any Gemfiles. Maybe I could move them into that directory.
Two might work, but would it solve the issue of Nixpacks failing to install Ruby? Based on the logs installing ruby is the first thing it tried, and fails to do. I also would like to avoid an additional service, as that might cost me a bit more? I'm not sure how much overhead that creates.
a year ago
An additional service would not add much overhead, and whatever overhead it does add would be inconsequential because it would mean you are doing it the correct way as opposed to throwing everything inside the same container.
Starting from the root directory, what do you run to start the flask server?
a year ago
I start the Flask server process from Node, when Strapi starts. Also probably not the best idea but it does work for now.
const pythonProcess = spawn('python', ["../../webhook/server.py"]);
a year ago
Sorry, I actually lied about the Flask server stuff, I'm using the python stdlib modules to create the HTTP server, so I don't have to install any python packages.
a year ago
Here is more log information:
> [stage-0 8/18] RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash -s stable && printf '\neval "$(~/.rbenv/bin/rbenv init -)"' >> /root/.profile && . /root/.profile && rbenv install 3.2.2 && rbenv global 3.2.2 && gem install bundler:2.2.26:
2.310 ==> Downloading openssl-3.1.5.tar.gz...
2.444 -> curl -q -fL -o openssl-3.1.5.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262
100 14.9M 100 14.9M 0 0 86.9M 0 --:--:-- --:--:-- --:--:-- 86.8M
3.378 ==> Installing openssl-3.1.5...
3.398 -> ./config "--prefix=$HOME/.rbenv/versions/3.2.2/openssl" "--openssldir=$HOME/.rbenv/versions/3.2.2/openssl/ssl" zlib-dynamic no-ssl3 shared
16.89 -> make -j 32
(Ubuntu 22.04 on x86_64 using ruby-build 20240501)
20.76
20.77 You can inspect the build directory at /tmp/ruby-build.20240510140517.145.D3hW8t
20.77 See the full build log at /tmp/ruby-build.20240510140517.145.log
-----
Dockerfile:21
-------------------
19 | # ruby:setup phase
20 | ENV NIXPACKS_PATH $HOME/.rbenv/bin:$NIXPACKS_PATH
21 | >>> RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash -s stable && printf '\neval "$(~/.rbenv/bin/rbenv init -)"' >> /root/.profile && . /root/.profile && rbenv install 3.2.2 && rbenv global 3.2.2 && gem install bundler:2.2.26
22 |
23 | # setup phase
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash -s stable && printf '\\neval \"$(~/.rbenv/bin/rbenv init -)\"' >> /root/.profile && . /root/.profile && rbenv install 3.2.2 && rbenv global 3.2.2 && gem install bundler:2.2.26" did not complete successfully: exit code: 1
Error: Docker build failed
a year ago
First let's try getting just the python server running in another service, because I assume getting Strapi running will be easy enough.
If you could share your repo with me that would be a tremendous help and would significantly lessen the back and forth.
a year ago
Sure thing, I'll try separating the two then.
a year ago
Yeah please work to give this repo more of a monorepo structure, right now it's a bit chaotic and in its current state would be very challenging to deploy properly to Railway.
a year ago
Ok, so I created https://github.com/Zwork101/troop-builder for the Python HTTP server with Jekyll, and made troop-webiste only contain the Strapi server. In the process I've been able to identify the problem. If I only specify Ruby as a provider, it's able to build (but python doesn't exist in the deployment, so the deployment fails). However if I add Python as a provider, Ruby fails to install.
a year ago
Here is the config of the troop-builder portion
[build]
builder = "NIXPACKS"
nixpacksPlan = {"providers":["...","python"]}
[deploy]
numReplicas = 1
startCommand = "python main.py"
sleepApplication = false
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 10
a year ago
Okay thanks, I'll try some config things to get that repo deploying, and I'll get back to you!
a year ago
Add this railway.json file to your project -
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "ruby"]
},
"install": {
"cmds": ["bundle install"]
}
}
}
},
"deploy": {
"startCommand": "python main.py"
}
}
You will also need to create a builds
folder in the project with a single .gitkeep
file in it, then remove line 9 of your .gitignore
file and replace it with -
builds/**
!builds/.gitkeep
This will keep just the bare folder intact while not committing any build content.
With these changes I have your repo working here - https://troop-builder-fork-production.up.railway.app
As I have noticed this sends a plaintext response of the location to the log file, you will need to have this response be the rendered template page, and then you will need to have Strapi load the template from the response instead of off-disk.
a year ago
Add this railway.json file to your project -
{ "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS", "nixpacksPlan": { "providers": ["python"], "phases": { "setup": { "nixPkgs": ["...", "ruby"] }, "install": { "cmds": ["bundle install"] } } } }, "deploy": { "startCommand": "python main.py" } }
You will also need to create a
builds
folder in the project with a single.gitkeep
file in it, then remove line 9 of your.gitignore
file and replace it with -builds/** !builds/.gitkeep
This will keep just the bare folder intact while not committing any build content.
With these changes I have your repo working here - https://troop-builder-fork-production.up.railway.app
As I have noticed this sends a plaintext response of the location to the log file, you will need to have this response be the rendered template page, and then you will need to have Strapi load the template from the response instead of off-disk.
This works! Thanks a bunch! Yeah it has some more work to do. I have a s3 bucket connected to cloudfront running a static site, and it seemed to me like railway would be much cheaper to run Strapi on than AWS, so now I need to install the AWS cli and update the S3 bucket after the website is built.
I am having trouble when it comes to getting the two services to interact, but that's a separate issue. If I use the internal URLs, they should be able to communicate, right?
a year ago
Ah, wasn't using IPv6. All good now!
a year ago
I would not recommend uploading files to a 3rd party host just to download them, that would be slow, prone to errors, and it would subject yourself to egress fees, instead try my proposed solution.
a year ago
I'll keep an eye on price, but from what I can tell with egress fees this is still the best option, as I don't expect to use strapi very often at all, maybe once a month, and it's not a huge amount of data. Strapi isn't a web server in the sense that Apache or Nginx is, it's a headless CMS. My current plan is to use AWS Cloudfront to serve the static files, and then when myself or someone else wishes to modify the static website, they can login to Strapi, change the values, rebuild the website, and then the new site is put in the S3 bucket Cloudfront looks at. This is for sure a bit more complex than having everything on one platform, but Cloudfront + S3 + Route 53 costs next to nothing, and Railway putting Strapi to sleep when not in use (which will be more often than not) is the most cost effective for running Strapi.
a year ago
Okay I see what you have going on, I was thinking something else, that does seem like a pretty good solution to static hosting!