Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem building a nixpack under gitpod #82

Closed
anuaimi opened this issue May 7, 2022 · 10 comments
Closed

problem building a nixpack under gitpod #82

anuaimi opened this issue May 7, 2022 · 10 comments

Comments

@anuaimi
Copy link

anuaimi commented May 7, 2022

I am using gitpod as my dev environment as I learn about nixpacks. I can build the binary without any problem but I can't build a nitpack for the example node project. I'm not very familiar with rust so not really clear what the error message is indicating.

Note, I am able to build locally on my Mac so its something to do with the gitpod environment. It looks like it fails doing a npm ci at the end of the docker build. My Mac has node 17 while gitpod is 16. Not sure if that's important.

To reproduce the issue, create a gitpod workspace using https://gitpod.io/# + the GitHub repo URL. Then from the terminal run cargo run -- build examples/node --name node

Here is the output.

cargo run -- build examples/node --name node
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/nixpacks build examples/node --name node`
=== Building (nixpacks v0.0.8) ===
=> Generated new build plan
=> Packages
    -> nodejs
=> Install
    -> npm ci
=> Build
    -> Skipping
=> Start
    -> npm run start
=> Building image with Docker
Sending build context to Docker daemon  7.168kB
Step 1/15 : FROM debian:bullseye-slim
 ---> bfbec70f8488
Step 2/15 : RUN apt-get update && apt-get -y upgrade   && apt-get install --no-install-recommends -y locales curl xz-utils ca-certificates openssl   && apt-get clean && rm -rf /var/lib/apt/lists/*   && mkdir -m 0755 /nix && mkdir -m 0755 /etc/nix && groupadd -r nixbld && chown root /nix   && echo 'sandbox = false' > /etc/nix/nix.conf   && for n in $(seq 1 10); do useradd -c "Nix build user $n" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(command -v nologin)" "nixbld$n"; done
 ---> Using cache
 ---> 6b66b20f974c
Step 3/15 : SHELL ["/bin/bash", "-o", "pipefail", "-c"]
 ---> Using cache
 ---> c550359f3833
Step 4/15 : RUN set -o pipefail && curl -L https://nixos.org/nix/install | bash     && /nix/var/nix/profiles/default/bin/nix-collect-garbage --delete-old
 ---> Using cache
 ---> 8cd081977e35
Step 5/15 : ENV   ENV=/etc/profile   USER=root   PATH=/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/bin:/sbin:/usr/bin:/usr/sbin   GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt   NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt   NIX_PATH=/nix/var/nix/profiles/per-user/root/channels
 ---> Using cache
 ---> 7e8e1d37c7e4
Step 6/15 : RUN nix-channel --update
 ---> Using cache
 ---> 9fcce4c4d9bd
Step 7/15 : RUN mkdir /app/
 ---> Using cache
 ---> da6c338bda53
Step 8/15 : WORKDIR /app/
 ---> Using cache
 ---> ddab151a4376
Step 9/15 : COPY environment.nix /app/
 ---> Using cache
 ---> d4e0409d43c1
Step 10/15 : RUN nix-env -if environment.nix
 ---> Using cache
 ---> 361901493d55
Step 11/15 : ARG NPM_CONFIG_PRODUCTION NODE_ENV
 ---> Running in 2ac92b375b9b
Removing intermediate container 2ac92b375b9b
 ---> f97b63c6066e
Step 12/15 : ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION NODE_ENV=$NODE_ENV
 ---> Running in 651966ee5147
Removing intermediate container 651966ee5147
 ---> 518edade8cc9
Step 13/15 : COPY . /app/
 ---> 8205e15c5e95
Step 14/15 : RUN npm ci
 ---> Running in d1a655c5b9f7
/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node[1]: ../src/node_platform.cc:61:std::unique_ptr<long unsigned int> node::WorkerThreadsTaskRunner::DelayedTaskScheduler::Start(): Assertion `(0) == (uv_thread_create(t.get(), start_thread, this))' failed.
 1: 0xa66fa8 node::Abort() [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 2: 0xa67037  [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 3: 0xae82a5 node::WorkerThreadsTaskRunner::WorkerThreadsTaskRunner(int) [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 4: 0xae83d2 node::NodePlatform::NodePlatform(int, v8::TracingController*) [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 5: 0xa270ff node::V8Platform::Initialize(int) [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 6: 0xa2541b node::InitializeOncePerProcess(int, char**, node::InitializationSettingsFlags, node::ProcessFlags::Flags) [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 7: 0xa255a9 node::InitializeOncePerProcess(int, char**) [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 8: 0xa25608 node::Start(int, char**) [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
 9: 0x7f6b1de611d7  [/nix/store/m4g6lswi75b739cpdx8wfxlfmcazyks9-glibc-2.34-115/lib/libc.so.6]
10: 0x7f6b1de61297 __libc_start_main [/nix/store/m4g6lswi75b739cpdx8wfxlfmcazyks9-glibc-2.34-115/lib/libc.so.6]
11: 0x98be61 _start [/nix/store/7fy3g0bbiww61k7imi4bayfnjxmbs3cj-nodejs-16.15.0/bin/node]
The command '/bin/bash -o pipefail -c npm ci' returned a non-zero code: 139
Error: Docker build failed
@anuaimi anuaimi changed the title problem building a nitpick under gitpod problem building a nixpack under gitpod May 7, 2022
@Milo123459
Copy link
Collaborator

Do you have a lockfile? If not, please generate one with npm i.

@anuaimi
Copy link
Author

anuaimi commented May 7, 2022

doesn't the example node project already have a lockfile. also, this command worked when run on my Mac.

@anuaimi
Copy link
Author

anuaimi commented May 7, 2022

this is what the example project has

gitpod /workspace/nixpacks (main) $ ls examples/node
index.js  package.json  package-lock.json

@aleksrutins
Copy link
Contributor

Assertion `(0) == (uv_thread_create(t.get(), start_thread, this))' failed.

Looks like there was trouble starting a thread in V8. I don't know why that would be, though, unless Gitpod has a limit on running threads (?), which I can't find mention of in their pricing.

@ghost
Copy link

ghost commented May 7, 2022

Looks like there was trouble starting a thread in V8. I don't know why that would be, though, unless Gitpod has a limit on running threads (?), which I can't find mention of in their pricing.

Building the generated Dockerfile fails too.

Generated Dockerfile for node-main-file example
FROM debian:bullseye-slim

RUN apt-get update && apt-get -y upgrade \
  && apt-get install --no-install-recommends -y locales curl xz-utils ca-certificates openssl \
  && apt-get clean && rm -rf /var/lib/apt/lists/* \
  && mkdir -m 0755 /nix && mkdir -m 0755 /etc/nix && groupadd -r nixbld && chown root /nix \
  && echo 'sandbox = false' > /etc/nix/nix.conf \
  && for n in $(seq 1 10); do useradd -c "Nix build user $n" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(command -v nologin)" "nixbld$n"; done

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN set -o pipefail && curl -L https://nixos.org/nix/install | bash \
    && /nix/var/nix/profiles/default/bin/nix-collect-garbage --delete-old

ENV \
  ENV=/etc/profile \
  USER=root \
  PATH=/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/bin:/sbin:/usr/bin:/usr/sbin \
  GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt \
  NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
  NIX_PATH=/nix/var/nix/profiles/per-user/root/channels

RUN nix-channel --update

RUN mkdir /app/
WORKDIR /app/

# Setup
COPY environment.nix /app/
RUN nix-env -if environment.nix

# Load environment variables
ARG NPM_CONFIG_PRODUCTION NODE_ENV
ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION NODE_ENV=$NODE_ENV

# Install
COPY . /app/
RUN npm install


# Build



# Start

CMD node src/index.js
ulimit logs for Container(Layer 13)
time(seconds)        unlimited
file(blocks)         unlimited
data(kbytes)         unlimited
stack(kbytes)        8192
coredump(blocks)     unlimited
memory(kbytes)       unlimited
locked memory(kbytes) 8192
process              unlimited
nofiles              1048576
vmemory(kbytes)      unlimited
locks                unlimited
rtprio               0
ulimit logs for Gitpod
tcore file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256966
max locked memory       (kbytes, -l) 8192
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1048576
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

@ghost
Copy link

ghost commented May 7, 2022

Related NixOS/nixpkgs#170279

@anuaimi
Copy link
Author

anuaimi commented May 9, 2022

I think @wyzlle is on the right track. If I have a standard Dockerfile, I can build the image in gitpod. But the one that nixpacks generates using nix for packaging fails. Also, I tried the go and python examples and they also fail under gitpod.

@anuaimi
Copy link
Author

anuaimi commented May 12, 2022

Anyone had a chance to look at this? I have worked with gitpod and they believe it has to do with the way that nix is installed. One thing I noticed is that nix is installed as root. The docs recommend not to do this.

@JakeCooper
Copy link
Contributor

Anyone had a chance to look at this? I have worked with gitpod and they believe it has to do with the way that nix is installed. One thing I noticed is that nix is installed as root. The docs recommend not to do this.

If you can reproduce that using nix via root causes this, and using it via not root fixes it, we'd be happy to fix that

Beyond that, we're a bit limited on bandwidth ATM but you're welcome to take a crack at it yourself, or have one of the Gitpod people do jump into it

@coffee-cup
Copy link
Contributor

Closing for inactivity. We do also have a devcontainer setup in the Nixpacks repo that a few users use https://github.com/railwayapp/nixpacks/tree/main/.devcontainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants