Skip to content

Commit fedb708

Browse files
Merge pull request #125 from dipamsen/import-archive
Add convenience for running import-papers script
2 parents 8e5ef23 + 9bd5bac commit fedb708

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ A user is considered as an admin if they are a part of the team `GH_ORG_TEAM_SLU
129129
1. Change directory to `crawler/` and run `go mod tidy`.
130130
2. Run the crawler by running `go run crawler.go`. (Make sure you are connected to the campus network)
131131
3. This will generate a `qp.tar.gz` file. Transfer this file to the server's `backend/` folder.
132-
4. In the backend, run `cargo run --bin import-papers` to import the data into the database. (Make sure the database is set up and running)
132+
4. (Development): In the backend, run `cargo run --bin import-papers` to import the data into the database. (Make sure the database is set up and running)\
133+
(Production): In the backend, run `./import_papers.sh ./qp.tar.gz` to run the import script in the docker container running the application.
133134

134135
## Deployment
135136

backend/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ COPY metaploy/ ./
2828
RUN chmod +x ./postinstall.sh
2929

3030
COPY --from=builder /src/target/x86_64-unknown-linux-musl/release/iqps-backend .
31+
COPY --from=builder /src/target/x86_64-unknown-linux-musl/release/import-papers .
3132

3233
CMD ["./postinstall.sh", "./iqps-backend"]

backend/import_papers.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $# -ne 1 ]]; then
5+
echo "Usage: $0 <file.tar.gz>"
6+
exit 1
7+
fi
8+
9+
ARCHIVE_PATH="$1"
10+
SERVICE="iqps-backend"
11+
DEST_PATH="/app/qp.tar.gz"
12+
13+
echo "Copying '$ARCHIVE_PATH' to '$SERVICE'..."
14+
docker compose cp "$ARCHIVE_PATH" "$SERVICE":"$DEST_PATH"
15+
16+
echo "Running import-papers..."
17+
docker compose exec "$SERVICE" ./import-papers
18+
19+
echo "Done!"

0 commit comments

Comments
 (0)