본문 바로가기
Google Cloud/0x01-app engine

google app engine 사용하기 ][ ruby hello world 출력 및 배포하기

by SpeeDr00t 2019. 2. 14.
반응형

google app engine 사용하기 ][ python hello world 출력 및 배포하기  


https://cloud.google.com/appengine/


■ app engine 선택



■ ruby 선택




■ 리소스에 "documentation"과 github 샘플 참조




■ 샘플 소스 다운로드


git clone https://github.com/GoogleCloudPlatform/ruby-docs-samples
cd ruby-docs-samples/appengine/hello_world



■ app.rb 소스 확인


# Copyright 2015 Google, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START gae_flex_quickstart]
require "sinatra"
get "/" do
"Hello world!"
end
# [END gae_flex_quickstart]
view raw app.rb hosted with ❤ by GitHub



■ app.yaml 확인


# Copyright 2015 Google, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START gae_flex_quickstart_yaml]
runtime: ruby
env: flex
entrypoint: bundle exec ruby app.rb
# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/ruby/configuring-your-app-with-app-yaml
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
# [END gae_flex_quickstart_yaml]
view raw app.yaml hosted with ❤ by GitHub




■ cloud shell에서 app테스트


bundle install
bundle exec ruby app.rb -p 8080
view raw app 테스트 hosted with ❤ by GitHub



■ 배포


gcloud app create
gcloud app deploy
view raw 배포 hosted with ❤ by GitHub






■ 결과 확인







반응형