Skip to content

Commit

Permalink
enabling minio object storage
Browse files Browse the repository at this point in the history
  • Loading branch information
qtrinh2 committed Sep 26, 2024
1 parent d21cb04 commit 428ee78
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
21 changes: 19 additions & 2 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"storages",
"allauth",
"allauth.account",
"allauth.socialaccount",
Expand Down Expand Up @@ -180,8 +181,24 @@
STATIC_URL = "static/"
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
MEDIA_URL = "media/"
MEDIA_ROOT = BASE_DIR / "media"

# Media files
OBJ_STORAGE = env("OBJ_STORAGE", default=False)
if OBJ_STORAGE:
AWS_ACCESS_KEY_ID = env("OBJ_STORAGE_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = env("OBJ_STORAGE_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = env("OBJ_STORAGE_BUCKET_NAME")
AWS_S3_ENDPOINT_URL = env("OBJ_STORAGE_ENDPOINT_URL")

MEDIA_URL = f"{AWS_S3_ENDPOINT_URL}/{AWS_STORAGE_BUCKET_NAME}/"

# override default storage backend for media
STORAGES["default"] = {
"BACKEND": "storages.backends.s3.S3Storage",
}
else:
MEDIA_URL = "media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")


# Wagtail
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ services:
- DB_NAME=connthreads
- DB_USER=connthreads
- DB_PASS=password
- OBJ_STORAGE=True
- OBJ_STORAGE_ACCESS_KEY_ID=connthreads-dev-key
- OBJ_STORAGE_SECRET_ACCESS_KEY=connthreads-secret-key
- OBJ_STORAGE_BUCKET_NAME=connthreads-dev
- OBJ_STORAGE_ENDPOINT_URL=https://obj.rrchnm.org
command: >
sh -c "
poetry run python manage.py migrate &&
Expand Down
28 changes: 26 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ geopy = "^2.4.1"
django-tables2 = "^2.7.0"
django-filter = "^24.2"
fontawesomefree = "^6.6.0"
django-storages = "^1.14.4"


[tool.poetry.group.dev.dependencies]
Expand Down

0 comments on commit 428ee78

Please sign in to comment.