#"Quickstart" example

1 messages · Page 1 of 1 (latest)

stray pelican
#

Can anyone confirm, that the example in https://docs.dagger.io/quickstart/daggerize is working? I'm trying to get my feet wet here. This is on WSL.
dagger v0.12.4 (registry.dagger.io/engine:v0.12.4) linux/amd64

  ✔ Container.withExec(args: ["npm", "run", "test:unit", "run"]): Container! 0.4s
  ✘ Container.stdout: String! 0.4s
  ! process "npm install" did not complete successfully: exit code: 254

Error: response from query: input: helloDagger.publish resolve: call function "Publish": process "/runtime" did not complete successfully: exit code: 2

Stdout:
invoke: input: container.from.withDirectory.withMountedCache.withWorkdir.withExec.withExec.stdout resolve: process "npm install" did not complete successfully: exit code: 254

Stderr:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /src/package.json
npm ERR! errno -2
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/src/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-08-10T14_25_16_394Z-debug-0.log

RIGEL hello-dagger/dagger   main ?  cat /root/.npm/_logs/2024-08-10T14_25_16_394Z-debug-0.log
[bat error]: '/root/.npm/_logs/2024-08-10T14_25_16_394Z-debug-0.log': No such file or directory (os error 2)

Daggerize an example application

lament dome
#

@stray pelican I think I know what the error is. Seems like you're running the instructed dagger call publish --source=. inside the dagger folder. You should be standing in the hello-dagger folder when running that command

#

just tried it out works ok

stray pelican
#

I'm using go sdk. Here's what I get when I run dagger call publish --source=. from hello-dagger/

 hello-dagger   main ?  dagger call publish --source=.
Full trace at https://dagger.cloud/n8himmel/traces/d5b8e3df467996e6402fae5265b13765

✔ connect 0.8s
✔ initialize 2.9s
✔ prepare 0.1s
✔ helloDagger: HelloDagger! 0.0s
✘ HelloDagger.publish(
    source: ✔ ModuleSource.resolveDirectoryFromCaller(path: "."): Directory! 0.0s
  ): String! 5.5s
! call function "Publish": process "/runtime" did not complete successfully: exit code: 2
┃ invoke: input: container.from.withDirectory.withMountedCache.withWorkdir.withExec.withExec.directory resolve: process "npm run build" did not complete successfully: exit code: 127
┃
┃ Stdout:
┃ > hello-dagger@0.0.0 build
┃ > run-p type-check "build-only {@}" --
┃ Stderr:
┃ sh: 1: run-p: Permission denied
  ✔ Container.from(address: "node:21-slim"): Container! 1.1s
  ✔ Container.withExec(args: ["npm", "install"]): Container! 2.0s
  ✔ Container.withExec(args: ["npm", "run", "test:unit", "run"]): Container! 3.9s
  ✔ Container.stdout: String! 3.9s
  ✘ Container.withExec(args: ["npm", "run", "build"]): Container! 0.2s
    ✘ exec npm run build 0.2s
    ! process "npm run build" did not complete successfully: exit code: 127
    ┃
    ┃ > hello-dagger@0.0.0 build
    ┃ > run-p type-check "build-only {@}" --
    ┃
    ┃ sh: 1: run-p: Permission denied
  ✘ Container.directory(path: "./dist"): Directory! 0.2s
  ! process "npm run build" did not complete successfully: exit code: 127

Error: response from query: input: helloDagger.publish resolve: call function "Publish": process "/runtime" did not complete successfully: exit code: 2

Stdout:
invoke: input: container.from.withDirectory.withMountedCache.withWorkdir.withExec.withExec.directory resolve: process "npm run build" did not complete successfully: exit code: 127

Stdout:
> hello-dagger@0.0.0 build
> run-p type-check "build-only {@}" --
Stderr:
sh: 1: run-p: Permission denied
#

using .Terminal() before npm run build I found out that there is no run-p
So I installed npm-run-all and was then able to execute npm run build inside the build container.
Any idea what's wrong?

dagger /src $ npm install --save-dev npm-run-all
dagger /src $ npm run build

> hello-dagger@0.0.0 build
> run-p type-check "build-only {@}" --
…
✓ 47 modules transformed.
…
✓ built in 628ms
stray pelican
stray pelican
lament dome
#

this is what I get in linux

  ✔ Container.withExec(args: ["npm", "run", "build"]): Container! 3.3s                                                                                                    (1 results) [123/660]
    ✔ exec npm run build 3.3s
    ┃                                          
    ┃ > hello-dagger@0.0.0 build               
    ┃ > run-p type-check "build-only {@}" --   
    ┃                                                                                                                                                                                          
    ┃                                                                                          
    ┃ > hello-dagger@0.0.0 type-check                                                          
    ┃ > vue-tsc --build --force                                                                
    ┃                                                                                          
    ┃                                                                                          
    ┃ > hello-dagger@0.0.0 build-only          
    ┃ > vite build                             
    ┃                                          
    ┃ vite v5.2.11 building for production...  
    ┃ transforming...                          
    ┃ ✓ 47 modules transformed.                
    ┃ rendering chunks...                      
    ┃ computing gzip size...                   
    ┃ dist/index.html                      0.43 kB │ gzip:  0.29 kB                            
    ┃ dist/assets/AboutView-C6Dx7pxG.css   0.09 kB │ gzip:  0.10 kB                            
    ┃ dist/assets/index-EQp8QQYV.css       4.19 kB │ gzip:  1.29 kB                            
    ┃ dist/assets/AboutView-sifBMe-B.js    0.22 kB │ gzip:  0.20 kB                            
    ┃ dist/assets/index-CRSeOu3K.js       88.24 kB │ gzip: 34.88 kB  
#

@stray pelican what happens if you do this?

  1. add Terminal after npm run build in your pipeline like:
    build := m.BuildEnv(source).
        WithExec([]string{"npm", "run", "build"}).
        Terminal().
        Directory("./dist")

after calling dagger call again and being dropped into a shell, what do you get if you run npx run-p?