dpfl37651 2018-09-07 11:37
浏览 97

通过'revel build <testapp>'生成的run.sh二进制文件未在docker容器中运行

As I've recently started using revel framework to build go web app. I created a testapp (orpat), compiled it 'revel build orpat prod' and changed conf PORT->8084 for publishing the app. Files generated are -

  1. orpat (executable file 11 MB)
  2. run.sh
  3. run.bat
  4. src/ folder

It's executing well on my local system from other location(ofcourse it has golang and revel installed). http://localhost:8084

I copied the build files to a VM having no golang installed, it's executing there as well './run.sh' : run this cmd in terminal is enough to bring app online.

Below is dockerfile->

FROM golang:1.10.4-alpine3.8

RUN apk --no-cache add ca-certificates
RUN apk add --no-cache bash

COPY . /go/src/orpat

WORKDIR /go/src

EXPOSE 8084/tcp

RUN chmod -vR 777 /go/src/orpat

CMD [ "bash", "run.sh" ]

Image creation thru 'docker build -t orpat .' is working OK.

a@kc:~/docker/orpat$ sudo docker build -t orpat .
Sending build context to Docker daemon  12.02MB
Step 1/8 : FROM golang:1.10.4-alpine3.8
 ---> 20834f40149c
Step 2/8 : RUN apk --no-cache add ca-certificates
 ---> Running in 154c0f3024f1
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
OK: 5 MiB in 14 packages
Removing intermediate container 154c0f3024f1
 ---> 50d5c49f8eee
Step 3/8 : RUN apk add --no-cache bash
 ---> Running in b3c9ad1bfe06
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.1_p20180818-r1)
(2/5) Installing ncurses-terminfo (6.1_p20180818-r1)
(3/5) Installing ncurses-libs (6.1_p20180818-r1)
(4/5) Installing readline (7.0.003-r0)
(5/5) Installing bash (4.4.19-r1)
Executing bash-4.4.19-r1.post-install
Executing busybox-1.28.4-r0.trigger
OK: 14 MiB in 19 packages
Removing intermediate container b3c9ad1bfe06
 ---> 8ac100f8ab2f
Step 4/8 : COPY . /go/src/orpat
 ---> 7545fd3bf0d4
Step 5/8 : WORKDIR /go/src
 ---> Running in 469df33c4fea
Removing intermediate container 469df33c4fea
 ---> 69f0e4c2c42f
Step 6/8 : EXPOSE 8084/tcp
 ---> Running in 716e1d7b7f0f
Removing intermediate container 716e1d7b7f0f
 ---> 2bbd4e3c90b7
Step 7/8 : RUN chmod -vR 777 /go/src/orpat
 ---> Running in 1e9286d6f9ad
mode of '/go/src/orpat' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/500.txt' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/405.xml' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/500.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/405.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/404.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/500.xml' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/500.json' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/403.txt' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/403.json' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/404.txt' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/404.json' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/405.txt' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/404.xml' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/404-dev.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/405.json' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/403.xml' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/500-dev.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/templates/errors/403.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/conf' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/revel/conf/mime-types.conf' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/testrunner.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/plugin.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/controllers' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/controllers/testrunner.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/views' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/views/TestRunner' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/views/TestRunner/SuiteResult.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/views/TestRunner/Index.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/app/views/TestRunner/FailureDetail.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/js' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/js/jquery-1.9.1.min.js' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/js/bootstrap.min.js' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/js/highlight.pack.js' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/images' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/images/favicon.png' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/css' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/css/github.css' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/public/css/bootstrap.min.css' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/conf' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/testrunner/conf/routes' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/static' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/static/static.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/static/app' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/static/app/controllers' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/github.com/revel/modules/static/app/controllers/static.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/log' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/log/orpat-requests.json' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/README.md' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/tmp' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/tmp/main.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/init.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/routes' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/routes/routes.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/controllers' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/controllers/app.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/header.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/footer.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/flash.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/debug.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/App' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/App/Index.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/errors' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/errors/500.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/app/views/errors/404.html' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/messages' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/messages/sample.en' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/js' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/js/bootstrap-3.3.6.min.js' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/js/jquery-2.2.4.min.js' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/fonts' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/fonts/glyphicons-halflings-regular.woff2' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/fonts/glyphicons-halflings-regular.woff' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/fonts/glyphicons-halflings-regular.ttf' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/img' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/img/favicon.png' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/css' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/public/css/bootstrap-3.3.6.min.css' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/tests' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/tests/apptest.go' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/conf' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/conf/routes' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/src/orpat/conf/app.conf' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/run.sh' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/Dockerfile' changed to 0777 (rwxrwxrwx)
mode of '/go/src/orpat/orpat' changed to 0777 (rwxrwxrwx)
Removing intermediate container 1e9286d6f9ad
 ---> cceab940ff2c
Step 8/8 : CMD [ "bash", "run.sh" ]
 ---> Running in 41b7bf5daee6
Removing intermediate container 41b7bf5daee6
 ---> 51ee4984d102
Successfully built 51ee4984d102
Successfully tagged orpat:latest

But on creating container from image, it gets created and with Exited status. On restarting, it goes into Exited again. Unable to browse app in browser at 8084 port.

a@kc:~/docker/orpat$ sudo docker run -d -it -p 8084:8084 orpat
e0d87929635b1a0340b7ef297c1d01c1b9961d3e7562da6e9d79691a579058fd
a@kc:~/docker/orpat$ sudo docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
a@kc:~/docker/orpat$ sudo docker ps --all
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                        PORTS               NAMES
e0d87929635b        orpat               "bash run.sh"            17 seconds ago      Exited (127) 16 seconds ago                       naughty_easley
7ed9b052abff        sample:1.0          "npm start"              5 days ago          Exited (0) 4 days ago                             sample_app
74b229937da3        mongo:3.0.15        "docker-entrypoint.s…"   5 days ago          Exited (0) 4 days ago                             sample_db
a@kc:~/docker/orpat$ sudo docker container start naughty_easley 
naughty_easley
a@kc:~/docker/orpat$ sudo docker ps --all
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                       PORTS               NAMES
e0d87929635b        orpat               "bash run.sh"            46 seconds ago      Exited (127) 2 seconds ago                       naughty_easley
7ed9b052abff        sample:1.0          "npm start"              5 days ago          Exited (0) 4 days ago                            sample_app
74b229937da3        mongo:3.0.15        "docker-entrypoint.s…"   5 days ago          Exited (0) 4 days ago                            sample_db

So I go inside a totally new container, and execute this->

'sudo docker run -it -p 8084:8084 orpat bash'

and receiving errors like->

a@kc:~/docker/orpat$ sudo docker run -it -p 8084:8084 orpat bash
bash-4.4# pwd
/go/src
bash-4.4# ls -a
.      ..     orpat
bash-4.4# cd orpat/
bash-4.4# ls -a
.           ..          Dockerfile  orpat       run.sh      src
bash-4.4# cat Dockerfile 
FROM golang:1.10.4-alpine3.8

RUN apk --no-cache add ca-certificates
RUN apk add --no-cache bash

COPY . /go/src/orpat

WORKDIR /go/src

EXPOSE 8084/tcp

RUN chmod -vR 777 /go/src/orpat

CMD [ "bash", "run.sh" ]
bash-4.4# ./run.sh 
./run.sh: line 3: /go/src/orpat/orpat: not found
bash-4.4# bash run.sh 
run.sh: line 3: /go/src/orpat/orpat: No such file or directory
bash-4.4# cat run.sh 
#!/bin/sh
SCRIPTPATH=$(cd "$(dirname "$0")"; pwd)
"$SCRIPTPATH/orpat" -importPath orpat/ -srcPath "$SCRIPTPATH/src" -runMode prod
bash-4.4# 

on conf file, i've

# The IP address on which to listen.
http.addr = [::]

# The port on which to listen.
http.port = 8084

Can someone help me fix this, am looking for exe binary file to deployed. As this is a minimal testapp with just a page, i m stuck on my original sprint.

</div>
  • 写回答

1条回答 默认 最新

  • donglou8371 2019-09-16 17:56
    关注

    I do something like this:

    CGO_ENABLED=0 revel package -m prod -a project
    

    Dockerfile:

    # you could do FROM scratch if you really need nothing
    FROM alpine:3.10
    # add dependencies
    RUN apk --no-cache add ca-certificates tzdata
    # add the untarred file produced by revel package
    ADD project.tar.gz /opt
    # whatever port
    EXPOSE 8080
    # I looked inside run.sh for this
    CMD ["/opt/project", "-importPath", "project", "-srcPath", "/opt/src", "-runMode", "prod"]
    
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!