1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker-composeでs3 bucketをつくる

Posted at

s3を使ったアプリケーションの開発用にローカルでlocalstackやminio等を使う場合に
docker-compose内でs3 bucketをつくる

最終

localstackの場合

services:
  storage_init:
    image: maruware/awscli-wait-for-it
    environment:
      - AWS_DEFAULT_REGION=ap-northeast-1
      - AWS_DEFAULT_OUTPUT=json
      - AWS_ACCESS_KEY_ID=access
      - AWS_SECRET_ACCESS_KEY=secretsecret
    depends_on:
      - localstack
    entrypoint: >
      /wait-for-it.sh localstack:4572 -- 
        bash -c "aws --endpoint-url=http://localstack:4572 s3api head-bucket --bucket bucket || 
        aws --endpoint-url=http://localstack:4572 s3 mb s3://bucket/"

経過

localstackでS3をモックした - 勉強日記

今までアプリケーション内で分岐してBucketをつくっていたけど、上記で見かけて良さそうだったので参考に。
volumeのマウントとかめんどくさいのでimage内にwait-for-it.shも入れた

Bucketがないときだけ登録したいのでhead-bucketをはさむようにした。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?