Skip to content

Commit

Permalink
Docker Files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrrsin committed Mar 10, 2024
1 parent c9f4999 commit 15764a8
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 9 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [e2e-tests]
#needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -59,13 +59,30 @@ jobs:
registry: ghcr.io
workdir: webapp
buildargs: API_URI
docker-push-questionservice:
name: Push question service Docker Image to GitHub Packages
runs-on: ARM64
permissions:
contents: read
packages: write
# needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_en1a/usequestionservicerservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questionservice
docker-push-authservice:
name: Push auth service Docker Image to GitHub Packages
runs-on: ARM64
permissions:
contents: read
packages: write
needs: [e2e-tests]
#needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -82,7 +99,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [e2e-tests]
#needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -99,7 +116,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [e2e-tests]
#needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand Down
16 changes: 15 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@ services:
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
# platform: linux/arm64

questionservice:
container_name: questionservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_en1a/questionservice:latest
profiles: ["dev", "prod"]
build: ./questionservice
depends_on:
- mongodb
ports:
- "8010:8010"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
# platform: linux/arm64
gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_en1a/gatewayservice:latest
Expand All @@ -58,6 +71,7 @@ services:
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QUESTION_SERVICE_URL: http://questionservice:8010
# platform: linux/arm64

webapp:
Expand Down
2 changes: 2 additions & 0 deletions questionservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
20 changes: 20 additions & 0 deletions questionservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node.js runtime as a parent image
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/questionservice

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the app source code to the working directory
COPY . .

# Expose the port the app runs on
EXPOSE 8002

# Define the command to run your app
CMD ["node", "auth-service.js"]
18 changes: 18 additions & 0 deletions users/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ app.get('/rankings', async (req, res) => {
}
})


app.post("/addpoints", async (req, res) => {
try {
validateRequiredFields(req, ['username']);
const user = await User.findOne({
username: req.body.username
});
if (!user) {
throw new Error('User not found');
}
user.points += 1;
await user.save();
res.status(200).json(user);
} catch (error) {
res.status(400).json({ error: error.message });
}
});

app.post('/adduser', async (req, res) => {
try {
// Check if required fields are present in the request body
Expand Down
4 changes: 2 additions & 2 deletions webapp/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
content="Web site of WIQ by HappySw"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
Expand All @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>WIQ</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/MainPage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import useIsAuthenticated from "react-auth-kit/hooks/useIsAuthenticated";
import useAuthUser from 'react-auth-kit/hooks/useAuthUser';
import Game from './Game';

import { useNavigate } from 'react-router-dom';

const MainPage = () => {
Expand All @@ -16,7 +16,7 @@ const MainPage = () => {
}else{
logged = true;
}
console.log(logged);

}
, [logged]);

Expand Down

0 comments on commit 15764a8

Please sign in to comment.