如何在GCP上使用Rails自定义运行时?
我正在试图dockerize教程书架应用程序。 该应用程序本地运行正常,但部署到GCP后,我只是得到一个502错误的网关错误,并在日志中没有消息。
这些是相关的文件:
app.yml
runtime: custom env: flex entrypoint: bundle exec rails s -p 8080 -b '0.0.0.0' env_variables: RAILS_ENV: production POSTGRES_USER: postgres POSTGRES_PASSWORD: secret_password POSTGRES_DATABASE: postgres POSTGRES_SOCKET_PATH: /cloudsql/my_connection_name beta_settings: cloud_sql_instances: my_connection_name
Dockerfile
FROM ruby:2.3.3 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs RUN mkdir -p /myapp WORKDIR /myapp ADD Gemfile /myapp/Gemfile ADD Gemfile.lock /myapp/Gemfile.lock RUN bundle install
泊坞窗,compose.yml
version: 2 services: db: image: postgres ports: - "5432:5432" web: environment: - RAILS_ENV=development build: . command: bundle exec rails s -p 8080 -b '0.0.0.0' volumes: - .:/myapp ports: - "3000:8080" depends_on: - db
docker-compose up命令允许我像以前一样访问localhost:3000中的应用程序。
这是部署到谷歌云时日志的最后输出:
... Installing rspec-rails 3.5.2 Installing rails 4.2.6 Bundle complete! 11 Gemfile dependencies, 107 gems now installed. Bundled gems are installed into /usr/local/bundle. ---> e347b4148863 Removing intermediate container f65e759f2688 Successfully built e347b4148863 Successfully tagged eu.gcr.io/hj-gcp-tutorial/appengine/default.20171016t100956:latest PUSH Pushing eu.gcr.io/hj-gcp-tutorial/appengine/default.20171016t100956:latest The push refers to a repository [eu.gcr.io/hj-gcp-tutorial/appengine/default.20171016t100956] a58a218e4d69: Preparing ... a58a218e4d69: Pushed latest: digest: sha256:71db0d4944d5f457081d5f71cbf1c96b5504cf64eff97775fd50ece6c90e1dc2 size: 3047 DONE --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Updating service [default]...done. Waiting for operation [apps/hj-gcp-tutorial/operations/58f0d27e-9599-4c9c-bf72-d75221c45869] to complete...done. Stopping version [hj-gcp-tutorial/default/20171016t094317]. Updating service [default]...|Sent request to stop version [hj-gcp-tutorial/default/20171016t094317]. This operation may take some time to complete. If you would like to verify that it succeeded, run: $ gcloud app versions describe -s default 20171016t094317 until it shows that the version has stopped. Updating service [default]...done. Deployed service [default] to [https://hj-gcp-tutorial.appspot.com] You can stream logs from the command line by running: $ gcloud app logs tail -s default To view your application in the web browser run: $ gcloud app browse
之后访问应用程序时,我得到的是这样的:
2017-10-16 08:50:32 default[20171016t100956] "GET /" 502 2017-10-16 08:50:32 default[20171016t100956] "GET /favicon.ico" 502
- Docker – 无法构build映像 – fork / exec docker-containerd-shim:没有这样的文件或目录
- supervisord – 我的服务无法停止,开始没有给出正确的答案
- COS将耗尽/ var / lib / docker卷的inode
- 在Docker中运行的Python / Flask中运行Vision API演示时的StatusCode.UNAUTHENTICATED
- 如何加快谷歌云平台上的bazel构build
- Google容器引擎:访问云端存储
- 无法在Apache Mesos中关注沙箱链接
- Kubernetes无法访问谷歌云平台上的Grafana和Prometheus
- 在Google Container Registry中通过命令行添加标签来标记Docker镜像
- 在Google Cloud上安全部署私有Docker镜像的正确方法是什么?
- Google云端容器:从Dockerfile创build一个docker容器