forked from mozilla/kitsune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-staticfiles.sh
executable file
·38 lines (31 loc) · 1.11 KB
/
upload-staticfiles.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
set -exo pipefail
DOCKER_REPO=${DOCKER_REPO:-itsre/sumo-kitsune}
GIT_COMMIT=${GIT_COMMIT:-latest}
GIT_COMMIT_SHORT=${GIT_COMMIT_SHORT:-$GIT_COMMIT}
CONTAINER_NAME="kitsune-static-${GIT_COMMIT}"
IMAGE_NAME="${DOCKER_REPO}:full-${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
docker/bin/move_hashed_staticfiles.py "${TMP_DIR}" "${TMP_DIR_HASHED}"
for BUCKET in stage prod; do
# hashed filenames
aws s3 sync \
--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 \
--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}"