2 years ago
I have several projects on Railway and sometimes build are failing on some nix error.
please check an example project: 0a98cd14-9c35-4de8-9d8c-3019a3e82ac1
20 Replies
2 years ago
More projects that fail for the same reason:
3a2ba20a-8631-4be3-b633-be83af316cdb
02101ce5-058b-4ed7-b0d1-b5eeeb45e558
2 years ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
2 years ago
It didn't help, example project: fa3514e6-d775-4979-bf7e-efbbc92cba3e failed with the same error (While the others passed for some reason), with NIXPACKS_NO_CACHE=1
2 years ago
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2.30kB done
#1 DONE 0.0s
#2 [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1716249803
#2 DONE 0.1s
#3 [stage-0 1/8] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1716249803@sha256:5ef4d2021c418fcaabb56cea5ea9e24a5fdedfe27f58062d9689214dfed45c46
#3 DONE 0.0s
#4 [stage-0 2/8] WORKDIR /app/
#4 CACHED
#5 [internal] load .dockerignore
#5 transferring context: 2B done
#5 DONE 0.0s
#6 [internal] load build context
#6 transferring context: 1.87MB 0.0s done
#6 DONE 0.1s
#7 [ 3/10] COPY .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix
#7 DONE 0.1s
#8 [ 4/10] RUN nix-env -if .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix && nix-collect-garbage -d
#8 1.082 error:
#8 1.082 … while calling the 'import' builtin
#8 1.082 at /app/.nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix:3:12:
#8 1.082 2|
#8 1.082 3| let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf446f08bff6814b569265bef8374cfdd3d8f0e0.tar.gz";) { overlays = [ (import (builtins.fetchTarball "https://github.com/railwayapp/nix-npm-overlay/archive/main.tar.gz";)) ]; };
#8 1.082 | ^
#8 1.082 4| in with pkgs;
#8 1.082
#8 1.082 … while realising the context of a path
#8 1.082
#8 1.082 … while calling the 'fetchTarball' builtin
#8 1.082 at /app/.nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix:3:20:
#8 1.082 2|
#8 1.082 3| let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf446f08bff6814b569265bef8374cfdd3d8f0e0.tar.gz";) { overlays = [ (import (builtins.fetchTarball "https://github.com/railwayapp/nix-npm-overlay/archive/main.tar.gz";)) ]; };
#8 1.082 | ^
#8 1.082 4| in with pkgs;
#8 1.082
#8 1.082 error: Failed to open archive (truncated gzip input)
#8 ERROR: process "/bin/bash -ol pipefail -c nix-env -if .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix && nix-collect-garbage -d" did not complete successfully: exit code: 1
-----
> [ 4/10] RUN nix-env -if .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix && nix-collect-garbage -d:
1.082 … while realising the context of a path
1.082
1.082 … while calling the 'fetchTarball' builtin
1.082 at /app/.nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix:3:20:
1.082 2|
1.082 3| let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf446f08bff6814b569265bef8374cfdd3d8f0e0.tar.gz";) { overlays = [ (import (builtins.fetchTarball "https://github.com/railwayapp/nix-npm-overlay/archive/main.tar.gz";)) ]; };
1.082 | ^
1.082 4| in with pkgs;
1.082
1.082 error: Failed to open archive (truncated gzip input)
-----
Dockerfile:8
-------------------
6 |
7 | COPY .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix
8 | >>> RUN nix-env -if .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix && nix-collect-garbage -d
9 |
10 |
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c nix-env -if .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix && nix-collect-garbage -d" did not complete successfully: exit code: 1
Error: Docker build failed
2 years ago
Please note that I'm building more than 30 projects at the same time, all pointing to the same repo.
Hope that it helps...
2 years ago
Fetching from GitHub in parallel 30 times is likely the issue here, I would personally recommend moving to a Dockerfile based build that doesn't use nix.
Status changed to Solved Railway • almost 2 years ago
2 years ago
ok, thanks
2 years ago
Please let me know how that endeavour goes or if you run into any issues with a Dockerfile build.
2 years ago
Can you point to documentation on this?
I'm not a Docker expert...
2 years ago
Dockerfiles wouldn't be anything Railway specific, all you need to do is have the Dockerfile in the root of your project and Railway will use it, so nearly any guide on writing a Dockerfile for your desired language should do just fine.
Definitely don't need to be a Docker expert, please don't confuse Docker with Dockerfiles, I've never used Docker but I've written many Dockerfiles.
2 years ago
ok, I've managed to move to docker that's based on nodejs.
But, I was wondering maybe there's even better solution for me, wdyt about this:
Instead of all 30+ projects doing the same docker build (It's 100% the same), I can base my production on a docker hub image that I create...
so, when I push a change to master docker hub builds a new image, and once this image is ready all the reailway projects build is triggered (somehow) and because they all based on my docker image, the build will be very fast (just copy really)
is there a way to do this? wdyt?
Thanks
2 years ago
I do agree that would be more ideal, but unfortunately Railway does not yet provide a native way to watch for when a new image is published.
I don't know anything about your project but maybe the true solution is to not run 30+ of the same thing at once? though I would imagine that would require you to re-architect your project from the ground up, care to share more about why you currently run 30+ of the same thing? maybe this could be a job for replicas where your app is built once and x amount of containers are ran.
2 years ago
I have an application that I uses nodejs + postgres + redis, this application is designed to run per customer. I don't want to share anything between customers, and each customer is isolated from the other customers.
Each application load the config from the database so each customer has their own configuration. the databases urls are provided via the environment variables
other than this the code is totally the same...
Currently I create a railway project for each customer, setup postgress and redis, set configuration on the database and run it.
So, when I push to master all the projects run their build (same build)
Do you have a different solution? I would love to hear it
2 years ago
Yeah I'll be brutally honest, that's not scalable and I don't think that's a good way to architect your project, I understand wanting to have have separate instances for each user but the negatives far outweigh the benefits in my opinion, I think you should switch to a multi-tenant architecture as it's going to be easier to scale and easier to maintain.
2 years ago
ok, let's say that I refactor my database to include tenant_id column, and redis keys to include the tenantId
As my server holds per-customer state/external connections, I still need a nodejs server per customer...
Is there a way for me to spin a nodejs service/container per customer, which will all point to the same image?
2 years ago
As mentioned, I think you should move to a multi-tenant application, one application, one database, one redis for all your users, I imagine this would be a substantial re-write, but it would likely be worth it in the end.
There is nothing stopping you from deploying your 30+ services from the same image, but as mentioned previously, Railway does not provide a native functionality to watch for changes to the image registry for a newly published image.
2 years ago
well, as this is simplest thing for me, I will keep like as it is.
I don't plan to have more customers any time soon.
Thanks