Skip to content

Instantly share code, notes, and snippets.

@wasnot
Created December 6, 2016 01:56
Show Gist options
  • Save wasnot/48358f0d2c7e1d793020f7a5d8d1d676 to your computer and use it in GitHub Desktop.
Save wasnot/48358f0d2c7e1d793020f7a5d8d1d676 to your computer and use it in GitHub Desktop.
DockerのイメージをGAE/FEにデプロイする ref: http://qiita.com/wasnot/items/b8691bb4940e6f4a9c24
from bottle import Bottle
app = Bottle()
@app.route(['/hello', '/'])
def hello():
return "Hello World!"
@app.route("/_ah/health")
def _ah_health():
return "ok"
if __name__ == '__main__':
# waiting request
app.run(host='0.0.0.0', port=8080, debug=True)
# 自動生成部分
entrypoint: python app.py
runtime: custom
vm: true
# もしモジュール(サービス)を分割する場合は指定しておく
service: flex
# オートスケーリングだとデフォルト2台待機なので少なくしたりする
automatic_scaling:
min_num_instances: 1
max_num_instances: 20
# マシンタイプはデフォルトミニマムなので適宜指定。これは下から二つ目。
resources:
cpu: .5
memory_gb: 3
$ gcloud beta app gen-config
FROM gcr.io/google_appengine/python:1.3
# ここではpython2.7が指定されています。
RUN virtualenv /env -p python
# Set virtualenv environment variables. This is equivalent to running
# source /env/bin/activate
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
ADD . /app/
# こんなのを加えるとスムーズに環境構築されると思います。
RUN pip install -r requirements.txt
CMD python app.py
$ gcloud beta app deploy --project my-project --version flex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment