LoginSignup
22

More than 5 years have passed since last update.

deploy the MVMs of gae / go

Last updated at Posted at 2015-07-10

MVMSのgae/goをdeployするには、dockerが必要だったり、標準のgaeとはapp.yamlの設定が違ったりするので、手順をメモしておく。
だいたい公式の Document の通りだが、微妙にずれているところがあったりする。
特にgae/goはややこしいことになっている。

deploy the MVMs of gae / go

Step1 Install the Google Cloud SDK

gcloudそのもののinstall方法は Document を参照

$ gcloud components update

$ gcloud components update app

Step2 Install Docker

brewなどを利用して、docker, boot2dockerをinstallする
versionは1.4.1以上が必要

$ boot2docker version

boot2dockerが使っているdockerのupdateも忘れずに

$ boot2docker stop
$ boot2docker delete
$ boot2docker download
$ boot2docker init
$ boot2docker start
$ $(boot2docker shellinit)

Document では、MVMs用のDocker imageを先にpullしておくように書いてあるが、今はここにImageが無くて、持ってこれない。
とりあえず、やらなくても大丈夫だった。

$ docker pull gcr.io/google_appengine/python-compat
$ docker pull gcr.io/google_appengine/java-compat
$ docker pull gcr.io/google_appengine/go-compat

Step3 app.yaml

MVMsではapp.yamlからapplication, versionの項目が削除された。

app.yaml
vm: true
runtime: go
api_version: go1

manual_scaling:
  instances: 1
vm_settings:
  machine_type: n1-standard-1
  apt_get_install: redis-server vim

handlers:
- url: /.*
  script: _go_app

Step4 Test and Deploy

本当はgcloudでTestやDeployができるのだけど、goだけできないから、appcfg.pyでdeployします。

$ appcfg.py update -A <application_id> -V <version> --oauth2 <application_root>

localでのTestはどうやるのかなーと思って、適当に試してみたけど、動いてくれなかった・・・。

Option

deployするとDockerfileが生成されるので、カスマイズはこれをいじれば良さそう

# Dockerfile extending the generic Go image with application files for a
# single application.
FROM gcr.io/google_appengine/golang

COPY . /go/src/app
RUN go-wrapper download
RUN go-wrapper install -tags appenginevm

Resource

今回試したソースは Github に置いてる

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22