🇯🇵 🇺🇸
simple_server/
ディレクトリ
cd simple_server
docker build .
docker run -p 8080:8080 [DOCKER_IMAGE]
curl -XGET -H 'Content-Type:application/json' http://localhost:8080/
response:
{"message":"Hello World!!"}
http://35.247.11.48:8080/ (一定期間後削除)
- Cloud Build を利用してDockerイメージをアップロード
- GCPのリファレンス
Dockerfileによるビルド
gcloud builds submit --tag gcr.io/[PROJECT_ID]/[DOCKER_IMAGE] .
- Kubernetes Engine > クラスタ タブで「コンテナをデプロイ」から上記でpushしたDockerイメージを選択
- ワークロード タブで「サービスの公開」からロードバランサを有効化、ポート番号8080に設定
restful_server/
ディレクトリ
cd restful_server
docker-compose build
docker-compose up
curl -XGET -H 'Content-Type:application/json' http://localhost:8080/users
curl -XGET -H 'Content-Type:application/json' http://localhost:8080/users/1
curl -XPOST -H 'Content-Type:application/json' http://localhost:8080/users -d '{ "name": "test", "email": "[email protected]" }'
curl -XPUT -H 'Content-Type:application/json' http://localhost:8080/users/1 -d '{ "name": "test2", "email": "[email protected]" }'
curl -XDELETE -H 'Content-Type:application/json' http://localhost:8080/users/1