-
Notifications
You must be signed in to change notification settings - Fork 754
Expand file tree
/
Copy pathapp-init.sh
More file actions
executable file
·136 lines (107 loc) · 4.45 KB
/
app-init.sh
File metadata and controls
executable file
·136 lines (107 loc) · 4.45 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
WORKSPACEDIR="/workspace"
# Handle Linux host mounting the workspace dir as root
if [ ! -O "${WORKSPACEDIR}/ietf" ]; then
sudo chown -R dev:dev $WORKSPACEDIR
fi
# Start rsyslog service
sudo service rsyslog start &>/dev/null
# Add /workspace as a safe git directory
git config --global --add safe.directory /workspace
# Turn off git info in zsh prompt (causes slowdowns)
git config oh-my-zsh.hide-info 1
# Fix ownership of volumes
echo "Fixing volumes ownership..."
sudo chown -R dev:dev "$WORKSPACEDIR/.parcel-cache"
sudo chown -R dev:dev "$WORKSPACEDIR/__pycache__"
sudo chown -R dev:dev "$WORKSPACEDIR/.vite"
sudo chown -R dev:dev "$WORKSPACEDIR/.yarn/unplugged"
sudo chown dev:dev "/assets"
# Run nginx
echo "Starting nginx..."
sudo nginx
# Build node packages that requrie native compilation
echo "Compiling native node packages..."
yarn rebuild
# Silence Browserlist warnings
export BROWSERSLIST_IGNORE_OLD_DATA=1
# Generate static assets
echo "Building static assets... (this could take a minute or two)"
yarn build
yarn legacy:build
# Copy config files if needed
cp $WORKSPACEDIR/docker/configs/settings_postgresqldb.py $WORKSPACEDIR/ietf/settings_postgresqldb.py
if [ ! -f "$WORKSPACEDIR/ietf/settings_local.py" ]; then
echo "Setting up a default settings_local.py ..."
else
echo "Renaming existing ietf/settings_local.py to ietf/settings_local.py.bak"
mv -f $WORKSPACEDIR/ietf/settings_local.py $WORKSPACEDIR/ietf/settings_local.py.bak
fi
cp $WORKSPACEDIR/docker/configs/settings_local.py $WORKSPACEDIR/ietf/settings_local.py
if [ ! -f "$WORKSPACEDIR/ietf/settings_local_debug.py" ]; then
echo "Setting up a default settings_local_debug.py ..."
else
echo "Renaming existing ietf/settings_local_debug.py to ietf/settings_local_debug.py.bak"
mv -f $WORKSPACEDIR/ietf/settings_local_debug.py $WORKSPACEDIR/ietf/settings_local_debug.py.bak
fi
cp $WORKSPACEDIR/docker/configs/settings_local_debug.py $WORKSPACEDIR/ietf/settings_local_debug.py
if [ ! -f "$WORKSPACEDIR/ietf/settings_local_vite.py" ]; then
echo "Setting up a default settings_local_vite.py ..."
else
echo "Renaming existing ietf/settings_local_vite.py to ietf/settings_local_vite.py.bak"
mv -f $WORKSPACEDIR/ietf/settings_local_vite.py $WORKSPACEDIR/ietf/settings_local_vite.py.bak
fi
cp $WORKSPACEDIR/docker/configs/settings_local_vite.py $WORKSPACEDIR/ietf/settings_local_vite.py
# Create data directories
echo "Creating data directories..."
chmod +x ./docker/scripts/app-create-dirs.sh
./docker/scripts/app-create-dirs.sh
# Configure the development blobstore
echo "Configuring blobstore..."
PYTHONPATH=/workspace python ./docker/scripts/app-configure-blobstore.py
# Download latest coverage results file
echo "Downloading latest coverage results file..."
curl -fsSL https://github.com/ietf-tools/datatracker/releases/download/baseline/coverage.json -o release-coverage.json
# Wait for DB container
if [ -n "$EDITOR_VSCODE" ]; then
echo "Waiting for DB container to come online ..."
/usr/local/bin/wait-for db:5432 -- echo "PostgreSQL ready"
fi
# Run memcached
echo "Starting memcached..."
/usr/bin/memcached -u dev -d
# Initial checks
echo "Running initial checks..."
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py check --settings=settings_local
# Migrate, adjusting to what the current state of the underlying database might be:
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --fake-initial --settings=settings_local
# Apply migrations to the blobdb database as well (most are skipped)
/usr/local/bin/python $WORKSPACEDIR/ietf/manage.py migrate --settings=settings_local --database=blobdb
if [ -z "$EDITOR_VSCODE" ]; then
CODE=0
python -m aiosmtpd -n -c ietf.utils.aiosmtpd.DevDebuggingHandler -l localhost:2025 &
if [ -z "$*" ]; then
echo "-----------------------------------------------------------------"
echo "Ready!"
echo "-----------------------------------------------------------------"
echo
echo "You can execute arbitrary commands now, e.g.,"
echo
echo " ietf/manage.py runserver 8001"
echo
echo "to start a development instance of the Datatracker."
echo
echo " ietf/manage.py test --settings=settings_test"
echo
echo "to run all the python tests."
echo
zsh
else
echo "Executing \"$*\" and stopping container."
echo
zsh -c "$*"
CODE=$?
fi
sudo service rsyslog stop
exit $CODE
fi