Skip to content

Commit

Permalink
Merge pull request #173 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Trying to deploy using https
  • Loading branch information
paulasuarezp authored May 1, 2023
2 parents 7227dad + 34073f5 commit f63e98b
Show file tree
Hide file tree
Showing 23 changed files with 329 additions and 186 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/lomap_es2c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Create env
run: |
cd restapi
touch .env
echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env
cat .env
- run: npm --prefix webapp install
- run: npm --prefix restapi install
- run: npm --prefix webapp run build
Expand All @@ -56,7 +50,7 @@ jobs:
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
API_URI: http://${{ secrets.DEPLOY_HOST }}:5000/api
API_URI: https://${{ secrets.DEPLOY_HOST }}:5000/api
with:
name: arquisoft/lomap_es2c/webapp
username: ${{ github.actor }}
Expand All @@ -67,7 +61,8 @@ jobs:
docker-push-restapi:
name: Push restapi Docker Image to GitHub Packages
env:
DATABASE_USER: ${{ secrets.DATABASE_URL }}
SSL_CERT: ${{ secrets.SSL_CERT }}
SSL_PRIVKEY: ${{ secrets.SSL_PRIVKEY }}
runs-on: ubuntu-latest
needs: [e2e-tests]
steps:
Expand All @@ -80,7 +75,7 @@ jobs:
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
registry: ghcr.io
workdir: restapi
buildargs: DATABASE_URL
buildargs: SSL_CERT,SSL_PRIVKEY
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
Expand Down
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ yarn-error.log*
.vscode

#documentation build does not go into master
docs/build

restapi/.env
webapp/lomapes2c.eastus.cloudapp.azure.com.key
webapp/lomapes2c.eastus.cloudapp.azure.com.crt
docs/build
2 changes: 1 addition & 1 deletion docker-compose-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
restapi:
image: ghcr.io/arquisoft/lomap_es2c/restapi:latest
ports:
- "5000:5000"
- "5001:5001"
webapp:
image: ghcr.io/arquisoft/lomap_es2c/webapp:latest
ports:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
restapi:
build: ./restapi
ports:
- "5000:5000"
- "5001:5001"
webapp:
build: ./webapp
ports:
Expand Down
4 changes: 3 additions & 1 deletion docs/11_technical_risks.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ List of risks and/or technical debts, probably including suggested measures to m

=== Technical Debts

Al comienzo del proyecto es difícil especificar alguna duda técnica. No conocemos de antemano cuál será el resultado y final y que herramientas o tecnologías vamos a utilizar finalmente. Guiados por la intención de desarrollar el proyecto con las utilidades ya mencionadas la única duda en este punto es la dependencia de nuestra aplicación con servicios externos a nosotros (APIs) y de imposible control por nuestra parte.
* La principal duda técnica es la dependencia de Inrupt. Durante el desarrollo del trabajo hemos detectado mucha inestabilidad en sus servicios. En ocasiones tiene tiempos de respuesta muy altosmás, es una API en desarrollo por lo que no podemos asegurar que sea perfectamente fucnional o que vaya a cambiar significativamente en el futuro y nuestra aplicación deje de funcionar.
* La interoperabilidad nos genera muchas dudas debido a que ni si quiera se ha alcanzado un acuerdo firme. Se han tomado decisiones sin meditación a su respecto y puede generar problemas. Consideramos que el estandar de LoMap no ha tenido suficiente tiempo de desarrollo como para ser óptimo.
* Nos ha sido imposible hacer una comprobación exhaustiva de bugs o la inclusión de funcionalidad extra debido al poco tiempo existente para el desarrollo del proyecto en comparación con la problemática percibida en general al usar las tecnologías impuestas por el profesorado.


Binary file added docs/images/Logo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions restapi/fullchain.pem
Original file line number Diff line number Diff line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: 2 additions & 1 deletion restapi/package-lock.json

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

6 changes: 6 additions & 0 deletions restapi/privkey.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg35MWkZkaf3h6UVzc
pqkTrCYBEmcEHPfDwbhCYD3mHDehRANCAARkuePITA4iqcKIe9KE4jhM2ljVcB1L
UePKvVz0aRiXROedrI0R7CXt0p/Fq8FHqRx6I0v1iDxa9tZl+QUV1IBs
-----END PRIVATE KEY-----

36 changes: 27 additions & 9 deletions restapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import cors from 'cors';
import bp from 'body-parser';
import promBundle from 'express-prom-bundle';
import api from "./api";
import dotenv from 'dotenv';
dotenv.config();
const mongoose = require('mongoose');
const https = require('https');
const fs = require('fs');


const app: Application = express();
const port: number = Number.parseInt(`${process.env.PORT}`) || 5000;
const httpPort = 5000;
const httpsPort = 5001;

const metricsMiddleware: RequestHandler = promBundle({ includeMethod: true });
app.use(metricsMiddleware);
Expand All @@ -29,15 +30,32 @@ app.use(bp.json());

app.use("/api", api)

app.use(cors({
origin: ['http://localhost:3000', 'http://20.169.248.119:3000'],
credentials:true
}));
app.use(cors());

const options = {
key: fs.readFileSync("./privkey.pem"),
cert: fs.readFileSync("./fullchain.pem")
};

app.use((req, res, next) => {
if (req.secure) {
next();
} else {
res.redirect(`https://${req.headers.host}${req.url}`);
}
});

app.listen(port, (): void => {
console.log('Restapi listening on ' + port);
https.createServer(options, app).listen(httpsPort, () => {
console.log(`Restapi server started on port ${httpsPort}`);
}).on("error", (error: Error) => {
console.error("Error occured: " + error.message);
});

app.listen(httpPort, (): void => {
console.log('Restapi listening on ' + httpPort);
}).on("error", (error: Error) => {
console.error('Error occured: ' + error.message);
});


export default app;
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ sonar.projectVersion=1.0.4
sonar.coverage.exclusions=**/*.test.tsx,**/*.test.ts
sonar.sources=webapp/src/components,restapi
sonar.sourceEncoding=UTF-8
sonar.exclusions=node_modules/**
sonar.exclusions=node_modules/**,restapi/server.ts
sonar.typescript.lcov.reportPaths=**/coverage/lcov.info
2 changes: 1 addition & 1 deletion webapp/e2e/steps/login-form.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineFeature, loadFeature } from 'jest-cucumber';
import puppeteer from "puppeteer";

const feature = loadFeature('./e2e/features/login-form.feature');
const apiEndPoint= process.env.REACT_APP_URI|| 'http://localhost:3000'
const apiEndPoint= 'http://localhost:3000'

let page: puppeteer.Page;
let browser: puppeteer.Browser;
Expand Down
2 changes: 1 addition & 1 deletion webapp/e2e/steps/register-form.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineFeature, loadFeature } from 'jest-cucumber';
import puppeteer from "puppeteer";

const feature = loadFeature('./e2e/features/register-form.feature');
const apiEndPoint= process.env.REACT_APP_URI|| 'http://localhost:3000'
const apiEndPoint= 'http://localhost:3000'

let page: puppeteer.Page;
let browser: puppeteer.Browser;
Expand Down
Loading

0 comments on commit f63e98b

Please sign in to comment.