Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
# e.g. `/bin/sh^M: bad interpreter: No such file or directory`
# https://docs.github.com/en/github/using-git/configuring-git-to-handle-line-endings
*.sh text eol=lf
db/latest.sql filter=lfs diff=lfs merge=lfs -text
4 changes: 2 additions & 2 deletions doc/dev.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tCF Developer Info

Ensure your system has [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), [git-lfs](https://git-lfs.com/) and [Docker](https://docs.docker.com/install/) installed.
Ensure your system has [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), [git-lfs](https://git-lfs.com/), [Docker](https://docs.docker.com/install/), and [gdown](https://github.com/wkentaro/gdown) installed.

## One-Command Setup

Expand Down Expand Up @@ -35,7 +35,7 @@ $ docker compose up --build
```

4. Wait for the Django server to finish building (i.e. `tcf_django | Watching for file changes with StatReloader` is visible in stdout).
5. Download and place the [latest database backup](https://drive.google.com/drive/u/0/folders/1a7OkHkepOBWKiDou8nEhpAG41IzLi7mh) from Google Drive into `db/latest.sql` in your local repo.
5. Download and place the [latest database backup](https://drive.google.com/drive/u/0/folders/1a7OkHkepOBWKiDou8nEhpAG41IzLi7mh) (should be named `latest.sql`) from Google Drive into `db/latest.sql` in your local repo.
6. Update the database:

MacOS/Linux (or Windows, if you're using Git-Bash):
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ django-filter~=23.5
django-heroku~=0.3.1
django-stubs~=4.2.7
djangorestframework~=3.14.0
gdown~=5.2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GDown is only necessary for the setup script, not for the docker continaer. I think this should be removed - what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right I didn't even think of that, I'll remove.

gunicorn~=21.2.0
html-linter~=0.4.0
isort~=5.13.2
Expand All @@ -22,4 +23,4 @@ requests~=2.31.0
social-auth-app-django~=5.4.0
tqdm~=4.66.1
types-tqdm~=4.66.0
uWSGI~=2.0.23
uWSGI~=2.0.28
20 changes: 18 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ exists git

exists docker

exists gdown # check for gdown

git clone git@github.com:thecourseforum/theCourseForum2.git
if [ "$?" -ne 0 ]; then
echo "Unable to clone thecourseforum/theCourseForum2 with SSH. Ensure you have an ssh key set up on your GitHub account."
Expand All @@ -39,11 +41,25 @@ read -r _ </dev/tty

[ ! -f ".env" ] && echo "Error: '.env' file does not exist in '$1'. Follow the installation instructions in doc/dev.md after creating a '.env' file." && exit 1

GDRIVE_FILE_ID="1TsSvhvWGA24537xNo_9CkULKzjugNrZH"
SQL_FILE_PATH="db/latest.sql"

echo "Downloading $SQL_FILE_PATH from Google Drive..."

# use gdown to download latest.sql
gdown "$GDRIVE_FILE_ID" --output "$SQL_FILE_PATH"
if [ "$?" -ne 0 ]; then
echo "Failed to download $SQL_FILE_PATH from Google Drive."
echo "Make sure the file is publicly accessible or you have proper permissions."
exit 1
fi

docker compose build --no-cache
docker compose up &
(
sleep 1
sleep 3 # 1 to 3 to ensure containers are up
docker exec -i tcf_db psql tcf_db -U tcf_django -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
docker exec -i tcf_db psql tcf_db -U tcf_django -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
docker exec -i tcf_db psql tcf_db -U tcf_django <db/latest.sql
echo "Importing data from $SQL_FILE_PATH..."
docker exec -i tcf_db psql tcf_db -U tcf_django < "$SQL_FILE_PATH"
) &
Loading