Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

62 historical data #68

Merged
merged 10 commits into from
Apr 2, 2024
18 changes: 17 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice
docker-push-recordservice:
name: Push record service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_en1b/recordservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/recordservice
docker-push-gatewayservice:
name: Push gateway service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand Down Expand Up @@ -107,7 +123,7 @@ jobs:
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-questionservice,docker-push-questiongenerator]
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-questionservice,docker-push-questiongenerator,docker-push-recordservice]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

recordservice:
container_name: recordservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_en1b/recordservice:latest
profiles: ["dev", "prod"]
build: ./users/recordservice
depends_on:
- mongodb
ports:
- "8004:8004"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

questionservice:
container_name: questionservice-${teamname:-defaultASW}
Expand All @@ -74,6 +88,7 @@
- mongodb
- userservice
- authservice
- recordservice
- questionservice
ports:
- "8000:8000"
Expand All @@ -83,6 +98,7 @@
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QUESTION_SERVICE_URL: http://questionservice:8003
RECORD_SERVICE_URL: http://recordservice:8004

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand Down
22 changes: 22 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const port = 8000;
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const questionServiceUrl = process.env.QUESTION_SERVICE_URL || 'http://localhost:8003';
const recordServiceUrl = process.env.RECORD_SERVICE_URL || 'http://localhost:8004';

app.use(cors());
app.use(express.json());
Expand Down Expand Up @@ -52,6 +53,27 @@ app.get('/questions', async (req, res) => {
}
});

app.post('/addrecord', async(req, res) => {
try {
// Forward the record request to the record service
const recordResponse = await axios.post(recordServiceUrl+'/addrecord', req.body);
res.send(recordResponse.data);
} catch (error) {
res.send(error);
}
});

app.get('/records/:user', async(req, res)=>{
try {
const user = req.params.user;
// Forward the record request to the record service
const recordResponse = await axios.get(recordServiceUrl + '/records/' + user);
res.json(recordResponse.data);
} catch (error) {
res.send(error);
}
});

// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
2 changes: 2 additions & 0 deletions users/recordservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
20 changes: 20 additions & 0 deletions users/recordservice/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/recordervice

# 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 8004

# Define the command to run your app
CMD ["node", "record-service.js"]
Loading
Loading