将Rasa与Google Cloud Platform一起使用时,Dockerfile中应包含什么内容

问题描述 投票:0回答:1

我正在为Rasa开源聊天机器人使用Google Cloud Platform和Google App Engine(灵活)。

我已经将Google Cloud SDK下载到我的本地计算机上,并使用gcloud app deploy将聊天机器人部署到App Engine(我认为这会创建docker映像是正确的。)>

App Engine需要一个Dockerfile和一个app.yaml文件。我只是不确定Dockerfile中应该包含什么。遇到麻烦的是指向模型端点,该端点认为它不是zip文件。

Dockerfile看起来像:

FROM rasa/rasa
ENV BOT_ENV=production
COPY . /var/www
WORKDIR /var/www
RUN pip install rasa
ENTRYPOINT [ "rasa", "run", "-m", "./models", "-vv", "--enable-api", "--endpoints", "endpoints.yml", "--credentials", "credentials.yml", "-p", "8080"]


C:\Users\xxxxxxxx\Desktop\xxxxxxxxx>gcloud app deploy --version chatbot15
Services to deploy:

descriptor:      [C:\Users\xxxxxx\Desktop\xxxxxxxxx\app.yaml]
source:          [C:\Users\xxxxxx\Desktop\xxxxxxxx]
target project:  [xxxxx-xxxxxxx]
target service:  [default]
target version:  [chatbot15]
target url:      [https://xxxxxxxx.appspot.com]


Do you want to continue (Y/n)?  y

Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [.
To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/xxxxxx41f1f-c289-xxxxxxx-9ba1-xxxxxxxxxxx]
------------------------------------------------- REMOTE BUILD OUTPUT --------------------------------------------------
starting build "xxxxxx41f1f-c289-xxxxxxx-9ba1-xxxxxxxxxxx]"

FETCHSOURCE
Fetching storage object: gs://staging.xxxxxxxxxx.appspot.com/us.gcr.io/xxxxxxxxxx/appengine/default.chatbot15:latest#1xxxxxxxxxxx0
Copying gs://staging.xxxxxxxxxxx.appspot.com/us.gcr.io/xxxxxxxxxx/appengine/default.chatbot15:latest#158xxxxxxxxxx2560...
\ [1 files][ 24.3 MiB/ 24.3 MiB]
Operation completed over 1 objects/24.3 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
Sending build context to Docker daemon  38.15MB
Step 1/6 : FROM rasa/rasa
latest: Pulling from rasa/rasa

Digest: sha256:cc6a48c7cxxxc8f1c8c3bxxxxxxxxxxxxxxxxef266a58121f41e22b418c6a
Status: Downloaded newer image for rasa/rasa:latest
 ---> fcf204982b0f
Step 2/6 : ENV BOT_ENV=production
 ---> Running in 708a75c57f16
Removing intermediate container 708a75c57f16
 ---> 780c38217741
Step 3/6 : COPY . /var/www
 ---> a32cfeb03a84
Step 4/6 : WORKDIR /var/www
 ---> Running in 4f4f0446c8a4
Removing intermediate container 4f4f0446c8a4
 ---> 1751f3ffc062
Step 5/6 : RUN pip install rasa
 ---> Running in b70c61ca4670
[91mWARNING: The directory '/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

[0mRemoving intermediate container b70cxxxx670
 ---> 3e8xxx0f91c
Step 6/6 : ENTRYPOINT [ "rasa", "run", "-m", "./models", "-vv", "--enable-api", "--endpoints", "endpoints.yml", "--credentials", "credentials.yml", "-p", "8080"]
 ---> Running in 4xxxxxx6
Removing intermediate container 4xxxxxxxxxx6
 ---> 6fxxxxxxxxx30
Successfully built 6xxxxxxxxxxx30
Successfully tagged us.gcr.io/xxxxxxxxxx/appengine/default.chatbot15:latest
PUSH
Pushing us.gcr.io/xxxxxxxxxxx/appengine/default.chatbot15:latest
The push refers to repository [us.gcr.io/xxxxxxxxxxx/appengine/default.chatbot15]
0da5206fa56e: Pushed
latest: digest: sha256:d1cxxxxxxxxxxxxxxxxxxxxxxxx724xxxxxx size: 2837
DONE
------------------------------------------------------------------------------------------------------------------------

Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
2020-01-27 19:54:37 DEBUG    rasa.core.utils  - Available web server routes:
/conversations/<conversation_id>/messages          POST                           add_message
/conversations/<conversation_id>/tracker/events    POST                           append_events
/webhooks/rasa                                     GET                            custom_webhook_RasaChatInput.health
/webhooks/rasa/webhook                             POST                           custom_webhook_RasaChatInput.receive
/webhooks/rest                                     GET                            custom_webhook_RestInput.health
/webhooks/rest/webhook                             POST                           custom_webhook_RestInput.receive
/model/test/intents                                POST                           evaluate_intents
/model/test/stories                                POST                           evaluate_stories
/conversations/<conversation_id>/execute           POST                           execute_action
/domain                                            GET                            get_domain
/socket.io                                         GET                            handle_request
/                                                  GET                            hello
/model                                             PUT                            load_model
/model/parse                                       POST                           parse
/conversations/<conversation_id>/predict           POST                           predict
/conversations/<conversation_id>/tracker/events    PUT                            replace_events
/conversations/<conversation_id>/story             GET                            retrieve_story
/conversations/<conversation_id>/tracker           GET                            retrieve_tracker
/webhooks/socketio                                 GET                            socketio_webhook.health
/status                                            GET                            status
/model/predict                                     POST                           tracker_predict
/model/train                                       POST                           train
/conversations/<conversation_id>/trigger_intent    POST                           trigger_intent
/model                                             DELETE                         unload_model
/version                                           GET                            version
2020-01-27 19:54:37 INFO     root  - Starting Rasa server on http://localhost:8080
2020-01-27 19:54:37 DEBUG    rasa.core.utils  - Using the default number of Sanic workers (1).
2020-01-27 19:54:37 INFO     root  - Enabling coroutine debugging. Loop id 94796527495608.
2020-01-27 19:54:37 DEBUG    rasa.model  - Extracted model to '/tmp/tmpq4hewp3_'.
2020-01-27 19:54:41.930821: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2020-01-27 19:54:42 DEBUG    rasa.core.tracker_store  - Connected to InMemoryTrackerStore.
2020-01-27 19:54:42 DEBUG    rasa.core.lock_store  - Connected to lock store 'InMemoryLockStore'.
2020-01-27 19:54:42 DEBUG    rasa.core.nlg.generator  - Instantiated NLG to 'TemplatedNaturalLanguageGenerator'.
2020-01-27 19:54:42 DEBUG    rasa.core.agent  - Requesting model from server http://xxxxxxxxxxx.appspot.com/?hl=en-GB/models/20200123-205743.tar.gz...
2020-01-27 19:54:42 ERROR    rasa.core.agent  - Could not load model due to File is not a zip file.
[2020-01-27 19:54:42 +0000] [1] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
  File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 195, in unarchive
    tar = tarfile.open(fileobj=IOReader(byte_array))
  File "/usr/local/lib/python3.6/tarfile.py", line 1576, in open
    raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/build/lib/python3.6/site-packages/sanic/app.py", line 1133, in run
    serve(**server_settings)
  File "/build/lib/python3.6/site-packages/sanic/server.py", line 857, in serve
    trigger_events(before_start, loop)
  File "/build/lib/python3.6/site-packages/sanic/server.py", line 634, in trigger_events
    loop.run_until_complete(result)
  File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
  File "/build/lib/python3.6/site-packages/rasa/core/run.py", line 247, in load_agent_on_start
    action_endpoint=endpoints.action,
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 248, in load_agent
    model_server,
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 64, in load_from_server
    await _update_model_from_server(model_server, agent)
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 122, in _update_model_from_server
    model_server, agent.fingerprint
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 180, in _pull_model_and_fingerprint
    rasa.utils.io.unarchive(await resp.read(), model_directory)
  File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 200, in unarchive
    zip_ref = zipfile.ZipFile(IOReader(byte_array))
  File "/usr/local/lib/python3.6/zipfile.py", line 1131, in __init__
    self._RealGetContents()
  File "/usr/local/lib/python3.6/zipfile.py", line 1198, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Traceback (most recent call last):
  File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 195, in unarchive
    tar = tarfile.open(fileobj=IOReader(byte_array))
  File "/usr/local/lib/python3.6/tarfile.py", line 1576, in open
    raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/build/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/build/lib/python3.6/site-packages/rasa/__main__.py", line 76, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/build/lib/python3.6/site-packages/rasa/cli/run.py", line 83, in run
    rasa.run(**vars(args))
  File "/build/lib/python3.6/site-packages/rasa/run.py", line 56, in run
    **kwargs,
  File "/build/lib/python3.6/site-packages/rasa/core/run.py", line 206, in serve_application
    endpoints.lock_store if endpoints else None
  File "/build/lib/python3.6/site-packages/sanic/app.py", line 1133, in run
    serve(**server_settings)
  File "/build/lib/python3.6/site-packages/sanic/server.py", line 857, in serve
    trigger_events(before_start, loop)
  File "/build/lib/python3.6/site-packages/sanic/server.py", line 634, in trigger_events
    loop.run_until_complete(result)
  File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
  File "/build/lib/python3.6/site-packages/rasa/core/run.py", line 247, in load_agent_on_start
    action_endpoint=endpoints.action,
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 248, in load_agent
    model_server,
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 64, in load_from_server
    await _update_model_from_server(model_server, agent)
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 122, in _update_model_from_server
    model_server, agent.fingerprint
  File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 180, in _pull_model_and_fingerprint
    rasa.utils.io.unarchive(await resp.read(), model_directory)
  File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 200, in unarchive
    zip_ref = zipfile.ZipFile(IOReader(byte_array))
  File "/usr/local/lib/python3.6/zipfile.py", line 1131, in __init__
    self._RealGetContents()
  File "/usr/local/lib/python3.6/zipfile.py", line 1198, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

谢谢。

我正在为Rasa开源聊天机器人使用Google Cloud Platform和Google App Engine(灵活)。我已将Google Cloud SDK下载到我的本地计算机上,并使用gcloud应用程序部署了聊天机器人...

google-app-engine rasa-nlu rasa-core rasa
1个回答
0
投票

我的dockerfile看起来像这样:

热门问题
推荐问题
最新问题