rikkix / v2gen

A powerful cross-platform CLI client for V2Ray subscription. 跨平台V2Ray命令行订阅管理客户端
MIT License
143 stars 29 forks source link

Can not run with alpine #11

Closed cxgreat2014 closed 4 years ago

cxgreat2014 commented 4 years ago
root@hw:~/test/v2tproxy# ./v2gen -h
Usage of ./v2gen:
  -best
        use best node judged by ping result
  -c string
        v2gen config path (default "/etc/v2ray/v2gen.ini")
  -ct int
        ping count for each node (default 3)
  -dest string
        test destination url (vmess ping only) (default "https://cloudflare.com/cdn-cgi/trace")
  -eto int
        timeout seconds for each request (default 8)
  -ic
        use ICMP ping instead of vmess ping
  -init
        initialize v2gen config
  -med
        use median instead of ArithmeticMean
  -n int
        node index (default -1)
  -np
        do not ping
  -o string
        output path (default "/etc/v2ray/config.json")
  -r    random node index
  -sort
        sort ping results
  -t int
        threads used when pinging (default 5)
  -tpl string
        V2Ray tpl path
  -tto int
        timeout seconds for each node (default 25)
  -u string
        subscription URL
  -v    show version
  -vmess string
        vmess link(s)
root@hw:~/test/v2tproxy# cat Dockerfile
FROM alpine
RUN apk update && apk add bash wget curl
COPY v2gen /bin

ENTRYPOINT ["v2gen","-h"]
root@hw:~/test/v2tproxy# docker build .
Sending build context to Docker daemon  6.264MB
Step 1/4 : FROM alpine
 ---> f70734b6a266
Step 2/4 : RUN apk update && apk add bash wget curl
 ---> Using cache
 ---> e1f545f422cb
Step 3/4 : COPY v2gen /bin
 ---> Using cache
 ---> c07a856be4c9
Step 4/4 : ENTRYPOINT ["v2gen","-h"]
 ---> Running in 38f2f9464628
Removing intermediate container 38f2f9464628
 ---> d06c197a5cf2
Successfully built d06c197a5cf2
root@hw:~/test/v2tproxy# docker run -it --rm d06c19
root@hw:~/test/v2tproxy# 

No matter what command it is, it cannot be executed.

rikkix commented 4 years ago

please self build v2gen with command

CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' .

and that works to me

richard ~> docker build .            
Sending build context to Docker daemon  22.51MB
Step 1/4 : FROM alpine
---> f70734b6a266
Step 2/4 : RUN apk update && apk add bash wget curl
---> Using cache
---> a02c586c9d5d
Step 3/4 : COPY v2gen /bin
---> Using cache
---> d5a22d1fed32
Step 4/4 : ENTRYPOINT ["v2gen","-h"]
---> Using cache
---> 9d49661dd3f1
Successfully built 9d49661ddd01

richard ~> docker run 9d49661ddd01   
Usage of v2gen:
...

reference: https://github.com/ArkArk/latexmk-docker/issues/1#issuecomment-564627006