Skip to content

Commit

Permalink
Assignment 5
Browse files Browse the repository at this point in the history
  • Loading branch information
loyhongshenggg committed Nov 4, 2023
1 parent 87e0686 commit 3ec9f47
Show file tree
Hide file tree
Showing 1,226 changed files with 2,276 additions and 197,387 deletions.
38 changes: 8 additions & 30 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Deploy MultiDocker
on:
pull_request:
branches:
- master
push:
branches:
- master
Expand All @@ -16,47 +13,28 @@ jobs:

- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Create env file for userservice test
run: echo -e "${{ secrets.USER_SERVICE_TEST_ENV_FILE}}" > ./user-service/.env

- name: Build PostgreSQL Docker image
working-directory: ./user-service
run: |
docker build -f Dockerfile.postgres-db -t user-service-psql .
- name: Create env file for user service
run: echo -e "${{ secrets.USER_SERVICE_ENV_FILE }}" > ./user-service/.env

- name: Start PostgreSQL Docker container
working-directory: ./user-service
run: |
docker run -p 1111:5432 -e POSTGRES_PASSWORD=123 --name user-service-db -d user-service-psql
sleep 10
- name: Create env file for matching service
run: echo -e "${{ secrets.MATCHING_SERVICE_ENV_FILE }}" > ./matching-service/.env

- name: Build and test user-service
working-directory: ./user-service
run: |
npm ci
npm run test
- name: Create env file for collaboration service
run: echo -e "${{ secrets.COLLABORATION_SERVICE_ENV_FILE }}" > ./collaboration-service/.env

- name: Stop and remove PostgreSQL Docker container
run: |
docker stop user-service-db
docker rm user-service-db
- name: Build and test client
working-directory: ./client
run: |
npm ci
npm install
npm test
- name: Build and test question-service
working-directory: ./question-service
run: |
npm ci
npm install
npm test
- name: Prevent PR merge
if: github.event.pull_request.merged == 'true'
run: echo "This PR cannot be merged. Please make necessary changes."
# - name: Build Docker containers
# run: docker-compose -f docker-compose.yml build

Expand Down
5 changes: 0 additions & 5 deletions client/.env.example

This file was deleted.

26 changes: 5 additions & 21 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
FROM node:16-alpine as builder
WORKDIR '/client'
WORKDIR './client'
COPY ./package.json ./
RUN npm install
COPY . .
RUN npm ci
RUN npm run build

FROM nginx:alpine
COPY --from=builder /client/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
CMD ["nginx", "-g", "daemon off;"]

# To test it alone, run "docker build -t client ." inside /client
# To run the image, run "docker run -d -p 3002:3002 client" inside /client

# For dev mode
# FROM node:16-alpine as builder
# WORKDIR './client'
# COPY ./package.json ./
# RUN npm install
# COPY . .
# # RUN npm run build // only use for deployment
# EXPOSE 3002
# CMD ["npm", "start"]
# RUN npm run build // only use for deployment
EXPOSE 3002
CMD ["npm", "start"]
31 changes: 0 additions & 31 deletions client/nginx.conf

This file was deleted.

31 changes: 7 additions & 24 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"axios": "^1.4.0",
"axios-mock-adapter": "^1.22.0",
"babel-jest": "^29.7.0",
"dotenv": "^16.3.1",
"fetch-mock": "^9.11.0",
"framer-motion": "^10.12.16",
"identity-obj-proxy": "^3.0.0",
Expand Down
31 changes: 30 additions & 1 deletion client/src/api/Auth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from "axios";
import Cookies from 'js-cookie';
import { authServiceURL } from "./config";

const baseURL = process.env.REACT_APP_USER_SERVICE_URL;
const baseURL = authServiceURL;


function epochToDays(epochTimestamp) {
Expand Down Expand Up @@ -126,6 +127,34 @@ export const getUserProfile = async () => {
}
}

export const getSpecificUserProfile = async (uuid) => {
var curr_user_token = Cookies.get('token');

const config = {
method: 'post',
url: baseURL + '/user',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${curr_user_token}`
},
data: {
uuid: uuid
}
};

try {
const response = await axios(config);
if (response.status === 200) {
const data = response.data.res;
return data;
} else {
console.error('Failed to retrieve user profile. Status:', response.status);
}
} catch (error) {
console.error('Error while fetching user profile:', error);
}
}

export const editProfile = async (input) => {
var curr_user_token = Cookies.get('token');
var uuid = Cookies.get('uuid');
Expand Down
Loading

0 comments on commit 3ec9f47

Please sign in to comment.