Skip to content

Commit

Permalink
feat(docker): adding config and fixing the docker issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Agarwal authored and Aman Agarwal committed Nov 27, 2023
1 parent 828602b commit 0253611
Show file tree
Hide file tree
Showing 11 changed files with 6,951 additions and 6,404 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ COPY . .
# Build the Next.js app
RUN npm run build

COPY /.next/standalone ./

# Expose the desired port
EXPOSE 3000

Expand Down
9 changes: 9 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const wpcasBackendUrl =
process.env.WPCAS_SERVICE_BACKEND_IP || 'http://localhost:3000';
const marketBackendUrl =
process.env.MARKETPLACE_SERVICE_BACKEND_IP || 'http://localhost:3000';

module.exports = {
wpcasBackendUrl,
marketBackendUrl,
};
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ services:
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- WPCAS_SERVICE_BACKEND_IP=http://localhost:4010
- MARKETPLACE_SERVICE_BACKEND_IP=http://localhost:4000
2,042 changes: 1,236 additions & 806 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"xlsx": "^0.18.5"
},
"devDependencies": {
"@commitlint/cli": "^16.3.0",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^16.2.4",
"@svgr/webpack": "^8.0.1",
"@tailwindcss/forms": "^0.5.4",
Expand Down
6 changes: 2 additions & 4 deletions src/components/questionBank/QuestionUploadAndDownload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import axios from 'axios';
import React, { MutableRefObject, useRef, useState } from 'react';
import { wpcasBackendUrl } from 'root/config';

import ButtonFill from '@/components/uiComponents/ButtonFill';
import ButtonOutline from '@/components/uiComponents/ButtonOutline';
Expand All @@ -26,10 +27,7 @@ const QuestionUploadAndDownload = () => {
formData.append('file', file);

// Make a POST request to backend
await axios.post(
'http://localhost:3000/api/question-bank/upload',
formData
);
await axios.post(`${wpcasBackendUrl}/api/question-bank/upload`, formData);

setShowSuccessPopUp(true);
} catch (error) {
Expand Down
17 changes: 7 additions & 10 deletions src/services/bultTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios';
import { toast } from 'react-toastify';
import { wpcasBackendUrl } from 'root/config';

type CompetencyItem = {
competency: string;
Expand All @@ -9,7 +10,7 @@ type CompetencyItem = {
export const downloadTemplate = async () => {
try {
const response = await axios.get(
'http://localhost:3000/api/question-bank/template'
`${wpcasBackendUrl}/api/question-bank/template`
);
const templateData = response?.data?.data;

Expand Down Expand Up @@ -49,15 +50,11 @@ export const uploadTemplate = async (
formData.append('file', file);

// Make a POST request to backend
await axios.post(
'http://localhost:3000/api/question-bank/upload',
formData,
{
headers: {
'Content-Type': 'multipart/form-data', // Set the content type to multipart/form-data
},
}
);
await axios.post(`${wpcasBackendUrl}/api/question-bank/upload`, formData, {
headers: {
'Content-Type': 'multipart/form-data', // Set the content type to multipart/form-data
},
});

setShowSuccessPopUp(true);
} catch (error) {
Expand Down
13 changes: 7 additions & 6 deletions src/services/configurationServices.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import axios from 'axios';
import { wpcasBackendUrl } from 'root/config';

export const getConfigurationList = async () => {
const data = await axios.get('http://localhost:3000/api/survey-config');
const data = await axios.get(`${wpcasBackendUrl}/api/survey-config`);
return data.data.data;
};

export const downloadUserList = async () => {
const data = await axios.get('http://localhost:3000/api/user-metadata');
const data = await axios.get(`${wpcasBackendUrl}/api/user-metadata`);
return data.data.data;
};

export const downloadAssessesList = async () => {
const data = await axios.get(
'http://localhost:3000/api/survey-config/user-mapping-sample'
`${wpcasBackendUrl}/api/survey-config/user-mapping-sample`
);
return data.data.data;
};

export const createSurveyConfig = async (payload: FormData) => {
await axios.post(`http://localhost:3000/api/survey-config`, payload, {
await axios.post(`${wpcasBackendUrl}/api/survey-config`, payload, {
headers: {
'Content-Type': 'multipart/form-data', // Set the content type to multipart/form-data
},
Expand All @@ -27,7 +28,7 @@ export const createSurveyConfig = async (payload: FormData) => {

export const updateSurveyConfig = async (id: string, payload: FormData) => {
await axios.patch(
`http://localhost:3000/api/survey-config/update/${id}`,
`${wpcasBackendUrl}/api/survey-config/update/${id}`,
payload,
{
headers: {
Expand All @@ -38,6 +39,6 @@ export const updateSurveyConfig = async (id: string, payload: FormData) => {
};

export const getUserList = async () => {
const data = await axios.get('http://localhost:3000/api/survey/home-screen');
const data = await axios.get(`${wpcasBackendUrl}/api/survey/home-screen`);
return data.data.data;
};
11 changes: 6 additions & 5 deletions src/services/getCompetency.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from 'axios';
import { toast } from 'react-toastify';
import { wpcasBackendUrl } from 'root/config';

import { FinalObjType } from '@/app/propTypes';

Expand All @@ -18,7 +19,7 @@ type QuestionType = {
export const getCompetency = async () => {
try {
const response = await axios.get(
'http://localhost:3000/api/admin-competency/names'
`${wpcasBackendUrl}/api/admin-competency/names`
);

const mappedData = response?.data?.data?.map(
Expand All @@ -38,10 +39,10 @@ export const getAllLevels = async (
) => {
try {
const questionsResponse = await axios.get(
`http://localhost:3000/api/question-bank?competencyId=${currentCompetencyId}`
`${wpcasBackendUrl}/api/question-bank?competencyId=${currentCompetencyId}`
);
const levelsResponse = await axios.get(
`http://localhost:3000/api/admin-competency/${currentCompetencyId}`
`${wpcasBackendUrl}/api/admin-competency/${currentCompetencyId}`
);

const questions = questionsResponse?.data?.data;
Expand Down Expand Up @@ -112,15 +113,15 @@ export const updateItemOnServer = async (
// Only include deleteQuestions if it's not empty
if (finalObj.deleteQuestions?.length === 0) {
await axios.post(
'http://localhost:3000/api/question-bank/updateMultipleQuestions',
`${wpcasBackendUrl}/api/question-bank/updateMultipleQuestions`,
{
createQuestions: finalObj.createQuestions,
updateQuestions: finalObj.updateQuestions,
}
);
} else {
await axios.post(
'http://localhost:3000/api/question-bank/updateMultipleQuestions',
`${wpcasBackendUrl}/api/question-bank/updateMultipleQuestions`,
finalObj
);
}
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"~/*": ["./public/*"]
"~/*": ["./public/*"],
"root/*": ["./*"]
},
"incremental": true,
"plugins": [
Expand Down
Loading

0 comments on commit 0253611

Please sign in to comment.