Created
August 9, 2017 13:35
-
-
Save kotauchisunsun/e19dd56bdc832da380f2516f4eb63bf9 to your computer and use it in GitHub Desktop.
サーバーレスの入門に!自宅サーバーレス+自宅S3環境で作るサーバーレス・サムネイルサーバー! ref: http://qiita.com/kotauchisunsun/items/856e7ecb65bb06f85ffa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# minioを起動 | |
$ sudo docker run --rm -p 8080:9000 -it \ | |
-e MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE\ | |
-e MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\ | |
minio/minio server /export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# minioへimagesバケットの作成 | |
$ aws --endpoint-url http://192.168.0.6:8080 s3 mb s3://images | |
# minioへthumbsバケットの作成 | |
$ aws --endpoint-url http://192.168.0.6:8080 s3 mb s3://thumbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iron-functionsのサービス | |
$ sudo docker run --rm -it --name functions -v ${PWD}/data:/app/data \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
-p 8000:8080 iron/functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ソースコードをクローン | |
$ git clone https://github.com/kotauchisunsun/iron_thumbs.git | |
$ cd iron_thumbs | |
# パッケージの依存関係を解消 | |
$ glide update | |
$ sudo fn build | |
$ fn apps create iron_thumbs \ | |
--config IMAGE_BUCKET=images\ | |
--config THUMB_BUCKET=thumbs\ | |
--config S3_ENDPOINT=http://192.168.0.6:8080\ | |
--config S3_REGION=us-east-1\ | |
--config S3_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE\ | |
--config S3_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY | |
$ fn routes create iron_thumbs /thumbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 素材をダウンロード | |
$ wget "http://4.bp.blogspot.com/-dVbfTZcofUU/VGX8crT5GiI/AAAAAAAApG4/CB7GF5UmMqE/s400/computer_cloud_system.png" | |
# minioにファイルをアップロード | |
$ aws --endpoint-url http://192.168.0.6:8080 s3 cp computer_cloud_system.png s3://images/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl "http://localhost:8000/r/iron_thumbs/thumbs?filename=computer_cloud_system.png&size=180" > thumbs.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ab -n 1000 -c 10 "http://localhost:8000/r/iron_thumbs/thumbs?filename=computer_cloud_system.png&size=180" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment