LoginSignup
4
2

More than 5 years have passed since last update.

ローカルでGAE GoをDocker Composeで動かす

Posted at

ローカルでGAE(Standard Environment) GoをDocker Composeで動かすメモ。

Docker Hubにgoogle/cloud-sdkがあり、これにもdev_appserver.pyコマンドなど入ってるけど、depが効かないので、golangをベースにgcloud SDKを入れるDockerfileを作った。

なお、GoのバージョンはGAEのStandard Environmentで使えるものを確認して使う(2018年7月17日現在は1.9
https://cloud.google.com/appengine/docs/standard/go/release-notes

まずはDockerfileを作る

Dockerfile
FROM golang:1.9.7

RUN export CLOUD_SDK_REPO="cloud-sdk-stretch" && \
    echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
    apt-get update -y && apt-get install google-cloud-sdk google-cloud-sdk-app-engine-go -y

WORKDIR /go/src/path/to/project
EXPOSE 8080 8000

docker-compose.yamlはこんな感じ
ポイントは--host--admin_host0.0.0.0してあげること

docker-compose.yaml
version: "3.6"

services:
  api:
    build:
      context: .
    volumes:
      - .:/go/src/path/to/project
    ports:
      - 8080:8080
      - 8000:8000
    command: dev_appserver.py ./app/app.yaml --host 0.0.0.0 --admin_host 0.0.0.0 --datastore_path .datastore
4
2
0

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
4
2