使用方式:
$ gf docker -hUSAGEgf docker [FILE] [OPTION]ARGUMENTFILE file path for "gf build", it's "main.go" in default.OPTION the same options as "docker build" except some options as follows definedOPTION-p, --push auto push the docker image to docker registry if "-t" option passedEXAMPLESgf dockergf docker -t hub.docker.com/john/image:taggf docker -p -t hub.docker.com/john/image:taggf docker main.gogf docker main.go -t hub.docker.com/john/image:taggf docker main.go -t hub.docker.com/john/image:taggf docker main.go -p -t hub.docker.com/john/image:tagDESCRIPTIONThe "docker" command builds the GF project to a docker images.It runs "gf build" firstly to compile the project to binary file.It then runs "docker build" command automatically to generate the docker image.You should have docker installed, and there must be a Dockerfile in the root of the project.
自动编译并生成docker镜像。非必需FILE参数为编译文件路径,默认为main.go。非必需参数OPTIONS为docker build命令相同参数及选项。
使用示例:
$ gf docker main.go -p -t loads/gf-demos:test2020-12-31 00:47:28.207 start building...2020-12-31 00:47:28.207 go build -o ./bin/linux_amd64/main main.go2020-12-31 00:47:35.894 done!Sending build context to Docker daemon 37.63MBStep 1/10 : FROM loads/alpine:3.8---> f9fb622e6db2Step 2/10 : LABEL maintainer="john@goframe.org"---> Using cache---> da238418d031Step 3/10 : ENV WORKDIR /var/www/gf-demos---> Using cache---> 3e7129c087c9Step 4/10 : ADD ./bin/linux_amd64/main $WORKDIR/main---> 3661a9dea494Step 5/10 : RUN chmod +x $WORKDIR/main---> Running in 1d49d5d91080Removing intermediate container 1d49d5d91080---> a03ee04e3380Step 6/10 : ADD public $WORKDIR/public---> 63dd06d0e1a3Step 7/10 : ADD config $WORKDIR/config---> fa7a57eba577Step 8/10 : ADD template $WORKDIR/template---> 7075609b0447Step 9/10 : WORKDIR $WORKDIR---> Running in a34ef38e1031Removing intermediate container a34ef38e1031---> 580077998eafStep 10/10 : CMD ./main---> Running in ed286b518ad9Removing intermediate container ed286b518ad9---> fbbc05842901Successfully built fbbc05842901Successfully tagged loads/gf-demos:testThe push refers to repository [docker.io/loads/gf-demos]b4025b95a79f: Preparing9e0369a57507: Preparing46c68dcc8e12: Preparing59adbc083ee5: Preparing10e0b999ba57: Preparing8e850d7b086e: Waitingd5e057db20a2: Waiting92e898fd7f84: Waitingd9ff549177a9: Waiting...
