nanovms / ops

ops - build and run nanos unikernels
https://ops.city
MIT License
1.27k stars 132 forks source link

Cannot seem to push locally built package #1594

Closed radiosilence closed 6 months ago

radiosilence commented 6 months ago

To make it simpler here's a Makefile that should in theory compile/build out my package, add it to ops, and then push it:

PKGNAME=nano-web
PKGVERSION=0.1.0
PKGRELEASE=$(PKGNAME)_$(PKGVERSION)
RELEASEDIR=./release
PKGDIR=$(RELEASEDIR)/$(PKGRELEASE)

pkg-clean:
    rm -rf $(RELEASEDIR)

pkg-build:
     GOOS=linux go build -o $(PKGDIR)/$(PKGNAME) main.go

pkg-create: pkg-clean
    mkdir -p $(PKGDIR)/sysroot
    mkdir -p $(PKGDIR)/sysroot/public
    ./scripts/make-manifest.sh > $(PKGDIR)/package.manifest
    cp README.md $(PKGDIR)

pkg-add: pkg-create pkg-build
    ops pkg add $(PKGDIR) --name $(PKGRELEASE)

pkg-bundle: pkg-add
    cd $(RELEASEDIR); tar czvf $(PKGRELEASE).tar.gz $(PKGRELEASE)
    @echo "Release created: $(PKGDIR).tar.gz"

pkg-push: pkg-add
    ops pkg push $(PKGRELEASE)

pkg-load: pkg-add
    ops pkg load -l $(PKGRELEASE) -p 80

When I run make pkg-push I get this output:

make pkg-push   
rm -rf ./release
mkdir -p ./release/nano-web_0.1.1/sysroot
mkdir -p ./release/nano-web_0.1.1/sysroot/public
./scripts/make-manifest.sh > ./release/nano-web_0.1.1/package.manifest
cp README.md ./release/nano-web_0.1.1
GOOS=linux go build -o ./release/nano-web_0.1.1/nano-web main.go
ops pkg add ./release/nano-web_0.1.1 --name nano-web_0.1.1
nano-web_0.1.1
ops pkg push nano-web_0.1.1
no local package with the name nano-web_0.1.1 found

Have I missed a step somehow? It is slightly unclear if I am doing something wrong with regards to the docs.

If I use ops pkg load -l it works as expected:

 ops pkg load -l nano-web_0.0.1
running local instance
booting /Users/jc/.ops/images/nano-web ...
en1: assigned 10.0.2.15
⇨ public directory not found in: /

Here's my repo, sorry I'm a bit new to this: https://github.com/radiosilence/nano-web

Also here's a GitHub Action failing: https://github.com/radiosilence/nano-web/actions/runs/8299691056/job/22715977688

eyberg commented 6 months ago

so i took a look at your manifest shell script and at least for me I needed to set the PKGVERSION like so:

index 0b2131e..f2aa8c9 100755
--- a/scripts/make-manifest.sh
+++ b/scripts/make-manifest.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 PKGNAME="nano-web"
+PKGVERSION=$(./scripts/get-version.sh)

the Version wasn't getting put into the package.manifest w/out:

➜  nano-web git:(main) ✗ cat release/nano-web_0.1.2-1/package.manifest
{
   "Program":"nano-web_0.1.2-1/nano-web",
   "Args" : ["nano-web"],
   "Version":"0.1.2-1"
}
eyberg commented 6 months ago

also, fyi - there is a cmd 'ops pkg from-run g --name nano-web --version 0.1.1 -c config.json' that would remove a lot of these manual steps

radiosilence commented 6 months ago

The PKGVERSION was indeed getting set from my shell's env, so I've modified my makefile to set it explicitly now!

However this issue was caused by a bug in the regex due to the dash in the package name! See PR :)

Updated Makefile

PKGNAME=nano-web
PKGVERSION:=$(shell ./scripts/get-version.sh)
PKGRELEASE=$(PKGNAME)_$(PKGVERSION)
RELEASEDIR=./release
PKGDIR=$(RELEASEDIR)/$(PKGRELEASE)

pkg-clean:
    rm -rf $(RELEASEDIR)

pkg-build:
     GOOS=linux go build -o $(PKGDIR)/$(PKGNAME) main.go

pkg-create: pkg-clean
    mkdir -p $(PKGDIR)/sysroot
    mkdir -p $(PKGDIR)/sysroot/public
    PKGVERSION=$(PKGVERSION) PKGNAME=$(PKGNAME) ./scripts/make-manifest.sh > $(PKGDIR)/package.manifest
    cp README.md $(PKGDIR)

pkg-add: pkg-create pkg-build
    ops pkg add $(PKGDIR) --name $(PKGRELEASE)

pkg-bundle: pkg-add
    cd $(RELEASEDIR); tar czvf $(PKGRELEASE).tar.gz $(PKGRELEASE)
    @echo "Release created: $(PKGDIR).tar.gz"

pkg-push: pkg-add
    ops pkg push $(PKGRELEASE)

pkg-load: pkg-add
    ops pkg load -l $(PKGRELEASE) -p 80