Current section
Files
Jump to
Current section
Files
priv/templates/deploy-sync-config-s3.eex
#!/usr/bin/env bash
# Sync config files from S3 bucket to app config dir
set -e
# Config vars
export LANG="<%= env_lang %>"
CONFIG_DIR="<%= configuration_dir %>"
APP_USER="${APP_USER:-<%= app_user %>}"
APP_GROUP="${APP_USER:-<%= app_group %>}"
# Env vars
# CONFIG_S3_BUCKET: bucket name
# CONFIG_S3_PREFIX: optional path in prefix
# DESTDIR, prefix for target files, optional
umask 700
# It may be better to explicitly copy files one by one
aws s3 sync "s3://${CONFIG_S3_BUCKET}/${CONFIG_S3_PREFIX}" "${DESTDIR}${CONFIG_DIR}/"
chown $APP_USER:$APP_GROUP ${DESTDIR}$CONFIG_DIR/*
chmod 600 ${DESTDIR}$CONFIG_DIR/*