NilsIrl / dockerc

container image to single executable compiler
GNU General Public License v3.0
2.74k stars 40 forks source link

Usage of -e and -v flags when generating the binary #14

Closed tokenwizard closed 5 months ago

tokenwizard commented 5 months ago

Hi, Cool project. I notice in the documentation it mentions that you can use -e and -v as you would with docker run commands. Can you please provide an example of this usage? I have tried placing those flags before and after the --image flag and each time I get an error that the arguments are invalid.


dockerc --image docker://codeberg.org/sentryshot/sentryshot:latest -e TZ=America/New_York -v ./configs:/app/configs -v ./storage:/app/storage --output sentryshot 
Invalid argument '-e'
error: InvalidArgument

dockerc -e TZ=America/New_York -v ./configs:/app/configs -v ./storage:/app/storage --image docker://codeberg.org/sentryshot/sentryshot:latest --output sentryshot
Invalid argument '-e'
error: InvalidArgument
MichalisDBA commented 5 months ago

@tokenwizard I think these flags are used after you have created the static binary.

First: dockerc --image docker://codeberg.org/sentryshot/sentryshot:latest --output sentryshot

and then run it like that ./sentryshot -e TZ=America/New_York -v ./configs:/app/configs -v ./storage:/app/storage

tokenwizard commented 5 months ago

Nailed it! That was exactly it. Thanks!

tokenwizard commented 5 months ago

For those that may come here with the same question, @MichalisDBA correctly pointed out above that you add any docker-related flags when you run the newly-created binary.

ghuls commented 1 week ago

Not all docker options seem to be supported:

❯ ./test --entrypoint bash -ti
unknown option --entrypoint
usage: python3 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
NilsIrl commented 1 week ago

@ghuls Please open a separate issue for this. For this particular case, I would urge you to think what the desired user experience should be. When do you think it would be most appropriate to specify the option. Is this really something that should be specified when calling the binary? Perhaps you should consider changing the entrypoint using docker commit and then calling dockerc to create a binary.