-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathregen-baseline.sh
executable file
·67 lines (58 loc) · 2.22 KB
/
regen-baseline.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
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
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ ${TRACE-0} == 1 ]]; then
set -o xtrace
fi
#
# 1. Run a new Appsmith container.
# 2. Wait for, and ensure backend server is up.
# 3. Kill backend.
# 4. Ensure connection to the embedded MongoDB.
# 5. Run the export script against the embedded MongoDB.
# 6. If needed, move the jsonl files to the right place.
# 7. Remove the container.
#
# Unfortunately, everytime this script runs, there will be a diff in the jsonl files. Always. This is because the ObjectID
# values, and the "createdAt" values would be different everytime a new Appsmith container is started up. This is...
# _okay_ for now. Since once we passover to only writing migrations on Postgres, these files will effectively be sealed.
# So we have to put up with that "problem" only until then. Which makes it not worth our time to solve.
# That said, please carefully review the diff nevertheless, keeping in mind the implementation of the migrations that
# reads these files.
container_name=appsmith-for-baseline
project_root="$(git rev-parse --show-toplevel)"
edition=ce
if [[ "$(git remote get-url origin)" == *appsmithorg/appsmith-ee.git ]]; then
edition=ee
fi
docker rm --force "$container_name"
docker run \
--detach \
--name "$container_name" \
--pull always "appsmith/appsmith-$edition":release
docker cp \
"$project_root/deploy/docker/fs/opt/appsmith/utils/bin/move-to-postgres.mjs" \
"$container_name":/opt/appsmith/utils/export.mjs
docker exec "$container_name" bash -c '
set -o errexit
set -o nounset
for attempt in {1..99}; do
if curl --silent --fail --fail-early 127.0.0.1:8080/api/v1/health; then
break
fi
echo "Waiting for backend to come up..."
sleep 3
done
if ! supervisorctl stop editor postgres rts backend redis; then
echo "Warning: Some services may not have stopped correctly."
fi
source /appsmith-stacks/configuration/docker.env
node utils/export.mjs --mongodb-url="$APPSMITH_DB_URL" --baseline
'
baseline_dir="$project_root/deploy/docker/fs/opt/appsmith/baseline-$edition"
rm -rf "$baseline_dir"
docker cp "$container_name":/appsmith-stacks/mongo-data "$baseline_dir"
docker rm -f "$container_name"
echo Removed "$container_name" and copied the new baseline files.
echo Finish