0

I'm new to Cloudrun, attempting to deploy a Sinatra app. I've gone through the documentation, but can't figure out why '--source' keeps getting passed in. Haven't left it in the app itself, I figure it's added in from the deploy command. I've tried many tweaks to the Dockerfile & application config. I'd prefer not to have to install Docker on this machine but dockerizing before deployment could well solve the issue. I'd appreciate suggestions on what else I could try.

Error messages from logs:

1) terminated: Application failed to start: kernel init: cannot resolve init executable: error finding executable "--source" in PATH [/usr/local/bundle/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin]: no such file or directory

2) /usr/local/bundle/gems/sinatra-3.0.6/lib/sinatra/main.rb:22:in `<module:Sinatra>': invalid option: --source (OptionParser::InvalidOption)

$ gcloud run deploy
Deploying from source. To deploy a container use [--image]. See https://cloud.google.com/run/docs/deploying-source-code for more details.
Source code location (/home/bjorn/...):      
Next time, use `gcloud run deploy --source .` to deploy the current directory.

# Dockerfile

FROM ruby:3.2.2

WORKDIR /usr/src/app

COPY Gemfile Gemfile.lock ./
ENV BUNDLE_FROZEN=true
ENV BUNDLER_VERSION 2.4.10

RUN gem install bundler && \
  bundle config set --local without 'test' && \
  bundle install

COPY server.rb config.ru puma.rb ./

EXPOSE 8080

Entrypoint ["ruby", "./server.rb"]
# Alternately:
# CMD ["ruby", "./server.rb"]
# CMD ["bundle", "exec", "rackup", "--host", "0.0.0.0", "-p", "8080"]
# CMD ["web: bundle exec ruby server.rb -p 8080

Per request, more verbose logs:

DEFAULT 2023-08-21T07:45:18.516796Z /usr/local/bundle/gems/sinatra-3.1.0/lib/sinatra/main.rb:22:in `<module:Sinatra>': invalid option: --source (OptionParser::InvalidOption)
DEFAULT 2023-08-21T07:45:18.516820Z from /usr/local/bundle/gems/sinatra-3.1.0/lib/sinatra/main.rb:3:in `<top (required)>'
DEFAULT 2023-08-21T07:45:18.516826Z from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
DEFAULT 2023-08-21T07:45:18.516831Z from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
DEFAULT 2023-08-21T07:45:18.516836Z from /usr/local/bundle/gems/sinatra-3.1.0/lib/sinatra.rb:3:in `<top (required)>'
DEFAULT 2023-08-21T07:45:18.516840Z from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:159:in `require'
DEFAULT 2023-08-21T07:45:18.516845Z from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:159:in `rescue in require'
DEFAULT 2023-08-21T07:45:18.516849Z from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:39:in `require'
DEFAULT 2023-08-21T07:45:18.516854Z from ./server.rb:1:in `<main>'
DEFAULT 2023-08-21T07:45:18.516859Z <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sinatra (LoadError)
DEFAULT 2023-08-21T07:45:18.516864Z from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
DEFAULT 2023-08-21T07:45:18.516867Z from ./server.rb:1:in `<main>'
WARNING 2023-08-21T07:45:18.579930873Z Container called exit(1).
ERROR 2023-08-21T07:45:18.619506Z [protoPayload.serviceName: run.googleapis.com] [protoPayload.methodName: v1] [protoPayload.resourceName: [xyz] Ready condition status changed to False for Revision xyz with message: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information. Logs URL: https://console.cloud.google.com/logs/viewer?project=etc For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start
bjorn
  • 175
  • 2
  • 9
  • Can you check this [Documentation](https://cloud.google.com/run/docs/deploying-source-code). Also can you share the error logs by following this [Documentation](https://cloud.google.com/run/docs/logging). – Sandeep Vokkareni Aug 21 '23 at 12:45
  • Yes, I went through that page as well when setting up. As well as the Ruby specific cloud page, https://cloud.google.com/appengine/docs/flexible/ruby/create-app. I already included the log results I find to be relevant, I suppose I could add more verbose logs to the question though. – bjorn Aug 21 '23 at 13:39
  • Hav you verified in your local system whether container running successfulley? Like launching images from Dockerfile and running using [docker run](https://stackoverflow.com/questions/36075525/how-do-i-run-a-docker-instance-from-a-dockerfile)? – Badala Prashanth Aug 21 '23 at 15:10
  • I don't have enough disk space to install Docker on the laptop I've been working with, would need to switch the project over to a different computer to try it out. – bjorn Aug 22 '23 at 01:33
  • The `Container failed to start` error may occur due to different reasons. Can you check this [troubleshooting documentation](https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start). – Sandeep Vokkareni Aug 22 '23 at 04:32
  • Also try to build your Docker image by using this command `docker buildx build --platform linux/amd64 -t TAG\_NAME` as suggested [here](https://stackoverflow.com/questions/66127933/cloud-run-failed-to-start-and-then-listen-on-the-port-defined-by-the-port-envi#:~:text=The%20full%20command%3A%20docker%20buildx%20build%20%2D%2Dplatform%20linux/amd64%20%2Dt%20image%2Dname%3Av0.1.0%20.%20Reference%3A%20Docker%20Docs). – Sandeep Vokkareni Aug 22 '23 at 05:36

0 Answers0