Skip to content

Commit 461bd51

Browse files
committed
chore(commands): remove redundant database setup commands
since ensure_db implements the same functionality, the .sh commands were cleaned up to avoid redundancy
1 parent ed38802 commit 461bd51

File tree

6 files changed

+22
-41
lines changed

6 files changed

+22
-41
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"runServices": ["dev", "pgweb"],
66
"forwardPorts": ["docs:8000"],
77
"workspaceFolder": "/caltrans/app",
8-
"postStartCommand": ["/bin/bash", "bin/reset_db.sh"],
8+
"postStartCommand": ["/bin/bash", "bin/setup.sh"],
99
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],
1010
"customizations": {
1111
"vscode": {

.github/workflows/tests-pytest.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ jobs:
3333
pip install -e .[test]
3434
pip install -r streamlit_app/requirements.txt
3535
36-
- name: Run setup
37-
run: ./bin/init.sh
38-
3936
- name: Run tests
4037
run: ./tests/pytest/run.sh
4138

bin/reset_db.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

bin/setup.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
# Ensure databases, users, migrations, and superuser are set up
5+
should_reset=${REMOTE_CONTAINERS:-false}
6+
if [[ $should_reset == "true" ]]; then
7+
# running in a devcontainer, reset the DB
8+
python manage.py ensure_db --reset
9+
else
10+
python manage.py ensure_db
11+
fi
12+
13+
# Load data fixtures (if any)
14+
valid_fixtures=$(echo "$DJANGO_DB_FIXTURES" | grep -e fixtures\.json$ || test $? = 1)
15+
16+
if [[ -n "$valid_fixtures" ]]; then
17+
python manage.py loaddata $DJANGO_DB_FIXTURES
18+
else
19+
echo "No JSON fixtures to load"
20+
fi

bin/start.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/env bash
22
set -eu
33

4-
# initialize Django
5-
6-
bin/init.sh
7-
84
# start the web server
95

106
nginx

compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
context: .
77
dockerfile: appcontainer/Dockerfile
88
image: caltrans/pems:web
9+
command: ["-c", "bin/setup.sh && exec bin/start.sh"]
910
depends_on:
1011
- postgres
1112
env_file: .env

0 commit comments

Comments
 (0)