Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 0 additions & 7 deletions .gitattributes

This file was deleted.

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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,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
22 changes: 20 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ if [ -z "$1" ]; then
exit
fi

cd "$1" || exit

exists() {
command -v "$1" >/dev/null 2>&1 || {
echo "Error: '$1' is not installed. Please install '$1'." >&2
Expand All @@ -16,6 +18,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 +43,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