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

dockerized version #6

Open
roscopecoltran opened this issue Sep 25, 2018 · 21 comments
Open

dockerized version #6

roscopecoltran opened this issue Sep 25, 2018 · 21 comments

Comments

@roscopecoltran
Copy link

Hi,

Hope you are all well !

I was trying play online for a couple of advanced tests (package analysis, ast/import, flogo plugins, ...) and they failed because of write permissions. So I tried to build "play" or "jsgo" locally but it since it can not find the "message" package...

Is there a dockerize version (alpine based) for play and jsgo ?
It would so convenient for users or devs :-)

Thanks for all this cool project !

Cheers,
Rosco

@dave
Copy link
Owner

dave commented Sep 26, 2018

I've been meaning to write some documentation for setting it up locally... a docker container would be a great idea. I'll see what I can do in the next few days.

@roscopecoltran
Copy link
Author

Here is a quick example for a multi-stage docker file based on alpine and gopherjs/vecty, if it can help yout to save some precious time ^^.

https://github.com/nobonobo/vecty-chatapp/blob/master/Dockerfile

@dave
Copy link
Owner

dave commented Sep 27, 2018

I made some instructions on how to get it running locally - can you run through them and see if there's any problems?

https://github.com/dave/jsgo/blob/master/LOCAL.md

@dave
Copy link
Owner

dave commented Sep 27, 2018

p.s. Setting this up as a docker container won't be trivial for two reasons:

  1. Instead of asking the internet for git repos it uses files in your GOPATH, so that would need to be mapped into the docker container.
  2. The initialisation step takes a few minutes (it pre-compiles all the standard library packages) and populates a temporary directory (defaults to ~/.jsgo-local/) so this would need to be persisted if you wanted fast start-up.

@roscopecoltran
Copy link
Author

Thanks I will try it tonight :-), will keep you update

Many thanks ^^

@roscopecoltran
Copy link
Author

roscopecoltran commented Sep 28, 2018

Later today I will try with that too, https://github.com/kassisol/docker-volume-git

@roscopecoltran
Copy link
Author

roscopecoltran commented Oct 9, 2018

Hi Dave,

Hope you are all well !

Many thanks for the local version, it makes my life so easier for testing some new golang packages. Your work is just amazing as it fits in many of my side projects on golang ast and package embedding.

I have a couple more questions, and one that probably I should I have posted in forky or golib, but I can re-publish them later if you do not mind.

Questions:

Fetch remote git repos in local mode

Actually, it seems that go packages have to be already installed in my GOPATH. And, by exploring the code, I saw that you use the the context struct from go/build, so I was wondering how complicated it would be to have jsgo with a custom GOPATH to fetch/load remote/local packages (without GCSE client)

Suggestion

Parse go test files*

  • a. Would be awesome to detect the "testing" package and be able to run go tests.
  • b. Parsing go tests ast and rewrite them into main package if upper solution is too complicated
  • c. I have more questions but I will post an issue into forky for more clarity

Nb. Would be awesome to have a gitter chat for quick questions or suggestions (more convenient than slack for me)

Last word, you have made an amazing work dude ! How many brains do you have :-) ?!

Cheers,
Rosco

@dave
Copy link
Owner

dave commented Oct 9, 2018

Hey Rosco, to get it to fetch git repos in local mode should be very simple... Take a look at:

https://github.com/dave/jsgo/blob/master/server/server.go

