From 167990df783a22d6aaf9edceb631e8af7ebfb7f9 Mon Sep 17 00:00:00 2001 From: dedsecrattle Date: Tue, 24 Sep 2024 19:51:43 +0800 Subject: [PATCH] Add Dockerfile --- backend/question-service/.dockerignore | 1 + .../question-service/{.env_template => .env.sample} | 4 ++-- backend/question-service/Dockerfile | 13 +++++++++++++ backend/question-service/package.json | 3 ++- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 backend/question-service/.dockerignore rename backend/question-service/{.env_template => .env.sample} (71%) create mode 100644 backend/question-service/Dockerfile diff --git a/backend/question-service/.dockerignore b/backend/question-service/.dockerignore new file mode 100644 index 0000000000..40b878db5b --- /dev/null +++ b/backend/question-service/.dockerignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/backend/question-service/.env_template b/backend/question-service/.env.sample similarity index 71% rename from backend/question-service/.env_template rename to backend/question-service/.env.sample index 40cfa0baea..be0283230e 100644 --- a/backend/question-service/.env_template +++ b/backend/question-service/.env.sample @@ -1,6 +1,6 @@ -DB_CLOUD_URI="Production MongoDB URI" +DB_CLOUD_URI= DB_LOCAL_URI="mongodb://127.0.0.1:27017/peerprepQuestionServiceDB" PORT=3000 # Will use cloud MongoDB Atlas database -ENV=DEV +ENV=PROD diff --git a/backend/question-service/Dockerfile b/backend/question-service/Dockerfile new file mode 100644 index 0000000000..7e47680ee9 --- /dev/null +++ b/backend/question-service/Dockerfile @@ -0,0 +1,13 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY package*.json . + +RUN npm install + +COPY . . + +EXPOSE 3000 + +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/backend/question-service/package.json b/backend/question-service/package.json index ee1b782186..c4a18ba18a 100644 --- a/backend/question-service/package.json +++ b/backend/question-service/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "dev": "nodemon ./src/server.ts" + "dev": "nodemon ./src/server.ts", + "start": "tsc && node ./dist/server.js" }, "keywords": [], "author": "",