Ready for initial testing
This commit is contained in:
parent
54804bb2e2
commit
4f84948785
11 changed files with 714 additions and 975 deletions
|
@ -1,336 +0,0 @@
|
|||
#########################################################################################
|
||||
# Saleor_Production_Deployment.sh
|
||||
# Author: Aaron K. Nall http://github.com/thewhiterabbit
|
||||
#########################################################################################
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Get the actual user that logged in
|
||||
UN="$(who am i | awk '{print $1}')"
|
||||
if [[ "$UN" != "root" ]]; then
|
||||
HD="/home/$UN"
|
||||
else
|
||||
HD="/root"
|
||||
fi
|
||||
|
||||
while [ -n "$1" ]; do # while loop starts
|
||||
case "$1" in
|
||||
-name)
|
||||
DEPLOYED_NAME="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-host)
|
||||
API_HOST="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-uri)
|
||||
APP_MOUNT_URI="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-url)
|
||||
STATIC_URL="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-dbhost)
|
||||
PGDBHOST="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-dbport)
|
||||
DBPORT="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-v)
|
||||
vOPT="true"
|
||||
VERSION="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Option $1 is invalid."
|
||||
echo "Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
#########################################################################################
|
||||
# Select Operating System specific commands
|
||||
# Tested working on Ubuntu Server 20.04
|
||||
# Needs testing on the distributions listed below
|
||||
# Debian
|
||||
# Fedora CoreOS
|
||||
# Kubernetes
|
||||
# SUSE CaaS
|
||||
IN=$(uname -a)
|
||||
arrIN=(${IN// / })
|
||||
IN2=${arrIN[3]}
|
||||
arrIN2=(${IN2//-/ })
|
||||
OS=${arrIN2[1]}
|
||||
echo ""
|
||||
echo "$OS detected"
|
||||
echo ""
|
||||
sleep 3
|
||||
echo "Installing core dependencies..."
|
||||
# For future use to setup Operating System specific commands
|
||||
case "$OS" in
|
||||
Debian)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential python3-dev python3-pip python3-cffi python3-venv
|
||||
sudo python3 -m pip install --upgrade pip
|
||||
sudo apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
|
||||
sudo apt-get install -y nodejs npm postgresql postgresql-contrib
|
||||
;;
|
||||
|
||||
Fedora)
|
||||
;;
|
||||
|
||||
Kubernetes)
|
||||
;;
|
||||
|
||||
SUSE)
|
||||
;;
|
||||
|
||||
Ubuntu)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential python3-dev python3-pip python3-cffi python3-venv
|
||||
sudo python3 -m pip install --upgrade pip
|
||||
sudo apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
|
||||
sudo apt-get install -y nodejs npm postgresql postgresql-contrib
|
||||
;;
|
||||
|
||||
*)
|
||||
# Unsupported distribution detected, exit
|
||||
echo "Unsupported Linix distribution detected."
|
||||
echo "Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
#########################################################################################
|
||||
|
||||
# Tell the user what's happening
|
||||
echo ""
|
||||
echo "Finished installing core dependencies"
|
||||
echo ""
|
||||
sleep 3
|
||||
echo "Setting up security feature details..."
|
||||
echo ""
|
||||
|
||||
# Create randomized 2049 byte keyfile
|
||||
sudo mkdir /etc/saleor
|
||||
|
||||
echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2048| head -n 1)>/etc/saleor/api_sk
|
||||
# Set variables for the password, obfuscation string, and user/database names
|
||||
OBFSTR=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8| head -n 1)
|
||||
PGSQLUSERPASS=$(cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 128 | head -n 1)
|
||||
PGSQLDBNAME="saleor_db_$OBFSTR"
|
||||
PGSQLUSER="saleor_dbu_$OBFSTR"
|
||||
|
||||
# Tell the user what's happening
|
||||
echo "Finished setting up security feature details"
|
||||
echo ""
|
||||
sleep 1
|
||||
echo "Creating database..."
|
||||
echo ""
|
||||
|
||||
# Create a superuser for Saleor
|
||||
|
||||
sudo -i -u postgres psql -c "CREATE ROLE $PGSQLUSER PASSWORD '$PGSQLUSERPASS' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;"
|
||||
sudo -i -u postgres psql -c "CREATE DATABASE $PGSQLDBNAME;"
|
||||
# TODO - Secure the postgers user account
|
||||
|
||||
# Tell the user what's happening
|
||||
echo "Finished creating database"
|
||||
echo ""
|
||||
sleep 3
|
||||
echo "Please provide details for your instillation..."
|
||||
echo ""
|
||||
|
||||
# Ask for the API host IP or domain
|
||||
while [ "$HOST" = "" ]
|
||||
do
|
||||
echo -n "Enter the Dashboard & GraphQL host domain:"
|
||||
read HOST
|
||||
done
|
||||
|
||||
while [ "$API_HOST" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the API host IP or domain:"
|
||||
read API_HOST
|
||||
done
|
||||
|
||||
# Ask for the API port
|
||||
echo -n "Enter the API port (optional):"
|
||||
read API_PORT
|
||||
|
||||
# Ask for the API Mount URI
|
||||
while [ "$APP_MOUNT_URI" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the Dashboard URI:"
|
||||
read APP_MOUNT_URI
|
||||
done
|
||||
|
||||
# Ask for the Static URL
|
||||
echo -n "Enter the Static URL:"
|
||||
read STATIC_URL
|
||||
|
||||
# Ask for the Static URL
|
||||
while [ "$EMAIL" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the Dashboard admin's email:"
|
||||
read EMAIL
|
||||
done
|
||||
|
||||
# Ask for the Static URL
|
||||
while [ "$PASSW" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the Dashboard admin's desired password:"
|
||||
read PASSW
|
||||
done
|
||||
|
||||
# Use set parameters for Database or fall back to defaults
|
||||
if [ "$PGDBHOST" = "" ]; then
|
||||
PGDBHOST="localhost"
|
||||
fi
|
||||
|
||||
if [ "$DBPORT" = "" ]; then
|
||||
DBPORT="5432"
|
||||
fi
|
||||
|
||||
if [[ "$GQL_PORT" = "" ]]; then
|
||||
GQL_PORT="9000"
|
||||
fi
|
||||
|
||||
if [[ "$API_PORT" = "" ]]; then
|
||||
API_PORT="8000"
|
||||
fi
|
||||
|
||||
if [ "$APIURI" = "" ]; then
|
||||
APIURI="graphql"
|
||||
fi
|
||||
|
||||
if [ "vOPT" = "true" ]; then
|
||||
if [ "$VERSION" = "" ]; then
|
||||
VERSION="2.11.1"
|
||||
fi
|
||||
fi
|
||||
|
||||
sudo ufw allow $GQL_PORT
|
||||
sudo ufw allow $API_PORT
|
||||
|
||||
# Here goes nothing
|
||||
cd $HD
|
||||
if [ "vOPT" = "true" ]; then
|
||||
git clone https://github.com/mirumee/saleor.git
|
||||
else
|
||||
git clone https://github.com/thewhiterabbit/saleor.git
|
||||
fi
|
||||
wait
|
||||
cd saleor
|
||||
if [ "vOPT" = "true" ]; then
|
||||
sudo sed "s|{hd}|$HD|
|
||||
s/{hostip}/$API_HOST/" $HD/saleor/resources/saleor.service > /etc/systemd/system/saleor.service
|
||||
wait
|
||||
|
||||
sudo sed "s|{hd}|$HD|
|
||||
s/{api_host}/$API_HOST/
|
||||
s/{host}/$HOST/g
|
||||
s/{apiport}/$API_PORT/" $HD/saleor/resources/server_block > /etc/nginx/sites-available/saleor
|
||||
wait
|
||||
|
||||
sudo sed -i "s/{\"email\": \"admin@example.com\", \"password\": \"admin\"}/{\"email\": \"$EMAIL\", \"password\": \"$PASSW\"}/" $HD/saleor/saleor/core/management/commands/populatedb.py
|
||||
wait
|
||||
|
||||
sudo sed -i "s/{\"email\": \"admin@example.com\", \"password\": \"admin\"}/{\"email\": \"$EMAIL\", \"password\": \"$PASSW\"}/" $HD/saleor/saleor/core/tests/test_core.py
|
||||
wait
|
||||
|
||||
sudo sed -i "s|SECRET_KEY = os.environ.get(\"SECRET_KEY\")|with open('/etc/saleor/api_sk') as f: SECRET_KEY = f.read().strip()|" $HD/saleor/saleor/settings.py
|
||||
wait
|
||||
else
|
||||
sudo sed "s|{hd}|$HD|
|
||||
s/{hostip}/$API_HOST/" $HD/saleor/resources/saleor.service > /etc/systemd/system/saleor.service
|
||||
wait
|
||||
|
||||
sudo sed "s|{hd}|$HD|
|
||||
s/{api_host}/$API_HOST/
|
||||
s/{host}/$HOST/g
|
||||
s/{apiport}/$API_PORT/" $HD/saleor/resources/server_block > /etc/nginx/sites-available/saleor
|
||||
wait
|
||||
|
||||
sudo sed -i "s/{email}/$EMAIL/
|
||||
s/{passw}/$PASSW/" $HD/saleor/saleor/core/management/commands/populatedb.py
|
||||
wait
|
||||
|
||||
sudo sed -i "s/{email}/$EMAIL/
|
||||
s/{passw}/$PASSW/" $HD/saleor/saleor/core/tests/test_core.py
|
||||
wait
|
||||
fi
|
||||
|
||||
# Tell the user what's happening
|
||||
echo "Creating production deployment packages for Saleor API & GraphQL..."
|
||||
echo ""
|
||||
|
||||
DB_URL="postgres://$PGSQLUSER:$PGSQLUSERPASS@$PGDBHOST:$DBPORT/$PGSQLDBNAME"
|
||||
|
||||
if [ "vOPT" = "true" ]; then
|
||||
git checkout $VERSION
|
||||
fi
|
||||
python3 -m venv $HD/saleor/venv
|
||||
source $HD/saleor/venv/bin/activate
|
||||
pip3 install -r requirements.txt
|
||||
export DATABASE_URL=$DB_URL
|
||||
npm install
|
||||
npm audit fix
|
||||
python3 manage.py migrate
|
||||
python3 manage.py collectstatic
|
||||
npm run build-schema
|
||||
npm run build-emails
|
||||
|
||||
sudo touch /etc/init.d/saleor
|
||||
sudo chmod +x /etc/init.d/saleor
|
||||
sudo update-rc.d saleor defaults
|
||||
|
||||
APIURL="http://$API_HOST:$API_PORT/$APIURI/"
|
||||
|
||||
# Tell the user what's happening
|
||||
echo "Finished creating production deployment packages for Saleor API & GraphQL"
|
||||
echo""
|
||||
sleep 3
|
||||
echo "Creating production deployment packages for Saleor Dashboard..."
|
||||
echo ""
|
||||
|
||||
# Missing some things here as well
|
||||
cd $HD
|
||||
git clone https://github.com/mirumee/saleor-dashboard.git
|
||||
wait
|
||||
cd saleor-dashboard
|
||||
|
||||
if [ "vOPT" = "true" ]; then
|
||||
git checkout $VERSION
|
||||
fi
|
||||
npm i
|
||||
export API_URI=$APIURL
|
||||
export APP_MOUNT_URI=$APP_MOUNT_URI
|
||||
if [[ "$STATIC_URL" != "" ]]; then
|
||||
export STATIC_URL=$STATIC_URL
|
||||
fi
|
||||
npm run build
|
||||
|
||||
echo "Restarting nginx..."
|
||||
sudo ln -s /etc/nginx/sites-available/saleor /etc/nginx/sites-enabled/
|
||||
sudo systemctl restart nginx
|
||||
sleep 3
|
||||
|
||||
echo "I think we're done here."
|
||||
echo "Test the installation."
|
||||
echo "Run python3 manage.py createsuperuser from $HD/saleor"
|
93
deploy-dashboard.sh
Normal file
93
deploy-dashboard.sh
Normal file
|
@ -0,0 +1,93 @@
|
|||
|
||||
#########################################################################################
|
||||
echo ""
|
||||
echo "Creating production deployment packages for Saleor Dashboard..."
|
||||
echo ""
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Collect input from the user to assign required installation parameters
|
||||
#########################################################################################
|
||||
echo "Please provide details for your Saleor API instillation..."
|
||||
echo ""
|
||||
# Get the Dashboard & GraphQL host domain
|
||||
while [ "$HOST" = "" ]
|
||||
do
|
||||
echo -n "Enter the Dashboard & GraphQL host domain:"
|
||||
read HOST
|
||||
done
|
||||
# Get the API host IP or domain
|
||||
while [ "$API_HOST" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the API host IP or domain:"
|
||||
read API_HOST
|
||||
done
|
||||
# Get the APP Mount (Dashboard) URI
|
||||
while [ "$APP_MOUNT_URI" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the APP Mount (Dashboard) URI:"
|
||||
read APP_MOUNT_URI
|
||||
done
|
||||
# Get an optional custom API port
|
||||
echo -n "Enter the API port (optional):"
|
||||
read API_PORT
|
||||
#
|
||||
if [[ "$API_PORT" = "" ]]; then
|
||||
API_PORT="8000"
|
||||
fi
|
||||
#
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Setup the environment variables for Saleor API
|
||||
#########################################################################################
|
||||
# Build the API URL
|
||||
APIURL="http://$API_HOST:$API_PORT/$APIURI/"
|
||||
# Write the production .env file from template.env
|
||||
sudo sed "s|{apiuri}|$APIURL|
|
||||
s|{mounturi}|$APP_MOUNT_URI|
|
||||
s|{url}|$HOST|" $HD/Deploy_Saleor/resources/saleor-dashboard/template.env > $HD/saleor-dashboard/.env
|
||||
wait
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Build Saleor Dashboard for production
|
||||
#########################################################################################
|
||||
# Make sure we're in the user's home directory
|
||||
cd $HD
|
||||
# Clone the Saleor Dashboard Git repository
|
||||
if [ -f "$HD/saleor-dashboard" ]; then
|
||||
sudo rm -R $HD/saleor-dashboard
|
||||
fi
|
||||
git clone https://github.com/mirumee/saleor-dashboard.git
|
||||
wait
|
||||
# Make sure we're in the project root directory
|
||||
cd saleor-dashboard
|
||||
# Was the -v (version) option used?
|
||||
if [ "vOPT" = "true" ]; then
|
||||
git checkout $VERSION
|
||||
fi
|
||||
# Install dependancies
|
||||
npm i
|
||||
wait
|
||||
npm run build
|
||||
wait
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Tell the user what's happening
|
||||
#########################################################################################
|
||||
echo "I think we're done here."
|
||||
echo "Test the installation."
|
||||
echo "Run python3 manage.py createsuperuser from $HD/saleor"
|
||||
#########################################################################################
|
535
deploy-saleor.sh
Normal file
535
deploy-saleor.sh
Normal file
|
@ -0,0 +1,535 @@
|
|||
#########################################################################################
|
||||
# Saleor_Production_Deployment.sh
|
||||
# Author: Aaron K. Nall http://github.com/thewhiterabbit
|
||||
#########################################################################################
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
#########################################################################################
|
||||
# Get the actual user that logged in
|
||||
#########################################################################################
|
||||
UN="$(who am i | awk '{print $1}')"
|
||||
if [[ "$UN" != "root" ]]; then
|
||||
HD="/home/$UN"
|
||||
else
|
||||
HD="/root"
|
||||
fi
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Get the operating system
|
||||
#########################################################################################
|
||||
IN=$(uname -a)
|
||||
arrIN=(${IN// / })
|
||||
IN2=${arrIN[3]}
|
||||
arrIN2=(${IN2//-/ })
|
||||
OS=${arrIN2[1]}
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Parse options
|
||||
#########################################################################################
|
||||
while [ -n "$1" ]; do # while loop starts
|
||||
case "$1" in
|
||||
-name)
|
||||
DEPLOYED_NAME="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-host)
|
||||
API_HOST="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-uri)
|
||||
APP_MOUNT_URI="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-url)
|
||||
STATIC_URL="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-dbhost)
|
||||
PGDBHOST="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-dbport)
|
||||
DBPORT="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-repo)
|
||||
REPO="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
-v)
|
||||
vOPT="true"
|
||||
VERSION="$2"
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Option $1 is invalid."
|
||||
echo "Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Echo the detected operating system
|
||||
#########################################################################################
|
||||
echo ""
|
||||
echo "$OS detected"
|
||||
echo ""
|
||||
sleep 3
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Select/run Operating System specific commands
|
||||
#########################################################################################
|
||||
# Tested working on Ubuntu Server 20.04
|
||||
# Needs testing on the distributions listed below:
|
||||
# Debian
|
||||
# Fedora CoreOS
|
||||
# Kubernetes
|
||||
# SUSE CaaS
|
||||
echo "Installing core dependencies..."
|
||||
case "$OS" in
|
||||
Debian)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential python3-dev python3-pip python3-cffi python3-venv gcc
|
||||
sudo apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
|
||||
sudo apt-get install -y nodejs npm postgresql postgresql-contrib
|
||||
;;
|
||||
|
||||
Fedora)
|
||||
;;
|
||||
|
||||
Kubernetes)
|
||||
;;
|
||||
|
||||
SUSE)
|
||||
;;
|
||||
|
||||
Ubuntu)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential python3-dev python3-pip python3-cffi python3-venv gcc
|
||||
sudo apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
|
||||
sudo apt-get install -y nodejs npm postgresql postgresql-contrib
|
||||
;;
|
||||
|
||||
*)
|
||||
# Unsupported distribution detected, exit
|
||||
echo "Unsupported Linix distribution detected."
|
||||
echo "Exiting"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Tell the user what's happening
|
||||
#########################################################################################
|
||||
echo ""
|
||||
echo "Finished installing core dependencies"
|
||||
echo ""
|
||||
sleep 3
|
||||
echo "Setting up security feature details..."
|
||||
echo ""
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Generate a secret key file
|
||||
#########################################################################################
|
||||
# Does the key file directory exiet?
|
||||
if [ ! -d "/etc/saleor" ]; then
|
||||
sudo mkdir /etc/saleor
|
||||
else
|
||||
# Does the key file exist?
|
||||
if [ -f "/etc/saleor/api_sk" ]; then
|
||||
# Yes, remove it.
|
||||
sudo rm /etc/saleor/api_sk
|
||||
fi
|
||||
fi
|
||||
# Create randomized 2049 byte key file
|
||||
sudo echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2048| head -n 1) > /etc/saleor/api_sk
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Set variables for the password, obfuscation string, and user/database names
|
||||
#########################################################################################
|
||||
# Generate an 8 byte obfuscation string for the database name & username
|
||||
OBFSTR=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 8| head -n 1)
|
||||
# Append the database name for Saleor with the obfuscation string
|
||||
PGSQLDBNAME="saleor_db_$OBFSTR"
|
||||
# Append the database username for Saleor with the obfuscation string
|
||||
PGSQLUSER="saleor_dbu_$OBFSTR"
|
||||
# Generate a 128 byte password for the Saleor database user
|
||||
# TODO: Add special characters once we know which ones won't crash the python script
|
||||
PGSQLUSERPASS=$(cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 128 | head -n 1)
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Tell the user what's happening
|
||||
#########################################################################################
|
||||
echo "Finished setting up security feature details"
|
||||
echo ""
|
||||
sleep 1
|
||||
echo "Creating database..."
|
||||
echo ""
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Create a superuser for Saleor
|
||||
#########################################################################################
|
||||
# Create the role in the database and assign the generated password
|
||||
sudo -i -u postgres psql -c "CREATE ROLE $PGSQLUSER PASSWORD '$PGSQLUSERPASS' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;"
|
||||
# Create the database for Saleor
|
||||
sudo -i -u postgres psql -c "CREATE DATABASE $PGSQLDBNAME;"
|
||||
# TODO - Secure the postgers user account
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Tell the user what's happening
|
||||
#########################################################################################
|
||||
echo "Finished creating database"
|
||||
echo ""
|
||||
sleep 3
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Collect input from the user to assign required installation parameters
|
||||
#########################################################################################
|
||||
echo "Please provide details for your Saleor API instillation..."
|
||||
echo ""
|
||||
# Get the Dashboard & GraphQL host domain
|
||||
while [ "$HOST" = "" ]
|
||||
do
|
||||
echo -n "Enter the Dashboard & GraphQL host domain:"
|
||||
read HOST
|
||||
done
|
||||
# Get the API host IP or domain
|
||||
while [ "$API_HOST" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the API host IP or domain:"
|
||||
read API_HOST
|
||||
done
|
||||
# Get an optional custom API port
|
||||
echo -n "Enter the API port (optional):"
|
||||
read API_PORT
|
||||
# Get the APP Mount (Dashboard) URI
|
||||
while [ "$APP_MOUNT_URI" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the Dashboard URI:"
|
||||
read APP_MOUNT_URI
|
||||
done
|
||||
# Get an optional custom Static URL
|
||||
echo -n "Enter a custom Static Files URI (optional):"
|
||||
read STATIC_URL
|
||||
# Get the Admin's email address
|
||||
while [ "$EMAIL" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the Dashboard admin's email:"
|
||||
read EMAIL
|
||||
done
|
||||
# Get the Admin's desired password
|
||||
while [ "$PASSW" = "" ]
|
||||
do
|
||||
echo ""
|
||||
echo -n "Enter the Dashboard admin's desired password:"
|
||||
read -s PASSW
|
||||
done
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Set default and optional parameters
|
||||
#########################################################################################
|
||||
if [ "$PGDBHOST" = "" ]; then
|
||||
PGDBHOST="localhost"
|
||||
fi
|
||||
#
|
||||
if [ "$DBPORT" = "" ]; then
|
||||
DBPORT="5432"
|
||||
fi
|
||||
#
|
||||
if [[ "$GQL_PORT" = "" ]]; then
|
||||
GQL_PORT="9000"
|
||||
fi
|
||||
#
|
||||
if [[ "$API_PORT" = "" ]]; then
|
||||
API_PORT="8000"
|
||||
fi
|
||||
#
|
||||
if [ "$APIURI" = "" ]; then
|
||||
APIURI="graphql"
|
||||
fi
|
||||
#
|
||||
if [ "$vOPT" = "true" ]; then
|
||||
if [ "$VERSION" = "" ]; then
|
||||
VERSION="2.11.1"
|
||||
fi
|
||||
fi
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Open the selected ports for the API and APP
|
||||
#########################################################################################
|
||||
# Open GraphQL port
|
||||
sudo ufw allow $GQL_PORT
|
||||
# Open API port
|
||||
sudo ufw allow $API_PORT
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Clone the Saleor Git repository
|
||||
#########################################################################################
|
||||
# Make sure we're in the user's home directory
|
||||
cd $HD
|
||||
# Does the Saleor Dashboard already exist?
|
||||
if [ -f "$HD/saleor" ]; then
|
||||
# Remove /saleor-dashboard
|
||||
sudo rm -R $HD/saleor
|
||||
fi
|
||||
# Check if the -v (version) option was used
|
||||
if [ "$vOPT" = "true" ]; then
|
||||
# Get the Mirumee repo
|
||||
git clone https://github.com/mirumee/saleor.git
|
||||
else
|
||||
# Was a repo specified?
|
||||
if [ "$REPO" = "mirumee" ]; then
|
||||
# Get the Mirumee repo
|
||||
git clone https://github.com/mirumee/saleor.git
|
||||
else
|
||||
# Get the forked repo from thewhiterabbit
|
||||
git clone https://github.com/thewhiterabbit/saleor.git
|
||||
fi
|
||||
fi
|
||||
wait
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Replace any parameter slugs in the template files with real paramaters & write them to
|
||||
# the production files
|
||||
#########################################################################################
|
||||
# Create vassals directory in virtual environment
|
||||
mkdir $HD/env/saleor/vassals
|
||||
sudo ln -s $HD/saleor/saleor/wsgi/uwsgi.ini $HD/env/saleor/vassals
|
||||
# Was the -v (version) option used or Mirumee repo specified?
|
||||
if [ "vOPT" = "true" ] || [ "$REPO" = "mirumee" ]; then
|
||||
# Does an old saleor.service file exist?
|
||||
if [ -f "/etc/systemd/system/saleor.service" ]; then
|
||||
# Remove the old service file
|
||||
sudo rm /etc/systemd/system/saleor.service
|
||||
fi
|
||||
# Create the new service file
|
||||
sudo sed "s/{un}/$UN/
|
||||
s|{hd}|$HD|" $HD/Deploy_Saleor/template.service > /etc/systemd/system/saleor.service
|
||||
wait
|
||||
# Does an old server block exist?
|
||||
if [ -f "/etc/nginx/sites-available/saleor" ]; then
|
||||
# Remove the old service file
|
||||
sudo rm /etc/nginx/sites-available/saleor
|
||||
fi
|
||||
# Create the new server block
|
||||
sudo sed "s|{hd}|$HD|g
|
||||
s/{api_host}/$API_HOST/
|
||||
s/{host}/$HOST/g
|
||||
s/{apiport}/$API_PORT/" $HD/Deploy_Saleor/server_block > /etc/nginx/sites-available/saleor
|
||||
wait
|
||||
# Replace demo credentials with production credentials in /saleor/saleor/core/management/commands/populatedb.py
|
||||
sudo sed -i "s/{\"email\": \"admin@example.com\", \"password\": \"admin\"}/{\"email\": \"$EMAIL\", \"password\": \"$PASSW\"}/" $HD/saleor/saleor/core/management/commands/populatedb.py
|
||||
wait
|
||||
# Replace demo credentials with production credentials in /saleor/saleor/core/tests/test_core.py
|
||||
sudo sed -i "s/{\"email\": \"admin@example.com\", \"password\": \"admin\"}/{\"email\": \"$EMAIL\", \"password\": \"$PASSW\"}/" $HD/saleor/saleor/core/tests/test_core.py
|
||||
wait
|
||||
# Replace the insecure demo secret key assignemnt with a more secure file reference in /saleor/saleor/settings.py
|
||||
sudo sed -i "s|SECRET_KEY = os.environ.get(\"SECRET_KEY\")|with open('/etc/saleor/api_sk') as f: SECRET_KEY = f.read().strip()|" $HD/saleor/saleor/settings.py
|
||||
wait
|
||||
else
|
||||
# Does an old saleor.service file exist?
|
||||
if [ -f "/etc/systemd/system/saleor.service" ]; then
|
||||
# Remove the old service file
|
||||
sudo rm /etc/systemd/system/saleor.service
|
||||
fi
|
||||
# Create the new service file
|
||||
sudo sed "s/{un}/$UN/
|
||||
s|{hd}|$HD|" $HD/saleor/resources/template.service > /etc/systemd/system/saleor.service
|
||||
wait
|
||||
# Does an old server block exist?
|
||||
if [ -f "/etc/nginx/sites-available/saleor" ]; then
|
||||
# Remove the old service file
|
||||
sudo rm /etc/nginx/sites-available/saleor
|
||||
fi
|
||||
# Create the new server block
|
||||
sudo sed "s|{hd}|$HD|
|
||||
s/{api_host}/$API_HOST/
|
||||
s/{host}/$HOST/g
|
||||
s/{apiport}/$API_PORT/" $HD/saleor/resources/server_block > /etc/nginx/sites-available/saleor
|
||||
wait
|
||||
# Set the production credentials in /saleor/saleor/core/management/commands/populatedb.py
|
||||
sudo sed -i "s/{email}/$EMAIL/
|
||||
s/{passw}/$PASSW/" $HD/saleor/saleor/core/management/commands/populatedb.py
|
||||
wait
|
||||
# Set the production credentials in /saleor/saleor/core/tests/test_core.py
|
||||
sudo sed -i "s/{email}/$EMAIL/
|
||||
s/{passw}/$PASSW/" $HD/saleor/saleor/core/tests/test_core.py
|
||||
wait
|
||||
fi
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Tell the user what's happening
|
||||
echo "Creating production deployment packages for Saleor API & GraphQL..."
|
||||
echo ""
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Setup the environment variables for Saleor API
|
||||
#########################################################################################
|
||||
# Build the database URL
|
||||
DB_URL="postgres://$PGSQLUSER:$PGSQLUSERPASS@$PGDBHOST:$DBPORT/$PGSQLDBNAME"
|
||||
EMAIL_URL="smtp://$EMAIL:$EMAIL_PW@$EMAIL_HOST:/?ssl=True"
|
||||
# Build the chosts and ahosts lists
|
||||
C_HOSTS="$HOST,$API_HOST,localhost,127.0.0.1"
|
||||
A_HOSTS="$HOST,$API_HOST,localhost,127.0.0.1"
|
||||
QL_ORIGINS="$HOST,$API_HOST,localhost,127.0.0.1"
|
||||
# Write the production .env file from template.env
|
||||
sudo sed "s|{dburl}|$DB_URL|
|
||||
s|{emailurl}|$EMAIL_URL|
|
||||
s/{chosts}/$C_HOSTS/
|
||||
s/{ahosts}/$A_HOSTS/
|
||||
s/{gqlorigins}/$QL_ORIGINS/" $HD/Deploy_Saleor/resources/saleor/template.env > $HD/saleor/.env
|
||||
wait
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Copy the uwsgi_params file to /saleor/uwsgi_params
|
||||
#########################################################################################
|
||||
sudo cp $HD/Deploy_Saleor/uwsgi_params $HD/saleor/uwsgi_params
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Install Saleor for production
|
||||
#########################################################################################
|
||||
# Make sure we're in the project root directory for Saleor
|
||||
cd $HD/saleor
|
||||
# Was the -v (version) option used?
|
||||
if [ "vOPT" = "true" ]; then
|
||||
# Checkout the specified version
|
||||
git checkout $VERSION
|
||||
fi
|
||||
# Does an old virtual environment for Saleor exist?
|
||||
if [ -f "$HD/env/saleor" ]; then
|
||||
# remove the old virtual environment
|
||||
sudo rm -R $HD/env/saleor
|
||||
fi
|
||||
# Create a new virtual environment for Saleor
|
||||
python3 -m venv $HD/env/saleor
|
||||
# Activate the virtual environment
|
||||
source $HD/env/saleor/bin/activate
|
||||
# Make sure pip is upgraded
|
||||
python3 -m pip install --upgrade pip
|
||||
wait
|
||||
# Install Django
|
||||
pip3 install Django
|
||||
wait
|
||||
# Install uwsgi
|
||||
pip3 install uwsgi
|
||||
wait
|
||||
# Install the project requirements
|
||||
pip3 install -r requirements.txt
|
||||
wait
|
||||
# Install the project
|
||||
npm install
|
||||
# Run an audit to fix any vulnerabilities
|
||||
npm audit fix
|
||||
# Establish the database
|
||||
python3 manage.py migrate
|
||||
# Collect the static elemants
|
||||
python3 manage.py collectstatic
|
||||
# Build the schema
|
||||
npm run build-schema
|
||||
# Build the emails
|
||||
npm run build-emails
|
||||
# Exit the virtual environment here? _#_
|
||||
deactivate
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
echo "Enabling server block and Restarting nginx..."
|
||||
sudo ln -s /etc/nginx/sites-available/saleor /etc/nginx/sites-enabled/
|
||||
sudo systemctl restart nginx
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Create the Saleor service
|
||||
#########################################################################################
|
||||
# Touch
|
||||
sudo touch /etc/init.d/saleor
|
||||
# Allow execute
|
||||
sudo chmod +x /etc/init.d/saleor
|
||||
# Update with defaults
|
||||
sudo update-rc.d saleor defaults
|
||||
#########################################################################################
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# Tell the user what's happening
|
||||
#########################################################################################
|
||||
echo ""
|
||||
echo "Finished creating production deployment packages for Saleor API & GraphQL"
|
||||
echo ""
|
||||
#########################################################################################
|
3
resources/saleor-dashboard/template.env
Normal file
3
resources/saleor-dashboard/template.env
Normal file
|
@ -0,0 +1,3 @@
|
|||
API_URI="{apiuri}"
|
||||
APP_MOUNT_URI="/{dashuri}/"
|
||||
STATIC_URL="{url}"
|
|
@ -1,34 +0,0 @@
|
|||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: Django-Server
|
||||
# Required-Start: $all
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Django Server
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
|
||||
|
||||
# If you need to source some other scripts, do it here
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_begin_msg "Starting Saleor Server"
|
||||
python3 "{hd}/saleor/manage.py" runserver {hostip}:8000 --insecure &
|
||||
log_end_msg $?
|
||||
exit 0
|
||||
;;
|
||||
stop)
|
||||
log_begin_msg "Stopping Saleor Server"
|
||||
|
||||
# do something to kill the service or cleanup or nothing
|
||||
|
||||
log_end_msg $?
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/saleor {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
34
resources/saleor/server_block
Normal file
34
resources/saleor/server_block
Normal file
|
@ -0,0 +1,34 @@
|
|||
# the upstream component nginx needs to connect to
|
||||
upstream django {
|
||||
server unix://{hd}/saleor/saleor.sock;
|
||||
}
|
||||
# configuration of the server
|
||||
server {
|
||||
listen 80;
|
||||
server_name {host} www.{host};
|
||||
charset utf-8;
|
||||
# max upload size
|
||||
client_max_body_size 75M;
|
||||
# Django media and static files
|
||||
location /media {
|
||||
alias {hd}}/saleor/media;
|
||||
}
|
||||
location /static {
|
||||
alias {hd}/saleor/static;
|
||||
}
|
||||
# Send all non-media requests to the Django server.
|
||||
location / {
|
||||
uwsgi_pass django;
|
||||
include {hd}/saleor/uwsgi_params;
|
||||
}
|
||||
|
||||
location /graphql/ {
|
||||
proxy_pass https://{apihost}:{apiport};
|
||||
}
|
||||
|
||||
location /dashboard/ {
|
||||
path {hd}/saleor-dashboard/build/;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /dashboard/index.html;
|
||||
}
|
||||
}
|
26
resources/saleor/template.env
Normal file
26
resources/saleor/template.env
Normal file
|
@ -0,0 +1,26 @@
|
|||
PROJECT_ROOT="{proot}"
|
||||
|
||||
DEFAULT_COUNTRY="{country}"
|
||||
DEFAULT_CURRENCY="{currency}"
|
||||
|
||||
ALLOWED_CLIENT_HOSTS="{chosts}"
|
||||
ALLOWED_HOSTS="{ahosts}"
|
||||
ALLOWED_GRAPHQL_ORIGINS="{gqlorigins}"
|
||||
|
||||
#INTERNAL_IPS="{iips}"
|
||||
DATABASE_URL="{dburl}"
|
||||
|
||||
EMAIL_URL="{emailurl}"
|
||||
#SENDGRID_USERNAME="{sguser}"
|
||||
#SENDGRID_PASSWORD="{sgpass}"
|
||||
DEFAULT_FROM_EMAIL="{dfemail}"
|
||||
|
||||
STATIC_URL="{static}"
|
||||
MEDIA_URL="{media}"
|
||||
|
||||
#MAX_CHECKOUT_LINE_QUANTITY="{mclq}"
|
||||
|
||||
#OPENEXCHANGERATES_API_KEY="{openxkey}"
|
||||
#GOOGLE_ANALYTICS_TRACKING_ID="{gatid}"
|
||||
|
||||
DEBUG=False
|
9
resources/saleor/template.service
Normal file
9
resources/saleor/template.service
Normal file
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=uWSGI for Saleor API
|
||||
After=network.target
|
||||
[Service]
|
||||
User={un}
|
||||
Restart=always
|
||||
ExecStart={hd}/env/saleor/bin/uwsgi --emperor {hd}/env/saleor/vassals --uid www-data --gid www-data
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
14
resources/saleor/uwsgi_params
Normal file
14
resources/saleor/uwsgi_params
Normal file
|
@ -0,0 +1,14 @@
|
|||
uwsgi_param QUERY_STRING $query_string;
|
||||
uwsgi_param REQUEST_METHOD $request_method;
|
||||
uwsgi_param CONTENT_TYPE $content_type;
|
||||
uwsgi_param CONTENT_LENGTH $content_length;
|
||||
uwsgi_param REQUEST_URI $request_uri;
|
||||
uwsgi_param PATH_INFO $document_uri;
|
||||
uwsgi_param DOCUMENT_ROOT $document_root;
|
||||
uwsgi_param SERVER_PROTOCOL $server_protocol;
|
||||
uwsgi_param REQUEST_SCHEME $scheme;
|
||||
uwsgi_param HTTPS $https if_not_empty;
|
||||
uwsgi_param REMOTE_ADDR $remote_addr;
|
||||
uwsgi_param REMOTE_PORT $remote_port;
|
||||
uwsgi_param SERVER_PORT $server_port;
|
||||
uwsgi_param SERVER_NAME $server_name;
|
|
@ -1,14 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name {host} www.{host};
|
||||
|
||||
location /graphql/ {
|
||||
proxy_pass https://{apihost}:{apiport};
|
||||
}
|
||||
|
||||
location /dashboard/ {
|
||||
path {hd}/saleor-dashboard/build/;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /dashboard/index.html;
|
||||
}
|
||||
}
|
|
@ -1,591 +0,0 @@
|
|||
import ast
|
||||
import os.path
|
||||
import warnings
|
||||
from datetime import timedelta
|
||||
|
||||
import dj_database_url
|
||||
import dj_email_url
|
||||
import django_cache_url
|
||||
import jaeger_client
|
||||
import jaeger_client.config
|
||||
import pkg_resources
|
||||
import sentry_sdk
|
||||
import sentry_sdk.utils
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.management.utils import get_random_secret_key
|
||||
from pytimeparse import parse
|
||||
from sentry_sdk.integrations.celery import CeleryIntegration
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
|
||||
|
||||
def get_list(text):
|
||||
return [item.strip() for item in text.split(",")]
|
||||
|
||||
|
||||
def get_bool_from_env(name, default_value):
|
||||
if name in os.environ:
|
||||
value = os.environ[name]
|
||||
try:
|
||||
return ast.literal_eval(value)
|
||||
except ValueError as e:
|
||||
raise ValueError("{} is an invalid value for {}".format(value, name)) from e
|
||||
return default_value
|
||||
|
||||
|
||||
DEBUG = get_bool_from_env("DEBUG", True)
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
ROOT_URLCONF = "saleor.urls"
|
||||
|
||||
WSGI_APPLICATION = "saleor.wsgi.application"
|
||||
|
||||
ADMINS = (
|
||||
# ('Your Name', 'your_email@example.com'),
|
||||
)
|
||||
MANAGERS = ADMINS
|
||||
|
||||
_DEFAULT_CLIENT_HOSTS = "localhost,127.0.0.1"
|
||||
|
||||
ALLOWED_CLIENT_HOSTS = os.environ.get("ALLOWED_CLIENT_HOSTS")
|
||||
if not ALLOWED_CLIENT_HOSTS:
|
||||
if DEBUG:
|
||||
ALLOWED_CLIENT_HOSTS = _DEFAULT_CLIENT_HOSTS
|
||||
else:
|
||||
raise ImproperlyConfigured(
|
||||
"ALLOWED_CLIENT_HOSTS environment variable must be set when DEBUG=False."
|
||||
)
|
||||
|
||||
ALLOWED_CLIENT_HOSTS = get_list(ALLOWED_CLIENT_HOSTS)
|
||||
|
||||
INTERNAL_IPS = get_list(os.environ.get("INTERNAL_IPS", "127.0.0.1"))
|
||||
|
||||
DATABASES = {
|
||||
"default": dj_database_url.config(
|
||||
default="postgres://saleor:saleor@localhost:5432/saleor", conn_max_age=600
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
LANGUAGE_CODE = "en"
|
||||
LANGUAGES = [
|
||||
("ar", "Arabic"),
|
||||
("az", "Azerbaijani"),
|
||||
("bg", "Bulgarian"),
|
||||
("bn", "Bengali"),
|
||||
("ca", "Catalan"),
|
||||
("cs", "Czech"),
|
||||
("da", "Danish"),
|
||||
("de", "German"),
|
||||
("el", "Greek"),
|
||||
("en", "English"),
|
||||
("es", "Spanish"),
|
||||
("es-co", "Colombian Spanish"),
|
||||
("et", "Estonian"),
|
||||
("fa", "Persian"),
|
||||
("fi", "Finnish"),
|
||||
("fr", "French"),
|
||||
("hi", "Hindi"),
|
||||
("hu", "Hungarian"),
|
||||
("hy", "Armenian"),
|
||||
("id", "Indonesian"),
|
||||
("is", "Icelandic"),
|
||||
("it", "Italian"),
|
||||
("ja", "Japanese"),
|
||||
("ka", "Georgian"),
|
||||
("km", "Khmer"),
|
||||
("ko", "Korean"),
|
||||
("lt", "Lithuanian"),
|
||||
("mn", "Mongolian"),
|
||||
("my", "Burmese"),
|
||||
("nb", "Norwegian"),
|
||||
("nl", "Dutch"),
|
||||
("pl", "Polish"),
|
||||
("pt", "Portuguese"),
|
||||
("pt-br", "Brazilian Portuguese"),
|
||||
("ro", "Romanian"),
|
||||
("ru", "Russian"),
|
||||
("sk", "Slovak"),
|
||||
("sl", "Slovenian"),
|
||||
("sq", "Albanian"),
|
||||
("sr", "Serbian"),
|
||||
("sv", "Swedish"),
|
||||
("sw", "Swahili"),
|
||||
("ta", "Tamil"),
|
||||
("th", "Thai"),
|
||||
("tr", "Turkish"),
|
||||
("uk", "Ukrainian"),
|
||||
("vi", "Vietnamese"),
|
||||
("zh-hans", "Simplified Chinese"),
|
||||
("zh-hant", "Traditional Chinese"),
|
||||
]
|
||||
LOCALE_PATHS = [os.path.join(PROJECT_ROOT, "locale")]
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
USE_TZ = True
|
||||
|
||||
FORM_RENDERER = "django.forms.renderers.TemplatesSetting"
|
||||
|
||||
EMAIL_URL = os.environ.get("EMAIL_URL")
|
||||
SENDGRID_USERNAME = os.environ.get("SENDGRID_USERNAME")
|
||||
SENDGRID_PASSWORD = os.environ.get("SENDGRID_PASSWORD")
|
||||
if not EMAIL_URL and SENDGRID_USERNAME and SENDGRID_PASSWORD:
|
||||
EMAIL_URL = "smtp://%s:%s@smtp.sendgrid.net:587/?tls=True" % (
|
||||
SENDGRID_USERNAME,
|
||||
SENDGRID_PASSWORD,
|
||||
)
|
||||
email_config = dj_email_url.parse(
|
||||
EMAIL_URL or "console://demo@example.com:console@example/"
|
||||
)
|
||||
|
||||
EMAIL_FILE_PATH = email_config["EMAIL_FILE_PATH"]
|
||||
EMAIL_HOST_USER = email_config["EMAIL_HOST_USER"]
|
||||
EMAIL_HOST_PASSWORD = email_config["EMAIL_HOST_PASSWORD"]
|
||||
EMAIL_HOST = email_config["EMAIL_HOST"]
|
||||
EMAIL_PORT = email_config["EMAIL_PORT"]
|
||||
EMAIL_BACKEND = email_config["EMAIL_BACKEND"]
|
||||
EMAIL_USE_TLS = email_config["EMAIL_USE_TLS"]
|
||||
EMAIL_USE_SSL = email_config["EMAIL_USE_SSL"]
|
||||
|
||||
# If enabled, make sure you have set proper storefront address in ALLOWED_CLIENT_HOSTS.
|
||||
ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL = get_bool_from_env(
|
||||
"ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL", True
|
||||
)
|
||||
|
||||
ENABLE_SSL = get_bool_from_env("ENABLE_SSL", False)
|
||||
|
||||
if ENABLE_SSL:
|
||||
SECURE_SSL_REDIRECT = not DEBUG
|
||||
|
||||
DEFAULT_FROM_EMAIL = os.environ.get("DEFAULT_FROM_EMAIL", EMAIL_HOST_USER)
|
||||
|
||||
MEDIA_ROOT = os.path.join(PROJECT_ROOT, "media")
|
||||
MEDIA_URL = os.environ.get("MEDIA_URL", "/media/")
|
||||
|
||||
STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
|
||||
STATIC_URL = os.environ.get("STATIC_URL", "/static/")
|
||||
STATICFILES_DIRS = [
|
||||
("images", os.path.join(PROJECT_ROOT, "saleor", "static", "images"))
|
||||
]
|
||||
STATICFILES_FINDERS = [
|
||||
"django.contrib.staticfiles.finders.FileSystemFinder",
|
||||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
]
|
||||
|
||||
context_processors = [
|
||||
"django.template.context_processors.debug",
|
||||
"django.template.context_processors.media",
|
||||
"django.template.context_processors.static",
|
||||
"saleor.site.context_processors.site",
|
||||
]
|
||||
|
||||
loaders = [
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
]
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
"DIRS": [os.path.join(PROJECT_ROOT, "templates")],
|
||||
"OPTIONS": {
|
||||
"debug": DEBUG,
|
||||
"context_processors": context_processors,
|
||||
"loaders": loaders,
|
||||
"string_if_invalid": '<< MISSING VARIABLE "%s" >>' if DEBUG else "",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
# Read secret key from a file
|
||||
with open('/etc/saleor/api_sk') as f:
|
||||
SECRET_KEY = f.read().strip()
|
||||
|
||||
if not SECRET_KEY and DEBUG:
|
||||
warnings.warn("SECRET_KEY not configured, using a random temporary key.")
|
||||
SECRET_KEY = get_random_secret_key()
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"saleor.core.middleware.request_time",
|
||||
"saleor.core.middleware.discounts",
|
||||
"saleor.core.middleware.google_analytics",
|
||||
"saleor.core.middleware.country",
|
||||
"saleor.core.middleware.currency",
|
||||
"saleor.core.middleware.site",
|
||||
"saleor.core.middleware.plugins",
|
||||
"saleor.core.middleware.jwt_refresh_token_middleware",
|
||||
]
|
||||
|
||||
INSTALLED_APPS = [
|
||||
# External apps that need to go before django's
|
||||
"storages",
|
||||
# Django modules
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sites",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.postgres",
|
||||
# Local apps
|
||||
"saleor.plugins",
|
||||
"saleor.account",
|
||||
"saleor.discount",
|
||||
"saleor.giftcard",
|
||||
"saleor.product",
|
||||
"saleor.attribute",
|
||||
"saleor.channel",
|
||||
"saleor.checkout",
|
||||
"saleor.core",
|
||||
"saleor.csv",
|
||||
"saleor.graphql",
|
||||
"saleor.menu",
|
||||
"saleor.order",
|
||||
"saleor.invoice",
|
||||
"saleor.seo",
|
||||
"saleor.shipping",
|
||||
"saleor.search",
|
||||
"saleor.site",
|
||||
"saleor.page",
|
||||
"saleor.payment",
|
||||
"saleor.warehouse",
|
||||
"saleor.webhook",
|
||||
"saleor.wishlist",
|
||||
"saleor.app",
|
||||
# External apps
|
||||
"versatileimagefield",
|
||||
"django_measurement",
|
||||
"django_prices",
|
||||
"django_prices_openexchangerates",
|
||||
"django_prices_vatlayer",
|
||||
"graphene_django",
|
||||
"mptt",
|
||||
"django_countries",
|
||||
"django_filters",
|
||||
"phonenumber_field",
|
||||
]
|
||||
|
||||
|
||||
ENABLE_DEBUG_TOOLBAR = get_bool_from_env("ENABLE_DEBUG_TOOLBAR", False)
|
||||
if ENABLE_DEBUG_TOOLBAR:
|
||||
# Ensure the graphiql debug toolbar is actually installed before adding it
|
||||
try:
|
||||
__import__("graphiql_debug_toolbar")
|
||||
except ImportError as exc:
|
||||
msg = (
|
||||
f"{exc} -- Install the missing dependencies by "
|
||||
f"running `pip install -r requirements_dev.txt`"
|
||||
)
|
||||
warnings.warn(msg)
|
||||
else:
|
||||
INSTALLED_APPS += ["django.forms", "debug_toolbar", "graphiql_debug_toolbar"]
|
||||
MIDDLEWARE.append("saleor.graphql.middleware.DebugToolbarMiddleware")
|
||||
|
||||
DEBUG_TOOLBAR_PANELS = [
|
||||
"ddt_request_history.panels.request_history.RequestHistoryPanel",
|
||||
"debug_toolbar.panels.timer.TimerPanel",
|
||||
"debug_toolbar.panels.headers.HeadersPanel",
|
||||
"debug_toolbar.panels.request.RequestPanel",
|
||||
"debug_toolbar.panels.sql.SQLPanel",
|
||||
"debug_toolbar.panels.profiling.ProfilingPanel",
|
||||
]
|
||||
DEBUG_TOOLBAR_CONFIG = {"RESULTS_CACHE_SIZE": 100}
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"root": {"level": "INFO", "handlers": ["default"]},
|
||||
"formatters": {
|
||||
"django.server": {
|
||||
"()": "django.utils.log.ServerFormatter",
|
||||
"format": "[{server_time}] {message}",
|
||||
"style": "{",
|
||||
},
|
||||
"json": {
|
||||
"()": "saleor.core.logging.JsonFormatter",
|
||||
"datefmt": "%Y-%m-%dT%H:%M:%SZ",
|
||||
"format": (
|
||||
"%(asctime)s %(levelname)s %(lineno)s %(message)s %(name)s "
|
||||
+ "%(pathname)s %(process)d %(threadName)s"
|
||||
),
|
||||
},
|
||||
"verbose": {
|
||||
"format": (
|
||||
"%(levelname)s %(name)s %(message)s [PID:%(process)d:%(threadName)s]"
|
||||
)
|
||||
},
|
||||
},
|
||||
"handlers": {
|
||||
"default": {
|
||||
"level": "DEBUG",
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "verbose" if DEBUG else "json",
|
||||
},
|
||||
"django.server": {
|
||||
"level": "INFO",
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "django.server" if DEBUG else "json",
|
||||
},
|
||||
},
|
||||
"loggers": {
|
||||
"django": {"level": "INFO", "propagate": True},
|
||||
"django.server": {
|
||||
"handlers": ["django.server"],
|
||||
"level": "INFO",
|
||||
"propagate": False,
|
||||
},
|
||||
"saleor": {"level": "DEBUG", "propagate": True},
|
||||
"saleor.graphql.errors.handled": {
|
||||
"handlers": ["default"],
|
||||
"level": "INFO",
|
||||
"propagate": False,
|
||||
},
|
||||
"graphql.execution.utils": {"propagate": False},
|
||||
},
|
||||
}
|
||||
|
||||
AUTH_USER_MODEL = "account.User"
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||
"OPTIONS": {"min_length": 8},
|
||||
}
|
||||
]
|
||||
|
||||
DEFAULT_COUNTRY = os.environ.get("DEFAULT_COUNTRY", "US")
|
||||
DEFAULT_CURRENCY = os.environ.get("DEFAULT_CURRENCY", "USD")
|
||||
DEFAULT_DECIMAL_PLACES = 3
|
||||
DEFAULT_MAX_DIGITS = 12
|
||||
DEFAULT_CURRENCY_CODE_LENGTH = 3
|
||||
|
||||
# The default max length for the display name of the
|
||||
# sender email address.
|
||||
# Following the recommendation of https://tools.ietf.org/html/rfc5322#section-2.1.1
|
||||
DEFAULT_MAX_EMAIL_DISPLAY_NAME_LENGTH = 78
|
||||
|
||||
COUNTRIES_OVERRIDE = {"EU": "European Union"}
|
||||
|
||||
OPENEXCHANGERATES_API_KEY = os.environ.get("OPENEXCHANGERATES_API_KEY")
|
||||
|
||||
GOOGLE_ANALYTICS_TRACKING_ID = os.environ.get("GOOGLE_ANALYTICS_TRACKING_ID")
|
||||
|
||||
|
||||
def get_host():
|
||||
from django.contrib.sites.models import Site
|
||||
|
||||
return Site.objects.get_current().domain
|
||||
|
||||
|
||||
PAYMENT_HOST = get_host
|
||||
|
||||
PAYMENT_MODEL = "order.Payment"
|
||||
|
||||
MAX_CHECKOUT_LINE_QUANTITY = int(os.environ.get("MAX_CHECKOUT_LINE_QUANTITY", 50))
|
||||
|
||||
TEST_RUNNER = "saleor.tests.runner.PytestTestRunner"
|
||||
|
||||
|
||||
PLAYGROUND_ENABLED = get_bool_from_env("PLAYGROUND_ENABLED", True)
|
||||
|
||||
ALLOWED_HOSTS = get_list(os.environ.get("ALLOWED_HOSTS", "localhost,127.0.0.1"))
|
||||
ALLOWED_GRAPHQL_ORIGINS = get_list(os.environ.get("ALLOWED_GRAPHQL_ORIGINS", "*"))
|
||||
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
|
||||
# Amazon S3 configuration
|
||||
# See https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html
|
||||
AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID")
|
||||
AWS_LOCATION = os.environ.get("AWS_LOCATION", "")
|
||||
AWS_MEDIA_BUCKET_NAME = os.environ.get("AWS_MEDIA_BUCKET_NAME")
|
||||
AWS_MEDIA_CUSTOM_DOMAIN = os.environ.get("AWS_MEDIA_CUSTOM_DOMAIN")
|
||||
AWS_QUERYSTRING_AUTH = get_bool_from_env("AWS_QUERYSTRING_AUTH", False)
|
||||
AWS_QUERYSTRING_EXPIRE = get_bool_from_env("AWS_QUERYSTRING_EXPIRE", 3600)
|
||||
AWS_S3_CUSTOM_DOMAIN = os.environ.get("AWS_STATIC_CUSTOM_DOMAIN")
|
||||
AWS_S3_ENDPOINT_URL = os.environ.get("AWS_S3_ENDPOINT_URL", None)
|
||||
AWS_S3_REGION_NAME = os.environ.get("AWS_S3_REGION_NAME", None)
|
||||
AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY")
|
||||
AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME")
|
||||
AWS_DEFAULT_ACL = os.environ.get("AWS_DEFAULT_ACL", None)
|
||||
|
||||
# Google Cloud Storage configuration
|
||||
GS_PROJECT_ID = os.environ.get("GS_PROJECT_ID")
|
||||
GS_STORAGE_BUCKET_NAME = os.environ.get("GS_STORAGE_BUCKET_NAME")
|
||||
GS_MEDIA_BUCKET_NAME = os.environ.get("GS_MEDIA_BUCKET_NAME")
|
||||
GS_AUTO_CREATE_BUCKET = get_bool_from_env("GS_AUTO_CREATE_BUCKET", False)
|
||||
GS_QUERYSTRING_AUTH = get_bool_from_env("GS_QUERYSTRING_AUTH", False)
|
||||
GS_DEFAULT_ACL = os.environ.get("GS_DEFAULT_ACL", None)
|
||||
GS_MEDIA_CUSTOM_ENDPOINT = os.environ.get("GS_MEDIA_CUSTOM_ENDPOINT", None)
|
||||
GS_EXPIRATION = os.environ.get("GS_EXPIRATION", None)
|
||||
|
||||
# If GOOGLE_APPLICATION_CREDENTIALS is set there is no need to load OAuth token
|
||||
# See https://django-storages.readthedocs.io/en/latest/backends/gcloud.html
|
||||
if "GOOGLE_APPLICATION_CREDENTIALS" not in os.environ:
|
||||
GS_CREDENTIALS = os.environ.get("GS_CREDENTIALS")
|
||||
|
||||
if AWS_STORAGE_BUCKET_NAME:
|
||||
STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
|
||||
elif GS_STORAGE_BUCKET_NAME:
|
||||
STATICFILES_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
|
||||
|
||||
if AWS_MEDIA_BUCKET_NAME:
|
||||
DEFAULT_FILE_STORAGE = "saleor.core.storages.S3MediaStorage"
|
||||
THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
|
||||
elif GS_MEDIA_BUCKET_NAME:
|
||||
DEFAULT_FILE_STORAGE = "saleor.core.storages.GCSMediaStorage"
|
||||
THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
|
||||
|
||||
VERSATILEIMAGEFIELD_RENDITION_KEY_SETS = {
|
||||
"products": [
|
||||
("product_gallery", "thumbnail__540x540"),
|
||||
("product_gallery_2x", "thumbnail__1080x1080"),
|
||||
("product_small", "thumbnail__60x60"),
|
||||
("product_small_2x", "thumbnail__120x120"),
|
||||
("product_list", "thumbnail__255x255"),
|
||||
("product_list_2x", "thumbnail__510x510"),
|
||||
],
|
||||
"background_images": [("header_image", "thumbnail__1080x440")],
|
||||
"user_avatars": [("default", "thumbnail__445x445")],
|
||||
}
|
||||
|
||||
VERSATILEIMAGEFIELD_SETTINGS = {
|
||||
# Images should be pre-generated on Production environment
|
||||
"create_images_on_demand": get_bool_from_env("CREATE_IMAGES_ON_DEMAND", DEBUG)
|
||||
}
|
||||
|
||||
PLACEHOLDER_IMAGES = {
|
||||
60: "images/placeholder60x60.png",
|
||||
120: "images/placeholder120x120.png",
|
||||
255: "images/placeholder255x255.png",
|
||||
540: "images/placeholder540x540.png",
|
||||
1080: "images/placeholder1080x1080.png",
|
||||
}
|
||||
|
||||
DEFAULT_PLACEHOLDER = "images/placeholder255x255.png"
|
||||
|
||||
SEARCH_BACKEND = "saleor.search.backends.postgresql"
|
||||
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
"saleor.core.auth_backend.JSONWebTokenBackend",
|
||||
]
|
||||
|
||||
# CELERY SETTINGS
|
||||
CELERY_TIMEZONE = TIME_ZONE
|
||||
CELERY_BROKER_URL = (
|
||||
os.environ.get("CELERY_BROKER_URL", os.environ.get("CLOUDAMQP_URL")) or ""
|
||||
)
|
||||
CELERY_TASK_ALWAYS_EAGER = not CELERY_BROKER_URL
|
||||
CELERY_ACCEPT_CONTENT = ["json"]
|
||||
CELERY_TASK_SERIALIZER = "json"
|
||||
CELERY_RESULT_SERIALIZER = "json"
|
||||
CELERY_RESULT_BACKEND = os.environ.get("CELERY_RESULT_BACKEND", None)
|
||||
|
||||
# Change this value if your application is running behind a proxy,
|
||||
# e.g. HTTP_CF_Connecting_IP for Cloudflare or X_FORWARDED_FOR
|
||||
REAL_IP_ENVIRON = os.environ.get("REAL_IP_ENVIRON", "REMOTE_ADDR")
|
||||
|
||||
# Slugs for menus precreated in Django migrations
|
||||
DEFAULT_MENUS = {"top_menu_name": "navbar", "bottom_menu_name": "footer"}
|
||||
|
||||
# Slug for channel precreated in Django migrations
|
||||
DEFAULT_CHANNEL_SLUG = os.environ.get("DEFAULT_CHANNEL_SLUG", "default-channel")
|
||||
|
||||
|
||||
# Sentry
|
||||
sentry_sdk.utils.MAX_STRING_LENGTH = 4096
|
||||
SENTRY_DSN = os.environ.get("SENTRY_DSN")
|
||||
if SENTRY_DSN:
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN, integrations=[CeleryIntegration(), DjangoIntegration()]
|
||||
)
|
||||
|
||||
GRAPHENE = {
|
||||
"RELAY_CONNECTION_ENFORCE_FIRST_OR_LAST": True,
|
||||
"RELAY_CONNECTION_MAX_LIMIT": 100,
|
||||
"MIDDLEWARE": [
|
||||
"saleor.graphql.middleware.OpentracingGrapheneMiddleware",
|
||||
"saleor.graphql.middleware.JWTMiddleware",
|
||||
"saleor.graphql.middleware.app_middleware",
|
||||
],
|
||||
}
|
||||
|
||||
PLUGINS_MANAGER = "saleor.plugins.manager.PluginsManager"
|
||||
|
||||
PLUGINS = [
|
||||
"saleor.plugins.avatax.plugin.AvataxPlugin",
|
||||
"saleor.plugins.vatlayer.plugin.VatlayerPlugin",
|
||||
"saleor.plugins.webhook.plugin.WebhookPlugin",
|
||||
"saleor.payment.gateways.dummy.plugin.DummyGatewayPlugin",
|
||||
"saleor.payment.gateways.dummy_credit_card.plugin.DummyCreditCardGatewayPlugin",
|
||||
"saleor.payment.gateways.stripe.plugin.StripeGatewayPlugin",
|
||||
"saleor.payment.gateways.braintree.plugin.BraintreeGatewayPlugin",
|
||||
"saleor.payment.gateways.razorpay.plugin.RazorpayGatewayPlugin",
|
||||
"saleor.payment.gateways.adyen.plugin.AdyenGatewayPlugin",
|
||||
"saleor.payment.gateways.authorize_net.plugin.AuthorizeNetGatewayPlugin",
|
||||
"saleor.plugins.invoicing.plugin.InvoicingPlugin",
|
||||
]
|
||||
|
||||
# Plugin discovery
|
||||
installed_plugins = pkg_resources.iter_entry_points("saleor.plugins")
|
||||
for entry_point in installed_plugins:
|
||||
plugin_path = "{}.{}".format(entry_point.module_name, entry_point.attrs[0])
|
||||
if plugin_path not in PLUGINS:
|
||||
if entry_point.name not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append(entry_point.name)
|
||||
PLUGINS.append(plugin_path)
|
||||
|
||||
if (
|
||||
not DEBUG
|
||||
and ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL
|
||||
and ALLOWED_CLIENT_HOSTS == get_list(_DEFAULT_CLIENT_HOSTS)
|
||||
):
|
||||
raise ImproperlyConfigured(
|
||||
"Make sure you've added storefront address to ALLOWED_CLIENT_HOSTS "
|
||||
"if ENABLE_ACCOUNT_CONFIRMATION_BY_EMAIL is enabled."
|
||||
)
|
||||
|
||||
# Initialize a simple and basic Jaeger Tracing integration
|
||||
# for open-tracing if enabled.
|
||||
#
|
||||
# Refer to our guide on https://docs.saleor.io/docs/next/guides/opentracing-jaeger/.
|
||||
#
|
||||
# If running locally, set:
|
||||
# JAEGER_AGENT_HOST=localhost
|
||||
if "JAEGER_AGENT_HOST" in os.environ:
|
||||
jaeger_client.Config(
|
||||
config={
|
||||
"sampler": {"type": "const", "param": 1},
|
||||
"local_agent": {
|
||||
"reporting_port": os.environ.get(
|
||||
"JAEGER_AGENT_PORT", jaeger_client.config.DEFAULT_REPORTING_PORT
|
||||
),
|
||||
"reporting_host": os.environ.get("JAEGER_AGENT_HOST"),
|
||||
},
|
||||
"logging": get_bool_from_env("JAEGER_LOGGING", False),
|
||||
},
|
||||
service_name="saleor",
|
||||
validate=True,
|
||||
).initialize_tracer()
|
||||
|
||||
|
||||
# Some cloud providers (Heroku) export REDIS_URL variable instead of CACHE_URL
|
||||
REDIS_URL = os.environ.get("REDIS_URL")
|
||||
if REDIS_URL:
|
||||
CACHE_URL = os.environ.setdefault("CACHE_URL", REDIS_URL)
|
||||
CACHES = {"default": django_cache_url.config()}
|
||||
|
||||
# Default False because storefront and dashboard don't support expiration of token
|
||||
JWT_EXPIRE = get_bool_from_env("JWT_EXPIRE", False)
|
||||
JWT_TTL_ACCESS = timedelta(seconds=parse(os.environ.get("JWT_TTL_ACCESS", "5 minutes")))
|
||||
JWT_TTL_APP_ACCESS = timedelta(
|
||||
seconds=parse(os.environ.get("JWT_TTL_APP_ACCESS", "5 minutes"))
|
||||
)
|
||||
JWT_TTL_REFRESH = timedelta(seconds=parse(os.environ.get("JWT_TTL_REFRESH", "30 days")))
|
||||
|
||||
|
||||
JWT_TTL_REQUEST_EMAIL_CHANGE = timedelta(
|
||||
seconds=parse(os.environ.get("JWT_TTL_REQUEST_EMAIL_CHANGE", "1 hour")),
|
||||
)
|
Loading…
Reference in a new issue