-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathassemble
executable file
·100 lines (83 loc) · 2.77 KB
/
assemble
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
function is_django_installed() {
python -c "import django" &>/dev/null
}
function should_collectstatic() {
is_django_installed && [[ -z "$DISABLE_COLLECTSTATIC" ]]
}
# Install pipenv to the separate virtualenv to isolate it
# from system Python packages and packages in the main
# virtualenv. Executable is simlinked into ~/.local/bin
# to be accessible. This approach is inspired by pipsi
# (pip script installer).
function install_pipenv() {
echo "---> Installing pipenv packaging tool ..."
VENV_DIR=$HOME/.local/venvs/pipenv
virtualenv $VENV_DIR
$VENV_DIR/bin/pip --isolated install -U pipenv
mkdir -p $HOME/.local/bin
ln -s $VENV_DIR/bin/pipenv $HOME/.local/bin/pipenv
}
set -e
shopt -s dotglob
echo "---> Installing application source ..."
mv /tmp/src/* ./
if [[ ! -z "$UPGRADE_PIP_TO_LATEST" || ! -z "$ENABLE_PIPENV" ]]; then
echo "---> Upgrading pip to latest version ..."
curl -s -o get-pip.py https://bootstrap.pypa.io/pip/3.6/get-pip.py && python3 get-pip.py
python3 -m pip install -U setuptools==57.4.0 wheel
rm get-pip.py
fi
cd backend
if [[ ! -z "$ENABLE_PIPENV" ]]; then
install_pipenv
echo "---> Installing dependencies via pipenv ..."
if [[ -f Pipfile ]]; then
pipenv install --deploy
elif [[ -f requirements.txt ]]; then
pipenv install -r requirements.txt
fi
pipenv check
elif [[ -f requirements.txt ]]; then
echo "---> Installing dependencies ..."
pip install -r requirements.txt
elif [[ -f setup.py ]]; then
echo "---> Installing application ..."
python setup.py develop
fi
cd ..
cd frontend
npm install
# Run unit tests in build stage with the code below
echo "--> testing and building frontend files"
npm run test:unit -- --runInBand
npm run build
# Copy resultant file to the backend.
mkdir -p ../backend/gwells/static/
cp -R dist/* ../backend/gwells/static/
cp dist/index.html ../backend/gwells/templates/
cd ..
if should_collectstatic; then
(
echo "---> Collecting Django static files ..."
cd backend
APP_HOME=${APP_HOME:-.}
# Look for 'manage.py' in the directory specified by APP_HOME, or the current directory
manage_file=$APP_HOME/manage.py
if [[ ! -f "$manage_file" ]]; then
echo "WARNING: seems that you're using Django, but we could not find a 'manage.py' file."
echo "'manage.py collectstatic' ignored."
exit
fi
if ! python $manage_file collectstatic --dry-run --noinput &> /dev/null; then
echo "WARNING: could not run 'manage.py collectstatic'. To debug, run:"
echo " $ python $manage_file collectstatic --noinput"
echo "Ignore this warning if you're not serving static files with Django."
exit
fi
python $manage_file collectstatic --noinput
cd ..
)
fi
# set permissions for any installed artifacts
fix-permissions /opt/app-root