Created
November 2, 2024 01:54
-
-
Save douglasmiranda/7f67d844274be91e6985fb64d537b0e1 to your computer and use it in GitHub Desktop.
Minio as S3 storage for Django + Django Storages setup
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
services: | |
django: | |
# setup django container ... | |
# Storage | |
minio: | |
image: minio/minio:latest | |
ports: | |
- 9000:9000 | |
- 9001:9001 | |
command: server /data --console-address ":9001" | |
volumes: | |
- minio_data:/data | |
env_file: | |
- minio.env | |
# Minio auto setup | |
minio-client: | |
image: minio/mc:latest | |
entrypoint: | | |
/bin/sh -c " | |
/usr/bin/mc config host add --quiet --api s3v4 s3 http://minio:9000 $${MINIO_ROOT_USER} $${MINIO_ROOT_PASSWORD}; | |
/usr/bin/mc mb --quiet s3/$${STORAGE_BUCKET_NAME}; | |
/usr/bin/mc admin user add s3 "$${STORAGE_ACCESS_KEY}" "$${STORAGE_SECRET_KEY}"; | |
/usr/bin/mc admin policy attach s3 readwrite --user "$${STORAGE_ACCESS_KEY}"; | |
/usr/bin/mc anonymous set download s3/$${STORAGE_BUCKET_NAME}; | |
" | |
depends_on: | |
- minio | |
env_file: | |
- minio.env |
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
# https://min.io/docs/minio/linux/reference/minio-server/minio-server.html#id5 | |
MINIO_ROOT_USER=admin | |
MINIO_ROOT_PASSWORD=12345678 | |
STORAGE_BUCKET_NAME=media | |
# Development credentials for storing files locally | |
STORAGE_ACCESS_KEY=dev_key | |
STORAGE_SECRET_KEY=dev_secret |
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
... | |
STORAGES["default"] = { | |
"BACKEND": "storages.backends.s3.S3Storage", | |
} | |
AWS_ACCESS_KEY_ID = "dev_key" | |
AWS_SECRET_ACCESS_KEY = "dev_secret" | |
AWS_STORAGE_BUCKET_NAME = "media" | |
# Send files to your minio container instead of aws | |
AWS_S3_ENDPOINT_URL = "http://minio:9000" | |
# your minio inside the docker container would write the url in the context | |
# of the contaiener, so override with: | |
AWS_S3_CUSTOM_DOMAIN = "localhost:9000/media" | |
AWS_S3_URL_PROTOCOL = "http:" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment