grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Add Dockerfile for `grumpy` #151

Open abitrolly opened 4 years ago

abitrolly commented 4 years ago

It is Ubuntu 20.04 with Python 2. Still not clear how to run grumpy directly from source.

/app/grumpy-tools-src# python2 grumpy_tools
/usr/bin/python2: can't find '__main__' module in 'grumpy_tools'

Need some helper scripts.


Test that the image works.

docker run -it yakshaveinc/grumpy
alanjds commented 4 years ago

You can take a look on the .travis.yaml describing the CI test.

You may need to run the following lines on the Dockerfile to produce a working image:

https://github.com/grumpyhome/grumpy/blob/9c8d5003b183b8bef1626e812af59d8b792de17e/.travis.yml#L28-L52

After that, the grumpy command will be available. Then you may want to put it on the ENTRYPOINT Dockerfile statement.

abitrolly commented 4 years ago

I see there is only one script in grumpy-tools-src. Maybe rename the dir to grumpy-cli?

alanjds commented 4 years ago

This could be done the two packages got independent. But they are coupled to a point that a split CI seemed not wise at the time. Having such names was the way I got to be able to use a monorepo for both packages.

The proposed change will lead to deep changes on the package management & CI involving makefiles and Golang compilation. I do not recommend doing so, but feel free to mark me for code review or ask for references on setuptools internals :)

abitrolly commented 4 years ago

@alanjds the directory structure already diverged between two grumpyhome and google. A circular dependency between cli and libs of grumpy doesn't looks like a good thing to me.

abitrolly commented 4 years ago

Saving commands I use to build the image.

podman build -t grumpy .

podman tag grumpy docker.io/yakshaveinc/grumpy
podman push --creds "$(pass yakshaveinc/docker | tr ' ' ':')" docker.io/yakshaveinc/grumpy:latest

podman run -it yakshaveinc/grumpy
abitrolly commented 4 years ago

At least grumpy-tools doesn't need grumpy-runtime for the installation.

✗ podman run -it yakshaveinc/grumpy grumpy
Error: Could not found the Grumpy Runtime 'data/gopath' resource.
Is 'grumpy-runtime' package installed?
abitrolly commented 4 years ago

Everything installs without error, but running fails.

# grumpy -c 'print("hello")'
/tmp/tmptxtN5t__pycache__/gopath/src/__python__/main.go:6:2: cannot find package "__python__/__go__/grumpy" in any of:
    /usr/lib/go-1.13/src/__python__/__go__/grumpy (from $GOROOT)
    /tmp/tmptxtN5t__pycache__/gopath/src/__python__/__go__/grumpy (from $GOPATH)
    /app/grumpy-runtime-src/grumpy_runtime/data/gopath/src/__python__/__go__/grumpy
abitrolly commented 4 years ago

@alanjds pushed latest version to Docker Hub. Should work now.