metaparticle-io / package

Metaparticle/Package: Language Fluent Containerization and Deployment in Java, .NET and Javascript (and more coming soon)
https://metaparticle.io
MIT License
493 stars 55 forks source link

The Golang Tutorial doesn't work #104

Open TsuyoshiUshio opened 6 years ago

TsuyoshiUshio commented 6 years ago

I try the Golang tutorial to learn the Metaparticle. However, it doesn't work. I can fix several issues however, I can't solve an error. I can run through the tutorial, I'd happy to send a pull request for the doc.

1. There is no sample under tutorial/go

It is on the tutorial web page. so no problem.

2. go get fails

go get https://github.com/metaparticle-io/package/go/metaparticle

fails. It is the same error as this issue.

https://github.com/metaparticle-io/package/issues/62

We can solve the same solution (install dep and solve the dependency)

3. The second sample didn't work.

This sample cause an error now, metaparticle.Containerize need &metaparticle.Runtime to run it. To solve this, just add Runtime. It is added the next sample.

func main() {
    metaparticle.Containerize(
        &metaparticle.Package{
            Name:       "metaparticle-web-demo",
            Repository: "your-docker-user-goes-here",
            Builder:    "docker",
            Verbose:    true,
            Publish:    true,
        },
        func() {
            log.Println("Starting server on :8080")
            http.HandleFunc("/", handler)
            err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
            if err != nil {
                log.Fatal("Couldn't start the server: ", err)
            }
        })
}

4. repository name must be canonical error

When I tried

go run main.go

It cause this error. metaparticle already has created the same image, when I try docker push tsuyoshiushio/mdemo by myself, it works.

Successfully built 92f2ff7c4e5d
Successfully tagged tsuyoshiushio/mdemo:latest
panic: Could not push image "tsuyoshiushio/mdemo" to the repository: Error sending push request to docker: repository name must be canonical

goroutine 1 [running]:
github.com/metaparticle-io/package/go/metaparticle.Containerize(0xc4201346c0, 0xc4205a90c0, 0x144d350)
    /Users/ushio/Codes/metaparticle/experiment/src/github.com/metaparticle-io/package/go/metaparticle/metaparticle.go:161 +0x651
main.main()
    /Users/ushio/Codes/metaparticle/experiment/src/github.com/TsuyoshiUshio/MetaparticleSpike/main.go:21 +0x146
exit status 2

This error might be related this issue.

ImagePull in golang client v17.03.1-ce fails with 'repository name must be canonical' #32372

The guy is just down grade docker package, however, I guess it is not proper way to solve this error. Any ideas?

ahmedalhulaibi commented 6 years ago

I had all the same issues and I hit the same roadblock. I set Publish to false in the metaparticle.Package to at least run locally automatically.

running docker push manually also worked for me so still need a fix on the docker push

&metaparticle.Package{
            Name:       "metaparticle-web-demo",
            Repository: "your-docker-user-goes-here",
            Builder:    "docker",
            Verbose:    true,
            Publish:    false,
        },