#running an angular build via Dagger GO SDK

1 messages · Page 1 of 1 (latest)

livid sky
#

Could use some help as I'm running into a few issues with setting up Dagger + Go SDK to invoke an angular build.
I'm a little crunched on time so can't go to far down the rabbit hole, so maybe a little help can get me over the few issues I'm running into?

First issue:

node := client.Container().From("alpine:latest"). // Trimmed down to almost 6m vs node images at several hundred mb
                                WithExec([]string{"apk", "add", "--update", "nodejs", "npm"})

Works great. Now I move on to running the setup commands and get errors with no details on why.

const AngularVersion = "13"
node = node.WithMountedDirectory(".", src).
WithWorkdir("/src")
path := "dist/"
 node = node.WithExec([]string{"npm", "install", "-g", "@angular/cli"}) // fmt.Sprintf("@angular/cli@%s", AngularVersion)}).
    node = node.WithExec([]string{"npm", "install", "--ci"})
    output := node.Directory(path)

I get issues with both the npm install globally and the ci (which i expect as I need to figure out private authentication stuff).

That said, this is all I get for the npm global install.

#2 ERROR: process "npm install -g @angular/cli" did not complete successfully: exit code: 1
Error: input:1: container.from.withExec.withMountedDirectory.withWorkdir.withExec.withExec.directory process "npm install -g @angular/cli" did not complete successfully: exit code: 1

I can run docker run --rm -it alpine:latest /bin/sh and run this stuff manually without an error.

#

cc @noble swallow too as I'm running via Mage and might be of interest.

shy inlet
#

@noble swallow Should I take a look?

noble swallow
shy inlet
#

I get this output

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 15.1.3
Node: 19.5.0 (Unsupported)
Package Manager: npm 9.3.1
OS: linux arm64

Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1501.3 (cli-only)
@angular-devkit/core         15.1.3 (cli-only)
@angular-devkit/schematics   15.1.3 (cli-only)
@schematics/angular          15.1.3 (cli-only)
#

Also, I've heard of/used npm ci before, but not npm install --ci

#

likely similar/same? not sure

#

looks like you need diff version of Angular, though. 13. Not sure if things have changed. I see docs about an ng --version command. I'm using ng v to get version info.

noble swallow
#

Had a quick second to look at this. I'm guessing what's happening is that the global path where the angular cli is installed isn't in the path. Maybe it would work with node.WithExec([]string{"sh", "-c", "npm install --ci"}). Worth a shot!

livid sky
#

👀 will look. thank you so much much appreciate the guidance and examples

shy inlet
#

Just pushed a slight tweak

#

Might want to make sure that your node version and angular versions are compatible. With node:latestimage and @angular/cli@13 I got this:

#7 0.437
#7 0.437      _                      _                 ____ _     ___
#7 0.437     / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
#7 0.437    / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
#7 0.437   / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
#7 0.437  /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
#7 0.437                 |___/
#7 0.437
#7 0.932
#7 0.932 Angular CLI: 13.3.10
#7 0.932 Node: 19.5.0 (Unsupported)
#7 0.932 Package Manager: npm 9.3.1
#7 0.932 OS: linux arm64
#7 0.932
#7 0.932 Angular: undefined
#7 0.932 ...
#7 0.932
#7 0.932 Package                      Version
#7 0.932 ------------------------------------------------------
#7 0.932 @angular-devkit/architect    0.1303.10 (cli-only)
#7 0.932 @angular-devkit/core         13.3.10 (cli-only)
#7 0.932 @angular-devkit/schematics   13.3.10 (cli-only)
#7 0.932 @schematics/angular          13.3.10 (cli-only)
#7 0.932
#7 0.932 Warning: The current version of Node (19.5.0) is not supported by Angular.
#

note last line

#

Could be big difference between you using alpine as your container image to run this pipeline versus node image

livid sky
#

A big part I think was incorrectly mapping WithMountedDirectory(".", dir) instead of /src. So far making more progress. Looking at your example which really helped.

livid sky
#

Now when I'm running the build to package i docker, I can't generate a local image. Am I still supposed to export a tarball and then use dockerload?

I'm used to goreleaser publishing outside of docker where I run dev.local/myimage:latest etc.
I found the example of dagger engine, but it's a bit more complex than I need, so just making sure nothing's changed since then.

#

I ran docker run -d -p 5000:5000 --restart=always --name registry registry:2 and tried to push to this with image of DockerImageName = "0.0.0.1:5100/nginx-nonroot:latest" and no go so far. Working on it but welcome confirmation

noble swallow