Skip to content

Commit 399d554

Browse files
Merge pull request #2 from InternComp/hs-integrate-backend
For MVP
2 parents 5df45ba + f8fb6c2 commit 399d554

8 files changed

Lines changed: 89 additions & 30 deletions

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
path = interncomp-backend
77
url = https://github.com/InternComp/interncomp-backend.git
88
branch = main
9-
[submodule "interncomp-database"]
10-
path = interncomp-database
11-
url = https://github.com/InternComp/interncomp-database.git
12-
branch = main
139
[submodule "interncomp-documentation"]
1410
path = interncomp-documentation
1511
url = https://github.com/InternComp/interncomp-documentation.git

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22

33
A parent repo for interncomp project
44

5-
# Initial Setup (To be tested yet)
5+
# Initial Setup
66

7-
Use following to clone:
7+
## Cloning the project
8+
9+
Use following command to clone:
810

911
```
1012
git clone --recurse-submodules https://github.com/InternComp/interncomp-platform.git
1113
```
1214

13-
To update all:
15+
To update all repos:
1416

1517
```
1618
git submodule update --remote
1719
```
20+
21+
## Setup .env files
22+
23+
Setup .env files as discussed in assignment submission.
24+
25+
## Running the code
26+
27+
See manual-setup.md in this repo.
28+
29+

docker-compose.dev.yml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,43 @@ services:
77
- ./interncomp-frontend:/app
88
- /app/node_modules # Avoid overwriting node_modules
99
ports:
10-
- '5173:5173' # Vite default port
10+
- '4000:4000' # Frontend is being set at port 4000 in vite.config.js
1111
networks:
1212
- app-network
1313

14-
# backend:
15-
# build:
16-
# context: ./interncomp-backend
17-
# dockerfile: Dockerfile.dev
18-
# volumes:
19-
# - ./interncomp-backend:/app
20-
# - /app/node_modules # Avoid overwriting node_modules
21-
# ports:
22-
# - '4000:3000' # Map backend container's port 3000 to local port 4000
23-
# depends_on:
24-
# - db
25-
# environment:
26-
# DATABASE_URL: postgres://postgres:password@db:5432/interncomp-database
27-
# networks:
28-
# - app-network
29-
30-
db:
14+
postgres:
3115
image: postgres:15-alpine
3216
environment:
3317
POSTGRES_USER: postgres
3418
POSTGRES_PASSWORD: password
3519
POSTGRES_DB: interncomp-database
3620
ports:
37-
- '5432' # Map some automatically chosen machine port to container's PostgreSQL port 5432
21+
- '5433:5432' # Map some automatically chosen machine port to container's PostgreSQL port 5432
3822
volumes:
3923
- pgdata:/var/lib/postgresql/data
4024
networks:
4125
- app-network
4226

27+
backend:
28+
build:
29+
context: ./interncomp-backend
30+
dockerfile: Dockerfile.dev
31+
volumes:
32+
- ./interncomp-backend:/app
33+
- /app/node_modules # Avoid overwriting node_modules
34+
ports:
35+
- '3000:3000' # Map backend container's port 3000 to local port 3000
36+
depends_on:
37+
- postgres
38+
environment:
39+
DATABASE_URL: postgres://postgres:password@postgres:5432/interncomp-database
40+
# command: sh -c "npm install && npx prisma migrate dev && npm run seed && "./wait-for-it.sh postgres:5432 -- npm run dev""
41+
networks:
42+
- app-network
43+
# entrypoint: ["/bin/sh", "-c", "./wait-for-it.sh postgres:5432 -- npm run dev"]
44+
45+
46+
4347
networks:
4448
app-network:
4549
driver: bridge

interncomp-database

Lines changed: 0 additions & 1 deletion
This file was deleted.

interncomp-documentation

interncomp-frontend

Submodule interncomp-frontend updated 52 files

manual-setup.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Running manually (Deprecated, for archivial purpose only)
2+
3+
### Frontend
4+
5+
**Setup (One Time Only)**
6+
7+
Assuming Node 20 LTS is installed
8+
9+
1. Go to frontend repo in terminal. For eg: `cd interncomp-frontend`.
10+
2. Do `git pull` just in case.
11+
3. Run `npm install`
12+
13+
**Running frontend**
14+
To run, use `npm run dev`
15+
16+
17+
### Backend
18+
19+
Firstly, we need to setup database.
20+
Assuming Postgresql is installed, and make sure service is running.
21+
22+
Run in terminal: `sudo -u postgres psql -U postgres`
23+
24+
Then in postgres:
25+
```bash
26+
postgres=# CREATE USER test WITH PASSWORD 'password';
27+
CREATE ROLE
28+
postgres=# GRANT ALL PRIVILEGES ON DATABASE "interncomp-database" TO test;
29+
GRANT
30+
postgres=# ALTER USER test WITH SUPERUSER;
31+
ALTER ROLE
32+
postgres=# exit
33+
```
34+
35+
Continue with backend setup
36+
37+
**Backend Setup (One Time Only)**
38+
39+
Assuming Node 20 LTS and Postgresql is installed
40+
41+
```bash
42+
npx prisma generate
43+
npm install
44+
npx prisma migrate dev --name init
45+
```
46+
47+
**Running backend**
48+
To run, use `npm run dev`

0 commit comments

Comments
 (0)