... we just need to change where it injects the fetcher (the bit that gets git repos) and the resolver (the bit that resolves go paths into git repos) into the server in local mode... I never extracted the "live" version of the resolver to an external service, so to use the live resolver, you just set it to nil. So... Change this:

	if config.LOCAL {
		fileserver = localfileserver.New(config.LocalFileserverTempDir, config.Static, config.Host, config.Bucket)
		database = localdatabase.New(config.LocalFileserverTempDir)
		fetcherResolver := localfetcher.New()
		c = cache.New(
			database,
			fetcherResolver,
			fetcherResolver,
			config.HintsKind,
		)
	} else {

to this:

	if config.LOCAL {
		fileserver = localfileserver.New(config.LocalFileserverTempDir, config.Static, config.Host, config.Bucket)
		database = localdatabase.New(config.LocalFileserverTempDir)
		c = cache.New(
			database,
			gitfetcher.New(
				cachefileserver.New(1024*1024*1042, 100*1024*1024),
				fileserver,
				config.GitFetcherConfig,
			),
			nil,
			config.HintsKind,
		)
	} else {

... and it should work? (I didn't test this)

@dave
Copy link
Owner

dave commented Oct 9, 2018

Parsing go test files shouldn't be too difficult to add, but I never implemented it for the jsgo ecosystem because it's not really needed.

@roscopecoltran
Copy link
Author

Hey Rosco, to get it to fetch git repos in local mode should be very simple... Take a look at:

https://github.com/dave/jsgo/blob/master/server/server.go

... we just need to change where it injects the fetcher (the bit that gets git repos) and the resolver (the bit that resolves go paths into git repos) into the server in local mode... I never extracted the "live" version of the resolver to an external service, so to use the live resolver, you just set it to nil. So... Change this:

	if config.LOCAL {
		fileserver = localfileserver.New(config.LocalFileserverTempDir, config.Static, config.Host, config.Bucket)
		database = localdatabase.New(config.LocalFileserverTempDir)
		fetcherResolver := localfetcher.New()
		c = cache.New(
			database,
			fetcherResolver,
			fetcherResolver,
			config.HintsKind,
		)
	} else {

to this:

	if config.LOCAL {
		fileserver = localfileserver.New(config.LocalFileserverTempDir, config.Static, config.Host, config.Bucket)
		database = localdatabase.New(config.LocalFileserverTempDir)
		c = cache.New(
			database,
			gitfetcher.New(
				cachefileserver.New(1024*1024*1042, 100*1024*1024),
				fileserver,
				config.GitFetcherConfig,
			),
			nil,
			config.HintsKind,
		)
	} else {

... and it should work? (I didn't test this)

Cool, I will test it now and post feedback later.

@roscopecoltran
Copy link
Author

Parsing go test files shouldn't be too difficult to add, but I never implemented it for the jsgo ecosystem because it's not really needed.

Is there any roadmap or deck describing jsgo's ecosystem and goals ? I would be more than pleased to understand the origins/problems to solve that triggered this interesting project

@dave
Copy link
Owner

dave commented Oct 9, 2018

No, there's no more documentation above what's in the readme.

@roscopecoltran
Copy link
Author

Hi,

Hope you are all well !

Sorry for the delay, but I am playing with jsgo quite a lot, and it is really awesome.

I managed to make it work locally but I add to install some dependencies not mentioned in the doc. Also, for the docker container, I spent 2 days with an alpine based image but I had lots of tweaks to do in order to make it work (wasted lot of time that before finding that gopherjs check strictly the go version as I had v1.11.1 and not gov1.11). So, I need more time to get some packed properly on my side.

But, for now, I have some annoying errors that maybe you can help to sort out.

https://play.jsgo.io/github.com/shurcooL/gtdo

gopath/src/github.com/shurcooL/gtdo/doc_handler.go:203:31: New not declared by package select_menu

And, if you a the "dev" build tag, you get:

{"Time":"2018-10-16T16:20:52.712398+02:00","Error":"gopath/src/golang.org/x/sys/unix/timestruct.go:13:24: undeclared name: Timespec","Ip":""}

Saved playground link:
https://play.jsgo.io/58866e7121a00ee3b6bc79bad74acb191d67ef0c

Is there a way to pass build tags as query parameter with values, maybe comma separated, in the url ?

Thanks in advance

Cheers,
Rosco

@dave
Copy link
Owner

dave commented Oct 16, 2018

Not sure why that's happening... But if that gtdo package wasn't created with the jsgo environment in mind then it's possible it needs changes to work... You might need to fork it and get it to work without that build tag... I'm guessing the dev build tag causes something unrelated to load a package it shouldn't... I don't think golang.org/x/sys/unix should be loading.

@dave
Copy link
Owner

dave commented Oct 16, 2018

But wait gtdo isn't a GopherJS app at all... I wouldn't expect it to work... It's trying to start a web server.

This is the GopherJS package: https://play.jsgo.io/github.com/shurcooL/gtdo/frontend/

... which runs, but doesn't work well probably because it's looking for static assets.

@roscopecoltran
Copy link
Author

Thanks for explanations above, I will continue to read gopherjs/vecty and jsgo codebases.

One thing, can you confirm that latest src-d update, 4 days ago, on `gopkg.in/src-d/go-git.v4/...", is generating the same error as above, on your side ?

have (sivafs.SivaFS)
want (billy.Filesystem, cache.Object)"

Last question, from your perspective, what are the benefits of gopherjs on the long run ? Is it "a nice to have" project for Google ? Some contacts argued that they could not find any serious boilerplate/demo for a real-world use case, so not suitable for agency/production purposes.

What made you write jsgo project ?

Gopherjs projects found:
https://gotools.org/github.com/gopherjs/gopherjs/js?tab=dependents
https://gotools.org/github.com/gopherjs/vecty?tab=dependents

@dave
Copy link
Owner

dave commented Oct 17, 2018

I refreshed all my dependencies including gopkg.in/src-d/go-git.v4/... but I'm not getting that error... Where does the error occur?

I love Go but I also love the front-end web. Running Go on the front-end is something I've always wanted to do.

Some contacts argued that they could not find any serious boilerplate/demo for a real-world use case, so not suitable for agency/production purposes.

Absolutely right. It's definitely not mature enough for "agency" purposes. Whether it's ready for production depends on the context. I'm running it in production with play.jsgo.io, and it works great.

The jsgo system is something I've always wanted to create, since first playing with GopherJS - the package splitting and caching specifically. Check out the little intro on https://github.com/dave/jsgo

@dave
Copy link
Owner

dave commented Oct 17, 2018

Hmm yes you're right... I'll take a closer look...

@dave
Copy link
Owner

dave commented Oct 17, 2018

Aaah I had a branch checked out in my go-git directory, so it wasn't pulling the latest master. I've fixed the bug... give it a try now.

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

2 participants