-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Agregado docker-compose.yml con ejemplo para producción
El archivo incluye ejemplo para PHP y NodeJS
- Loading branch information
Showing
8 changed files
with
492 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/vendor/* | ||
/vendor/* | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: "3" | ||
services: | ||
dte-api: | ||
restart: "always" | ||
image: chialab/php:7.3-fpm | ||
command: bash -c "composer install && php -S 0.0.0.0:8000 index.php" | ||
expose: | ||
- "8000" | ||
volumes: | ||
- .:/var/www/html | ||
|
||
# APP CON EJEMPLO DE NODEJS | ||
app-node: | ||
build: | ||
context: ./ejemplos/node | ||
dockerfile: Dockerfile | ||
ports: # Debes usar el mismo puerto que tu servidor | ||
- "3000:3000" | ||
depends_on: | ||
- dte-api | ||
volumes: | ||
- ./ejemplos/node:/home/node/dte # Montamos el ejemplo desde fuera en el directorio de node del contenedor | ||
- /home/node/dte/node_modules | ||
|
||
# APP CON EJEMPLO DE PHP | ||
app-php: | ||
image: php:8-apache | ||
ports: # Debes usar el mismo puerto que tu servidor | ||
- "3001:80" | ||
depends_on: | ||
- dte-api | ||
volumes: | ||
- ./ejemplos/php/:/var/www/html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:12.13.1-alpine | ||
|
||
WORKDIR /home/node/dte | ||
|
||
COPY ./package*.json ./yarn.lock ./ | ||
|
||
RUN apk update && apk add yarn | ||
|
||
RUN yarn install | ||
|
||
COPY . . | ||
|
||
CMD ["yarn", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const http = require('http'); | ||
const express = require('express'); | ||
|
||
const app = express(); | ||
// PUERTO QUE USARÁ EXPRESS | ||
const port = 3000; | ||
|
||
// OPCIONES DEL MODULO HTTP PARA REALIZAR LA LLAMADA | ||
const options = { | ||
hostname: 'dte-api', | ||
port: 8000, | ||
path: '/dte/estado', | ||
method: 'POST' | ||
} | ||
|
||
app.get('/', (req, res) => { | ||
// LLAMADA A HTTP-DTE | ||
const apiReq = http.request(options, apiRes => { | ||
let str = ''; | ||
|
||
apiRes.on('data', data => str += data); | ||
|
||
apiRes.on('end', function () { | ||
res.send(str); | ||
// SI RECIBES EL ERROR: | ||
// { | ||
// "name":"FIRMA_NO_BASE64", | ||
// "message":"La firma debe estar codificada en base64", | ||
// "statusCode":400 | ||
// } | ||
// ES PORQUE AMBOS CONTAINERS SE HAN COMUNICADO CORRECTAMETNE | ||
}); | ||
}); | ||
|
||
apiReq.end(); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Servidor nodejs escuchando en: http://localhost:${port}`) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "node", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "node ./index.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.17.1" | ||
} | ||
|
||
} |
Oops, something went wrong.