зеркало из https://github.com/mozilla/kitsune.git
Whitenoise configuration.
* Upgrade to Whitenoise 5.3 * Remove S3 uploads for static assets
This commit is contained in:
Родитель
ba78e9cd2a
Коммит
1d86a3d7ce
|
@ -61,11 +61,6 @@ jobs:
|
|||
docker image push mozilla/kitsune:prod-latest
|
||||
docker logout
|
||||
- aws-cli/setup
|
||||
- run:
|
||||
name: Upload staticfiles
|
||||
command: |
|
||||
source docker/bin/set_git_env_vars.sh
|
||||
./docker/bin/upload-staticfiles.sh
|
||||
- run:
|
||||
name: Echo prod image hash
|
||||
command: |
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -exo pipefail
|
||||
|
||||
GIT_COMMIT=${GIT_COMMIT:-latest}
|
||||
GIT_COMMIT_SHORT=${GIT_COMMIT_SHORT:-$GIT_COMMIT}
|
||||
CONTAINER_NAME="kitsune-static-${GIT_COMMIT}"
|
||||
IMAGE_NAME="mozilla/kitsune:prod-${GIT_COMMIT_SHORT}"
|
||||
TMP_DIR="s3-static"
|
||||
TMP_DIR_HASHED="s3-static-hashed"
|
||||
|
||||
rm -rf "${TMP_DIR}"
|
||||
rm -rf "${TMP_DIR_HASHED}"
|
||||
|
||||
# extract the static files
|
||||
docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}"
|
||||
docker cp "${CONTAINER_NAME}:/app/static" "${TMP_DIR}"
|
||||
docker rm -f "${CONTAINER_NAME}"
|
||||
|
||||
# separate the hashed files into another directory
|
||||
mkdir "${TMP_DIR_HASHED}"
|
||||
find ${TMP_DIR} -maxdepth 1 -type f -regextype sed -regex ".*\.[0-9a-f]\{20\}\..*" -exec mv -t ${TMP_DIR_HASHED} {} +
|
||||
|
||||
for BUCKET in stage prod; do
|
||||
# hashed filenames
|
||||
aws s3 sync \
|
||||
--only-show-errors \
|
||||
--acl public-read \
|
||||
--cache-control "max-age=315360000, public, immutable" \
|
||||
"./${TMP_DIR_HASHED}" "s3://mozit-sumo-${BUCKET}-media/static/"
|
||||
# non-hashed-filenames
|
||||
aws s3 sync \
|
||||
--only-show-errors \
|
||||
--acl public-read \
|
||||
--cache-control "max-age=21600, public" \
|
||||
"./${TMP_DIR}" "s3://mozit-sumo-${BUCKET}-media/static/"
|
||||
done
|
||||
|
||||
rm -rf "${TMP_DIR}"
|
||||
rm -rf "${TMP_DIR_HASHED}"
|
|
@ -90,7 +90,6 @@ app:
|
|||
email_subject_prefix: "[support-dev] "
|
||||
email_use_tls: True
|
||||
enable_admin: True
|
||||
enable_whitenoise: True
|
||||
enforce_host: "dev.sumo.mozit.cloud,support-dev.allizom.org"
|
||||
engage_robots: False
|
||||
es_index_prefix: "sumo_dev"
|
||||
|
|
|
@ -86,7 +86,6 @@ app:
|
|||
email_port: 25
|
||||
email_use_tls: True
|
||||
enable_admin: False
|
||||
enable_whitenoise: True
|
||||
enforce_host: "support.mozilla.org,prod-frankfurt.sumo.mozit.cloud"
|
||||
engage_robots: True
|
||||
es_index_prefix: "sumo_prod"
|
||||
|
|
|
@ -89,7 +89,6 @@ app:
|
|||
email_port: 25
|
||||
email_use_tls: True
|
||||
enable_admin: False
|
||||
enable_whitenoise: True
|
||||
engage_robots: False
|
||||
es_index_prefix: "sumo_stage"
|
||||
es_live_indexing: True
|
||||
|
|
|
@ -89,7 +89,6 @@ app:
|
|||
email_subject_prefix: "[support-test] "
|
||||
email_use_tls: True
|
||||
enable_admin: True
|
||||
enable_whitenoise: True
|
||||
enforce_host: "test.sumo.mozit.cloud,support-test.allizom.org"
|
||||
engage_robots: False
|
||||
es_index_prefix: "sumo_dev"
|
||||
|
|
|
@ -89,7 +89,6 @@ app:
|
|||
email_port: 25
|
||||
email_use_tls: True
|
||||
enable_admin: True
|
||||
enable_whitenoise: True
|
||||
engage_robots: False
|
||||
es_index_prefix: "sumo_stage"
|
||||
es_live_indexing: True
|
||||
|
|
|
@ -410,7 +410,7 @@ STATICFILES_FINDERS = (
|
|||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
)
|
||||
|
||||
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
|
||||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
|
||||
WEBPACK_LRU_CACHE = 128
|
||||
if DEV or TEST:
|
||||
|
@ -499,6 +499,7 @@ MIDDLEWARE = (
|
|||
"allow_cidr.middleware.AllowCIDRMiddleware",
|
||||
"kitsune.sumo.middleware.FilterByUserAgentMiddleware",
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"commonware.request.middleware.SetRemoteAddrFromForwardedFor",
|
||||
"kitsune.sumo.middleware.EnforceHostIPMiddleware",
|
||||
|
|
13
wsgi/app.py
13
wsgi/app.py
|
@ -13,24 +13,19 @@ try:
|
|||
except ImportError:
|
||||
newrelic = False
|
||||
else:
|
||||
newrelic.agent.initialize('newrelic.ini')
|
||||
newrelic.agent.initialize("newrelic.ini")
|
||||
|
||||
import os
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kitsune.settings') # NOQA
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kitsune.settings") # NOQA
|
||||
|
||||
from decouple import config
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
||||
if config('ENABLE_WHITENOISE', default=False, cast=bool):
|
||||
from whitenoise.django import DjangoWhiteNoise
|
||||
application = DjangoWhiteNoise(application)
|
||||
|
||||
# Add NewRelic
|
||||
if newrelic:
|
||||
newrelic_license_key = config('NEW_RELIC_LICENSE_KEY', default=None)
|
||||
newrelic_license_key = config("NEW_RELIC_LICENSE_KEY", default=None)
|
||||
if newrelic_license_key:
|
||||
application = newrelic.agent.WSGIApplicationWrapper(application)
|
||||
|
|
Загрузка…
Ссылка в новой задаче