Skip to content

Commit

Permalink
make docker image work
Browse files Browse the repository at this point in the history
  • Loading branch information
pelazas committed Feb 22, 2024
1 parent 76ab05b commit cc77134
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

questiongeneratorservice:
container_name: qgservice-${teamname:-defaultASW}
image: pelazas1/questiongenerator:latest
profiles: ["dev", "prod"]
build: ./game/qgservice
depends_on:
- mongodb
ports:
- "8003:8003"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
Expand All @@ -55,6 +69,7 @@ services:
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QG_SERVICE_URL: http://qgservice:8003

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand Down
6 changes: 3 additions & 3 deletions game/qgservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/userservice
WORKDIR /usr/src/questiongeneratorservice

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
Expand All @@ -14,7 +14,7 @@ RUN npm install
COPY . .

# Expose the port the app runs on
EXPOSE 8001
EXPOSE 8003

# Define the command to run your app
CMD ["node", "user-service.js"]
CMD ["node", "qg-service.js"]
4 changes: 2 additions & 2 deletions game/qgservice/package-lock.json

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

6 changes: 3 additions & 3 deletions game/qgservice/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "userservice",
"name": "qgservice",
"version": "1.0.0",
"description": "User service, in charge of handling users in the application",
"description": "Question generator service",
"main": "service.js",
"scripts": {
"start": "node user-service.js",
"start": "node qg-service.js",
"test": "jest"
},
"repository": {
Expand Down
8 changes: 7 additions & 1 deletion game/qgservice/qg-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb';
mongoose.connect(mongoUri);


app.get('/', (req, res) => {
res.json({
"hi":"question generator"
})
})

/*
// Function to validate required fields in the request body
function validateRequiredFields(req, requiredFields) {
Expand Down Expand Up @@ -47,7 +53,7 @@ app.post('/adduser', async (req, res) => {
*/

const server = app.listen(port, () => {
console.log(`User Service listening at http://localhost:${port}`);
console.log(`Question generator Service listening at http://localhost:${port}`);
});

// Listen for the 'close' event on the Express.js server
Expand Down

0 comments on commit cc77134

Please sign in to comment.