Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Containers @ Google App Engine

Minku Lee
December 22, 2017

Containers @ Google App Engine

Google App Engine에 컨테이너 애플리케이션 배포하기

Minku Lee

December 22, 2017
Tweet

More Decks by Minku Lee

Other Decks in Technology

Transcript

  1. !

  2. GKE

  3. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  4. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  5. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  6. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  7. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  8. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  9. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  10. Dockerfile FROM ruby:2.4.1 ENV RAILS_ENV production ENV RAILS_LOG_TO_STDOUT true ENV

    RAILS_SERVE_STATIC_FILES true ENV PORT 8080 ADD . /opt/translator WORKDIR /opt/translator # Install Ruby dependencies RUN bundle install # Precompile assets RUN rake assets:precompile EXPOSE 8080 CMD ["./bin/rails", "server"]
  11. $ docker build -t translator . Sending build context to

    Docker daemon 3.723MB Step 1/16 : FROM ruby:2.4.1 ---> 3630c02d3d1b Step 2/16 : ENV RAILS_ENV production ---> 2a12ea7c6eef (઺ۚ) Step 13/16 : RUN bundle install ---> Running in f2a52936b83d Fetching gem metadata from https://rubygems.org/......... (઺ۚ) ---> 1f57192986de Step 16/16 : CMD ./bin/rails server ---> Running in b8b2bab7504c ---> dc51ead245a0 Removing intermediate container b8b2bab7504c Successfully built dc51ead245a0 Successfully tagged translator:latest
  12. $ docker run \ -p 8080:8080 \ -e SECRET_KEY_BASE=XXX \

    translator:latest => Booting Puma => Rails 5.1.3 application starting in production on http://0.0.0.0:8080 => Run `rails server -h` for more startup options Puma starting in single mode...
  13. $ docker run \ -p 8080:8080 \ -e SECRET_KEY_BASE=XXX \

    translator:latest => Booting Puma => Rails 5.1.3 application starting in production on http://0.0.0.0:8080 => Run `rails server -h` for more startup options Puma starting in single mode...
  14. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  15. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  16. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  17. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  18. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  19. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  20. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  21. app.yaml (manual scaling) runtime: custom env: flex skip_files: - .env

    - tmp/ - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 manual_scaling: instances: 10 env_variables: SECRET_KEY_BASE: 'XXX'
  22. app.yaml runtime: custom env: flex skip_files: - .env - tmp/

    - node_modules resources: cpu: 1 memory_gb: 1 disk_size_gb: 10 liveness_check: path: '/_internal/checks/health' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 readiness_check: path: '/_internal/checks/ready' check_interval_sec: 5 timeout_sec: 5 failure_threshold: 2 success_threshold: 2 app_start_timeout_sec: 300 automatic_scaling: min_num_instances: 1 max_num_instances: 10 cool_down_period_sec: 120 cpu_utilization: target_utilization: 0.6 env_variables: SECRET_KEY_BASE: 'XXX'
  23. App Engine $ gcloud app create You are creating an

    app for project [project-id]. WARNING: Creating an App Engine application for a project is irreversible and the region cannot be changed. More information about regions is at https://cloud.google.com/appengine/docs/locations. Please choose the region where you want your App Engine application located: [1] us-central (supports standard and flexible) (઺ۚ) [6] asia-northeast1 (supports standard and flexible) (઺ۚ) [9] cancel Please enter your numeric choice: 6 Creating App Engine application in project [project-id] and region [asia-northeast1]....done. Success! The app is now created. Please use `gcloud app deploy` to deploy your first app.
  24. $ gcloud app deploy Services to deploy: descriptor: [/Users/premist/dev/translator/app.yaml] source:

    [/Users/premist/dev/translator] target project: [sample-project-id] target service: [default] target version: [20170822t013314] target url: [https://sample-project-id.appspot.com] Do you want to continue (Y/n)? y If this is your first deployment, this may take a while...done. Beginning deployment of service [default]... Updating service [default]...done. Deployed service [default] to [https://sample-project-id.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
  25. Cloud SDK User's Computer Google Cloud Cloud Storage Cloud Container

    Builder App Engine Source upload Trigger build
  26. Cloud SDK User's Computer Google Cloud Cloud Storage Cloud Container

    Builder App Engine Source upload Trigger build Create new version
  27. Cloud SDK User's Computer Google Cloud Cloud Storage Cloud Container

    Builder App Engine Source upload Trigger build Create new version Wait for version to be ready
  28. Cloud SDK User's Computer Google Cloud Cloud Storage Cloud Container

    Builder App Engine Source upload Trigger build Create new version Wait for version to be ready Update traffic split
  29. ?

  30. Iowa Compute Engine: 1 App Engine Compute Engine Standard Sustained

    $42.984/mo $96.192/mo $223.056/mo Memory vCPU 1GB 2 4GB 4 14GB Preemptible $27.0864/mo $60.57504/mo $140.3568/mo $19.3/mo $43.3/mo $100.7/mo $6.79/mo $14.89/mo $35.09/mo
  31. Iowa Heroku: Standard-2X, P-M, P-L 1 App Engine $42.984/mo $88.524/mo

    $223.056/mo Memory vCPU 1GB 2 2.5GB 4 14GB $50/mo $250/mo $500/mo Heroku