- Download and unzip the file for Assignment 4.
cd
into it. - Set up environment variables.
The unredacted environment variable
MONGO_CONNECTION_STRING
can be found in our Canvas submission for private variables.
-
frontend
- Save the frontend variables under
frontend/.env
.REACT_APP_BACKEND_URL=http://localhost:8080/api REACT_APP_USER_SERVICE_BACKEND_URL=http://localhost:8000/
- Save the frontend variables under
-
user-service
- Save the user-service variables twice in
backend/user-service/.env
andbackend/user-service/.env.docker
- backend/user-service/.env.docker
DATABASE_URL="postgresql://postgres:postgres@postgres:5432/peerprep?schema=public" PORT=8000 JWT_SECRET="secret" FRONTEND_URL="http://localhost:3000"
- backend/user-service/.env (need to change DATABASE_URL because we would not be in docker compose's network)
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/peerprep?schema=public" PORT=8000 JWT_SECRET="secret" FRONTEND_URL="http://localhost:3000"
- Save the user-service variables twice in
-
question-service
- Save the question-service variables under
backend/question-service/.env
MONGO_CONNECTION_STRING=<redacted> PORT=8080 FRONTEND_URL="http://localhost:3000"
- Save the question-service variables under
- Actually run it with Docker.
- Option 1 (recommended): Docker Compose
- cd into all frontend/backend services and type
npm install
docker-compose up
- cd into all frontend/backend services and type
- Option 2: Running individually with
docker
- Navigate to the folder of the zip file you unzipped previously.
cd backend/question-service
docker build . -t question-service && docker run -p 8080:8080 -d question-service
- Open another terminal tab. Repeat step 1.
cd backend/user-service
docker build . -t user-service && docker run -p 8000:8000 -d user-service
- Testing
- If you used option 1, the frontend should be up as well, navigate to http://localhost:3000 to see the results.
- If you used option 2, you can use some curl commands to verify the services work
- Question service:
curl localhost:8080/api/questions/1
- User service:
curl localhost:8000/currentUser
- Question service: