Skip to content

Commit

Permalink
Merge pull request #233 from Arquisoft/Despliegue
Browse files Browse the repository at this point in the history
Despliegue
  • Loading branch information
mariolada authored May 3, 2022
2 parents 45a5b2b + 89424bb commit 2b8362a
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 136 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/pruebaDeploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
name: CI for ASW2122
on:
release:
types: [published]
jobs:
docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Publish to Registry
uses: elgohr/[email protected]
with:
name: arquisoft/dede_es2a/webapp
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
registry: ghcr.io
workdir: webapp
docker-push-restapi:
name: Push restapi Docker Image to GitHub Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Publish to Registry
uses: elgohr/[email protected]
with:
name: arquisoft/dede_es2a/restapi
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
registry: ghcr.io
workdir: restapi
deploy-webapp:
needs: [docker-push-restapi,docker-push-webapp]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy webapp
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.DEPLOY_KEY }}
heroku_app_name: "dede-es2a-webapp"
heroku_email: ${{ secrets.EMAIL }}
usedocker: true
appdir: "webapp"
deploy-restapi:
needs: [docker-push-restapi,docker-push-webapp]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy restapi
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.DEPLOY_KEY }}
heroku_app_name: "dede-es2a-restapi"
heroku_email: ${{ secrets.EMAIL }}
usedocker: true
appdir: "restapi"
*/
43 changes: 43 additions & 0 deletions .github/workflows/pruebaSinDocker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI for ASW2122
on:
release:
types: [published]
jobs:
deploy-webapp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy webapp
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.DEPLOY_KEY }}
heroku_app_name: "dede-es2a-webapp"
heroku_email: ${{ secrets.EMAIL }}
usedocker: true
appdir: "webapp"
docker_build_args: |
API_URI
env:
API_URI: "https://dede-es2a-restapi.herokuapp.com"
deploy-restapi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy restapi
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.DEPLOY_KEY }}
heroku_app_name: "dede-es2a-restapi"
heroku_email: ${{ secrets.EMAIL }}
usedocker: true
appdir: "restapi"
docker_build_args: |
MONGO_URI
CLOUDINARY_NAME
CLOUDINARY_API_KEY
CLOUDINARY_API_SECRET
env:
MONGO_URI: ${{ secrets.MONGO_URI }}
CLOUDINARY_NAME: ${{ secrets.CLOUD_NAME }}
CLOUDINARY_API_KEY: ${{ secrets.CLOUD_KEY }}
CLOUDINARY_API_SECRET: ${{ secrets.CLOUD_SECRET }}
3 changes: 2 additions & 1 deletion restapi/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules
/node_modules
.env
12 changes: 12 additions & 0 deletions restapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ LABEL org.opencontainers.image.source https://github.com/Arquisoft/dede_es2a
COPY . /app
WORKDIR /app

ARG MONGO_URI="mongodb://mongoserver:27017/api"
ENV MONGO_URI=$MONGO_URI

ARG CLOUDINARY_NAME="name"
ENV CLOUDINARY_NAME=$CLOUDINARY_NAME

ARG CLOUDINARY_API_KEY="apikey"
ENV CLOUDINARY_API_KEY=$CLOUDINARY_NAME

ARG CLOUDINARY_API_SECRET="secret"
ENV CLOUDINARY_API_SECRET=$CLOUDINARY_API_SECRET


#Install the dependencies
RUN npm install
Expand Down
16 changes: 10 additions & 6 deletions restapi/modules/cloudinary.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
const cloudinary = require('cloudinary').v2;
require('dotenv').config()

/*
var name: string = process.env.CLOUDINARY_NAME || 'name'
var api_key:string = process.env.CLOUDINARY_API_KEY || 'key'
var secret:string = process.env.CLOUDINARY_API_SECRET || 'secret'

export function config(){
cloudinary.config({
cloud_name : process.env.CLOUDINARY_NAME,
api_key : process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
cloud_name : name,
api_key : api_key,
api_secret: secret
});
}*/
}


/*
export function config(){
cloudinary.config({
cloud_name : 'dypp8pt31',
api_key : '321597164512969',
api_secret: 'sM2uhnqaS53Sq9_HsPDLK63FS7I'
});
}
}*/


export function configTest(){
Expand Down
11 changes: 5 additions & 6 deletions restapi/modules/gestorDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
const mongoose = require('mongoose')
require('dotenv').config()

const database_uri = process.env.DB_CONNECT
const database_test_uri = 'mongodb+srv://admin:<password>@cluster.mf7ve.mongodb.net/myFirstDatabase?retryWrites=true&w=majority'


export function connect(){
mongoose.connect('mongodb+srv://admin:[email protected]/myFirstDatabase?retryWrites=true&w=majority', {

mongoose.connect(process.env.MONGO_URI!, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() =>{
console.log("Database connected")
})
;
});
}

export function connectTest(){
Expand Down
4 changes: 2 additions & 2 deletions restapi/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let {config} = require('./modules/cloudinary');

const options: cors.CorsOptions = {
origin: ['http://localhost:3000']
//origin: ['https://dede-es2a-webapp.herokuapp.com']
//origin: 'https://dede-es2a-webapp.herokuapp.com' || 'http://localhost:3000'
};

const metricsMiddleware:RequestHandler = promBundle({includeMethod: true});
Expand All @@ -27,7 +27,7 @@ app.use(metricsMiddleware);
bd.connect();
config();

app.use(cors(options));
app.use(cors());
app.use(bp.json());

app.use("/juguete", jugueteRouter);
Expand Down
2 changes: 2 additions & 0 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ WORKDIR /app
#Install the dependencies
RUN npm install

ARG API_URI="http://localhost:5000"
ENV REACT_APP_API_URI=$API_URI

#Crete an optimized version of the webapp
RUN npm run build
Expand Down
Loading

0 comments on commit 2b8362a

Please sign in to comment.