├── .gitignore ├── Docker-Tutorial.pdf ├── LICENSE ├── README.md ├── chuletas ├── cheat-sheet-v2.pdf ├── docker-cheat-sheet.pdf └── docker_cheatsheet_r3v2.pdf ├── ejemplos ├── ejem01 │ ├── Dockerfile │ ├── run.sh │ └── src │ │ ├── index.html │ │ ├── otra.html │ │ └── prueba.php ├── ejem02 │ └── run.sh ├── ejem03 │ └── run.sh ├── ejem04 │ └── docker-compose.yaml ├── ejem05 │ └── src │ │ └── index.php ├── ejem06 │ ├── apache-php │ │ └── Dockerfile │ ├── docker-compose.yml │ ├── mariadb │ │ ├── Dockerfile │ │ └── sql │ │ │ └── init-db.sql │ └── src │ │ ├── index.php │ │ └── test.php ├── ejem07 │ ├── code │ │ └── myapp │ │ │ └── index.php │ ├── config │ │ ├── nginx │ │ │ └── myapp.conf │ │ └── php │ │ │ └── php.ini │ ├── docker │ │ ├── docker-compose.yml │ │ ├── mariadb │ │ │ └── mariadb.sh │ │ ├── nginx │ │ │ └── nginx.sh │ │ ├── php │ │ │ ├── Dockerfile │ │ │ └── php.sh │ │ ├── phpmyadmin │ │ │ └── phpmyadmin.sh │ │ └── run.sh │ └── mariadb │ │ └── sql │ │ └── init-db.sql ├── ejem08 │ ├── Dockerfile │ ├── run.sh │ └── src │ │ ├── index.html │ │ ├── otra.html │ │ └── prueba.php ├── ejem09 │ ├── docker-compose.yml │ ├── reverse │ │ ├── Dockerfile │ │ └── nginx.conf │ ├── site1 │ │ ├── Dockerfile │ │ └── src │ │ │ └── index.html │ └── site2 │ │ ├── Dockerfile │ │ └── src │ │ └── index.html ├── ejem10 │ ├── docker-compose.yml │ ├── site1 │ │ ├── Dockerfile │ │ └── src │ │ │ └── index.html │ └── site2 │ │ ├── Dockerfile │ │ └── src │ │ └── index.html ├── ejem11 │ └── gs-rest-service │ │ ├── .classpath │ │ ├── .dockerignore │ │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ │ ├── .project │ │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.apt.core.prefs │ │ ├── org.eclipse.jdt.core.prefs │ │ ├── org.eclipse.m2e.core.prefs │ │ └── org.springframework.ide.eclipse.prefs │ │ ├── Dockerfile │ │ ├── LICENSE.txt │ │ ├── LICENSE.writing.txt │ │ ├── README.md │ │ ├── manifest.yml │ │ ├── mvnw │ │ ├── mvnw.cmd │ │ ├── pom.xml │ │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── restservice │ │ │ │ ├── Greeting.java │ │ │ │ ├── GreetingController.java │ │ │ │ ├── RestServiceApplication.java │ │ │ │ └── config │ │ │ │ └── SpringFoxConfig.java │ │ └── resources │ │ │ └── static │ │ │ └── index.html │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── restservice │ │ └── GreetingControllerTests.java ├── ejem12 │ └── dockervue │ │ ├── .browserslistrc │ │ ├── .editorconfig │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── babel.config.js │ │ ├── docker-compose.yml │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ ├── logo.png │ │ │ ├── vuedocker.jpg │ │ │ └── vuedocker.png │ │ ├── components │ │ │ └── HelloWorld.vue │ │ ├── main.ts │ │ └── shims-vue.d.ts │ │ └── tsconfig.json ├── ejem13 │ ├── docker-compose.yml │ └── ejem.txt ├── ejem14 │ └── docker-compose.yml └── ejem15 │ ├── Dockerfile │ └── firefox.sh └── updates ├── joseluisgs-03-2021.md ├── joseluisgs.md └── mamoreo.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.pptx 2 | /libros/* 3 | /ejemplos/ejem02/wordpress/* 4 | /ejemplos/ejem03/wordpress/* 5 | /ejemplos/ejem04/wordpress/* 6 | /ejemplos/ejem07/mariadb/data/* 7 | /ejemplos/ejem07/logs/* 8 | -------------------------------------------------------------------------------- /Docker-Tutorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/Docker-Tutorial.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 José Luis González 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DOCKER Tutorial 2 | 3 | 2DAW Tutorial de Docker para el desarrollo avanzado de código. 4 | 5 | ![GitHub](https://img.shields.io/github/last-commit/joseluisgs/docker-tutorial) 6 | 7 | ![assets/image.png](https://laenredadera.net/wp-content/uploads/2018/01/docker.png) 8 | 9 | - [DOCKER Tutorial](#docker-tutorial) 10 | - [Acerca de](#acerca-de) 11 | - [Contenidos](#contenidos) 12 | - [Colaborar o nuevos contenidos o ejemplos](#colaborar-o-nuevos-contenidos-o-ejemplos) 13 | - [¿Cómo colaborar o corregir un cambio?](#cómo-colaborar-o-corregir-un-cambio) 14 | - [Autor](#autor) 15 | - [Contacto](#contacto) 16 | - [Licencia](#licencia) 17 | 18 | ## Acerca de 19 | 20 | Tutorial de Docker de supervivencia a 2DAW. Ejemplos usados en clase. 21 | Aprenderemos a manejar imagenes y contenedores y cómo aplicarlos para mejorar en el desarrollo de software. 22 | Siempre con el objetivo de poder crear un entorno que podamos comaprtir y facilitar el despliegue de nuestro proyecto. 23 | 24 | ## Contenidos 25 | - ¿Qué es Docker? 26 | - Instalación 27 | - Comandos básicos 28 | - Ejecutando contenedores 29 | - Dockerfile y nuestras imágenes 30 | - Persistencia de datos 31 | - Enlazando contenedores 32 | - Docker Compose 33 | - Docker Hub 34 | - Despliegue con Docker Hub y GitHub 35 | - Trucos y consejos 36 | - Optimización 37 | - Herramientas para Docker 38 | - Docker Swarm 39 | 40 | 41 | ## Colaborar o nuevos contenidos o ejemplos 42 | 43 | ### ¿Cómo colaborar o corregir un cambio? 44 | 45 | Para solicitar un cambio o ayudarme a pulir errores o a mejorar el contenido del curso y las transparencias lo podéis hacer de la siguiente manera: 46 | 47 | - Siempre debéis hacer un fork del proyecto para trabajar con él. 48 | - Lo primero es crear una rama con tu nombre de usuario de GitHub (vamos a ser ordenados) 49 | - En la carpeta updates de tu rama añadís un fichero con vuestro nombre de GitHub para que en dicho fichero vayáis actualizando con las cosas que queráis aportar. Este fichero debe estar redactado usando [markdown](https://www.markdownguide.org/basic-syntax/). 50 | - Indicáis el número de la página de la presentación (por ejemplo página 34). Indicáis el texto y remarcáis la palabra o error detectado. 51 | - De la misma manera si queréis incorporar un gráfico o figura lo indicáis en qué página, o si es nueva donde iría y subís ese recurso en la carpeta updates. 52 | - También podéis aportar referencias, herramientas y cosas útiles que os han servidor para dominar Git y GitHub. 53 | - Posteriormente hacéis un commit en vuestro repositorio y luego un pull request de los cambios indicados en tu rama y en la conversación me detallas algo de información y si el cambio se aprueba lo verás en la próxima versión Mira este [vídeo](https://www.youtube.com/watch?v=_M8oalUyz10) y este [otro](https://www.youtube.com/watch?v=QntLv5BjUr0). 54 | 55 | Gracias por colaborar y entre todos mejoramos usando GitHub. Espero vuestros pull requests :smile: 56 | 57 | ## Autor 58 | 59 | Codificado con :sparkling_heart: por [José Luis González Sánchez](https://twitter.com/joseluisgonsan) 60 | 61 | [![Twitter](https://img.shields.io/twitter/follow/joseluisgonsan?style=social)](https://twitter.com/joseluisgonsan) 62 | [![GitHub](https://img.shields.io/github/followers/joseluisgs?style=social)](https://github.com/joseluisgs) 63 | 64 | ### Contacto 65 |

66 | Cualquier cosa que necesites házmelo saber por si puedo ayudarte 💬. 67 |

68 |

69 | 70 | 72 |    73 | 74 | 76 |    77 | 78 | 80 |    81 | 82 | 84 | 85 |

86 | 87 | ## Licencia 88 | 89 | Este proyecto esta licenciado bajo licencia **MIT**, si desea saber más, visite el fichero 90 | [LICENSE](./LICENSE) para su uso docente y educativo. -------------------------------------------------------------------------------- /chuletas/cheat-sheet-v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/chuletas/cheat-sheet-v2.pdf -------------------------------------------------------------------------------- /chuletas/docker-cheat-sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/chuletas/docker-cheat-sheet.pdf -------------------------------------------------------------------------------- /chuletas/docker_cheatsheet_r3v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/chuletas/docker_cheatsheet_r3v2.pdf -------------------------------------------------------------------------------- /ejemplos/ejem01/Dockerfile: -------------------------------------------------------------------------------- 1 | # Imagen a usar 2 | FROM php:7.0-apache 3 | # copiamos todos los ficheros en el directorio en cuestion 4 | COPY src/ /var/www/html 5 | # Exponemos el puerto 80 6 | EXPOSE 80 7 | # Quien lo ha realizado 8 | MAINTAINER JL Gonzalez “jlgs@cifpvirgendegracia.com” 9 | -------------------------------------------------------------------------------- /ejemplos/ejem01/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker rmi -f miapache-php 3 | docker rm -f miapache-php 4 | docker build -t miapache-php . 5 | # Copiando los datos, de manera estática 6 | # docker run -dit --name miapache-php -p 5555:80 miapache-php 7 | # Montando enlanzado directorios 8 | docker run -dit --name miapache-php -p 5555:80 --mount type=bind,source="$PWD/src",target=/var/www/html miapache-php 9 | # Creando un volumen y almancenando los datos en él 10 | # Deberíamos pasar o copiar la información al volumen 11 | # docker run -dit -p 5555:80 --name miapache-php --mount type=volume,source=vol-miapache-php,target=/var/www/html miapache-php 12 | # Compartimos el mismo volumen entre varios contenedores 13 | # docker run -dit -p 7777:80 --name miapache-php-2 --mount type=volume,source=vol-miapache-php,target=/var/www/html miapache-php 14 | # Podemos verlo copiando los datos de a uno que es visible en el otro 15 | # docker cp src/index.html miapache-php:/var/www/html 16 | 17 | -------------------------------------------------------------------------------- /ejemplos/ejem01/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Apache en Docker 7 | 8 | 9 | 10 | 11 |

¡Hola 2DAW, mundo!

12 |

Mi web ejecutada desde Docker :)

13 | 14 | 15 | -------------------------------------------------------------------------------- /ejemplos/ejem01/src/otra.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Apache en Docker 7 | 8 | 9 | 10 | 11 |

¡Otra web!

12 |

Otra web desde Docker :)

13 | 14 | 15 | -------------------------------------------------------------------------------- /ejemplos/ejem01/src/prueba.php: -------------------------------------------------------------------------------- 1 | Mi fichero PHP'); 3 | echo ('

Mas info

'); 4 | echo ('

Mas infoas

'); 5 | -------------------------------------------------------------------------------- /ejemplos/ejem02/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Creamos el contenedor para nuestra base de datos 4 | docker run -d --name wordpress-db \ 5 | --mount source=wordpress-db,target=/var/lib/mysql \ 6 | -e MYSQL_ROOT_PASSWORD=secret \ 7 | -e MYSQL_DATABASE=wordpress \ 8 | -e MYSQL_USER=manager \ 9 | -e MYSQL_PASSWORD=secret \ 10 | mariadb:10.3.9 11 | 12 | # Creamos el contenedor de WordPress 13 | docker run -d --name wordpress \ 14 | --link wordpress-db:mysql \ 15 | --mount type=bind,source="$(pwd)"/wordpress,target=/var/www/html \ 16 | -e WORDPRESS_DB_USER=manager \ 17 | -e WORDPRESS_DB_PASSWORD=secret \ 18 | -p 8080:80 \ 19 | wordpress:4.9.8 -------------------------------------------------------------------------------- /ejemplos/ejem03/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir wordpress 4 | 5 | # Creamos la red propia 6 | docker network create mi-network 7 | 8 | # Creamos el contenedor para nuestra base de datos 9 | docker run -d --name wordpress-db \ 10 | --net=mi-network \ 11 | --mount source=wordpress-db,target=/var/lib/mysql \ 12 | -e MYSQL_ROOT_PASSWORD=secret \ 13 | -e MYSQL_DATABASE=wordpress \ 14 | -e MYSQL_USER=manager \ 15 | -e MYSQL_PASSWORD=secret mariadb:10.3.9 16 | 17 | # Creamos el contenedor de WordPress 18 | docker run -d --name wordpress \ 19 | --net=mi-network \ 20 | --link wordpress-db:mysql \ 21 | --mount type=bind,source="$(pwd)"/wordpress,target=/var/www/html \ 22 | -e WORDPRESS_DB_USER=manager \ 23 | -e WORDPRESS_DB_PASSWORD=secret \ 24 | -p 8080:80 \ 25 | wordpress:4.9.8 26 | 27 | -------------------------------------------------------------------------------- /ejemplos/ejem04/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | db: 5 | image: mariadb:10.3.9 6 | container_name: mariadb 7 | volumes: 8 | - data:/var/lib/mysql 9 | environment: 10 | - MYSQL_ROOT_PASSWORD=secret 11 | - MYSQL_DATABASE=wordpress 12 | - MYSQL_USER=manager 13 | - MYSQL_PASSWORD=secret 14 | web: 15 | image: wordpress:4.9.8 16 | container_name: wordpress 17 | depends_on: 18 | - db 19 | volumes: 20 | - ./wordpress:/var/www/html 21 | environment: 22 | - WORDPRESS_DB_USER=manager 23 | - WORDPRESS_DB_PASSWORD=secret 24 | - WORDPRESS_DB_HOST=db 25 | ports: 26 | - 8080:80 27 | 28 | volumes: 29 | data: 30 | -------------------------------------------------------------------------------- /ejemplos/ejem05/src/index.php: -------------------------------------------------------------------------------- 1 | Hola 2 DAW"; 3 | phpinfo(); 4 | -------------------------------------------------------------------------------- /ejemplos/ejem06/apache-php/Dockerfile: -------------------------------------------------------------------------------- 1 | # Apache + PHP + complementos 2 | FROM php:7.4-apache 3 | 4 | # Complementos, es importante que no nos pasemos con el run!! (cuanto más lineas peor, más lento) 5 | RUN docker-php-ext-install pdo pdo_mysql mysqli -------------------------------------------------------------------------------- /ejemplos/ejem06/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Indicamos la versión 2 | version: '3.7' 3 | 4 | # Iniciamos los servicios 5 | services: 6 | # Apache con PHP 7 | apache-php: 8 | build: ./apache-php 9 | container_name: apache-php-lamp 10 | ports: 11 | - 80:80 12 | volumes: 13 | - './src:/var/www/html' 14 | networks: 15 | - lamp-network 16 | 17 | # Maria DB 18 | mariadb: 19 | build: ./mariadb 20 | container_name: mariadb-lamp 21 | volumes: 22 | # - ./mariadb_data:/var/lib/mysql podríamos usar un directorio local llamado mariadb_data 23 | - mariadb-volume:/var/lib/mysql 24 | networks: 25 | - lamp-network 26 | 27 | # PHPMyAdmin 28 | phpmyadmin: 29 | image: phpmyadmin/phpmyadmin 30 | container_name: phpmyadmin-lamp 31 | links: 32 | - 'mariadb:db' 33 | ports: 34 | - 8081:80 35 | networks: 36 | - lamp-network 37 | 38 | volumes: 39 | mariadb-volume: 40 | 41 | networks: 42 | lamp-network: 43 | driver: bridge 44 | -------------------------------------------------------------------------------- /ejemplos/ejem06/mariadb/Dockerfile: -------------------------------------------------------------------------------- 1 | # MariaDB 2 | FROM mariadb:10.5 3 | 4 | # Configuramos BBDD 5 | ENV MYSQL_ROOT_PASSWORD 123 6 | ENV MYSQL_USER joseluis 7 | ENV MYSQL_PASSWORD 123 8 | ENV MYSQL_DATABASE testdb 9 | 10 | # Copiamos los ficheros sql para que se ejecuten 11 | COPY ./sql /docker-entrypoint-initdb.d/ -------------------------------------------------------------------------------- /ejemplos/ejem06/mariadb/sql/init-db.sql: -------------------------------------------------------------------------------- 1 | USE testdb; 2 | 3 | CREATE TABLE test ( 4 | nombre varchar(30), 5 | email varchar(50) 6 | ); 7 | 8 | INSERT INTO test (nombre, email) 9 | VALUES 10 | ('Jose Luis', 'joseluis@docker.com'), 11 | ('Soraya', 'soraya@docker.com'), 12 | ('Victor', 'victor@docker.com'); -------------------------------------------------------------------------------- /ejemplos/ejem06/src/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Obteniendo datos desde Maria DB 5 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | 20 | 21 | 38 | 39 | 40 | "; 41 | } 42 | 43 | mysqli_close($dbconn); 44 | ?> 45 | 46 | 47 | -------------------------------------------------------------------------------- /ejemplos/ejem07/code/myapp/index.php: -------------------------------------------------------------------------------- 1 | HOLA"); 3 | echo ("

He montado LEMP

"); 4 | 5 | try { 6 | // Importante, la dirección del host es como hayamos en el docker, en mi caso es mariadb 7 | $servername = "mariadb"; 8 | $username = "root"; 9 | $password = "password"; 10 | $database = "docker_sample"; 11 | $port = "3306"; 12 | 13 | $pdo = new PDO("mysql:host=$servername; port=$port; dbname=$database", $username, $password); 14 | $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 15 | echo "Conexión Realizada con éxito"; 16 | 17 | $res = $pdo->query('select nombre, email from usuarios'); 18 | foreach ($res as $user) { 19 | echo '

' . $user[0] . ' - ' . $user[1]; 20 | } 21 | $pdo = null; 22 | } catch (PDOException $e) { 23 | print "¡Error!: " . $e->getMessage() . "
"; 24 | die(); 25 | } 26 | -------------------------------------------------------------------------------- /ejemplos/ejem07/config/nginx/myapp.conf: -------------------------------------------------------------------------------- 1 | server { 2 | index index.php index.html; 3 | server_name myapp.dev; 4 | 5 | error_log /var/log/nginx/myapp_error.log; 6 | access_log /var/log/nginx/myapp_access.log; 7 | 8 | root /var/www/html/myapp; 9 | 10 | location ~ \.php$ { 11 | try_files $uri =404; 12 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 13 | 14 | fastcgi_pass php7:9000; 15 | 16 | fastcgi_index index.php; 17 | include fastcgi_params; 18 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 19 | fastcgi_param PATH_INFO $fastcgi_path_info; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ejemplos/ejem07/config/php/php.ini: -------------------------------------------------------------------------------- 1 | extension=pdo_mysql.so 2 | -------------------------------------------------------------------------------- /ejemplos/ejem07/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Indicamos la versión 2 | version: '3.7' 3 | 4 | # Iniciamos los servicios 5 | services: 6 | # PHP 7 | php7: 8 | container_name: php7 9 | build: ./php 10 | volumes: 11 | - /home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/config/php:/usr/local/etc/php 12 | - /home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/code/myapp:/var/www/html/myapp 13 | depends_on: 14 | - mariadb 15 | networks: 16 | - lemp-network 17 | 18 | # NGINX 19 | nginx: 20 | container_name: nginx 21 | image: nginx 22 | ports: 23 | - 8080:80 24 | volumes: 25 | - /home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/config/nginx:/etc/nginx/conf.d 26 | - /home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/code/myapp:/var/www/html/myapp 27 | - /home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/logs:/var/log/nginx 28 | depends_on: 29 | - php7 30 | networks: 31 | - lemp-network 32 | 33 | # MARIADB 34 | mariadb: 35 | container_name: mariadb 36 | image: mariadb:latest 37 | volumes: 38 | - /home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/mariadb/data:/var/lib/mysql 39 | environment: 40 | - MYSQL_ROOT_PASSWORD=password 41 | - MYSQL_DATABASE=docker_sample 42 | ports: 43 | - 3306:3306 44 | networks: 45 | - lemp-network 46 | 47 | # PHPMYADMIN 48 | phpmyadmin: 49 | image: phpmyadmin/phpmyadmin 50 | container_name: phpmyadmin 51 | links: 52 | - 'mariadb:db' 53 | depends_on: 54 | - mariadb 55 | ports: 56 | - 8081:80 57 | networks: 58 | - lemp-network 59 | 60 | # Si queremos que tengan una red propia a otros contenedores 61 | networks: 62 | lemp-network: 63 | driver: bridge 64 | -------------------------------------------------------------------------------- /ejemplos/ejem07/docker/mariadb/mariadb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Lanzo el contenedor 4 | docker run -d --name mariadb -p 3306:3306 \ 5 | -e MYSQL_ROOT_PASSWORD=password \ 6 | -e MYSQL_DATABASE=docker_sample \ 7 | -v "/home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/mariadb/data:/var/lib/mysql" \ 8 | mariadb:10.5 9 | 10 | 11 | # Lo lanzo por si estaba parado 12 | docker start mariadb 13 | 14 | # Si queremos un cliente por consola 15 | #docker run -it --link mariadb --rm mariadb sh -c 'exec mysql 16 | # -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" 17 | # -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"' -------------------------------------------------------------------------------- /ejemplos/ejem07/docker/nginx/nginx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Creo el contenedor 4 | docker run -itd --name nginx \ 5 | -v "/home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/config/nginx":/etc/nginx/conf.d \ 6 | -v "/home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/code/myapp":/var/www/html/myapp \ 7 | -v "/home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/logs":/var/log/nginx \ 8 | -p 8080:80 \ 9 | --link php7 nginx 10 | 11 | # Lo lanzo por si estaba parado 12 | docker start nginx 13 | -------------------------------------------------------------------------------- /ejemplos/ejem07/docker/php/Dockerfile: -------------------------------------------------------------------------------- 1 | # Imagen de PHP 2 | FROM php:7.4-fpm 3 | # Instalamos los paquetes que necesitamos 4 | RUN apt-get update && docker-php-ext-install mysqli pdo pdo_mysql -------------------------------------------------------------------------------- /ejemplos/ejem07/docker/php/php.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Creo la imagen 4 | docker build -t joseluisgs/php-fpm . 5 | 6 | # Lanzo el contenedor 7 | docker run -itd --name php7 \ 8 | --link mariadb \ 9 | -v "/home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/config/php":/usr/local/etc/php \ 10 | -v "/home/informatica/Dropbox/Puertollano 2020-2021/DAW/Temario/docker-tutorial/ejemplos/ejem07/code/myapp":/var/www/html/myapp \ 11 | joseluisgs/php-fpm 12 | 13 | # Lo lanzo por si estaba parado 14 | docker start php7 -------------------------------------------------------------------------------- /ejemplos/ejem07/docker/phpmyadmin/phpmyadmin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Lanzo el contenedor 4 | docker run -d --name phmyadmin \ 5 | --link mariadb:db\ 6 | -p 8888:80 \ 7 | phpmyadmin 8 | 9 | # Lo lanzo por si estaba parado 10 | docker start phmyadmin -------------------------------------------------------------------------------- /ejemplos/ejem07/docker/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "*** Iniciando Dockers ***" 3 | 4 | cd mariadb 5 | sh mariadb.sh 6 | echo "MariaDB Lista :)" 7 | cd .. 8 | 9 | #cd phpmyadmin 10 | #phpmyadmin.sh 11 | sh phpmyadmin/phpmyadmin.sh 12 | echo "PHP MyAdmin Listo :)" 13 | #cd .. 14 | 15 | cd php 16 | sh php.sh 17 | echo "PHP Listo :)" 18 | cd .. 19 | 20 | cd nginx 21 | sh nginx.sh 22 | echo "NGINX Listo :)" 23 | cd .. 24 | 25 | echo "*** Fin ***" -------------------------------------------------------------------------------- /ejemplos/ejem07/mariadb/sql/init-db.sql: -------------------------------------------------------------------------------- 1 | use docker_sample; 2 | 3 | create table usuarios ( 4 | id int not null auto_increment primary key, 5 | nombre varchar(100) not null, 6 | email varchar(250) not null 7 | ); 8 | 9 | insert into usuarios (nombre, email) VALUES 10 | ("Jose", "Vue"), 11 | ("Victor", "Aparejador"), 12 | ("Soraya", "Angular"), 13 | ("Luis", "Docker"); -------------------------------------------------------------------------------- /ejemplos/ejem08/Dockerfile: -------------------------------------------------------------------------------- 1 | # Imagen a usar 2 | FROM php:7.0-apache 3 | # copiamos todos los ficheros en el directorio en cuestion 4 | COPY src/ /var/www/html 5 | # Exponemos el puerto 80 6 | EXPOSE 80 7 | # Quien lo ha realizado 8 | MAINTAINER JL Gonzalez “jlgs@cifpvirgendegracia.com” 9 | -------------------------------------------------------------------------------- /ejemplos/ejem08/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker rmi -f miapache-php 3 | docker rm -f miapache-php 4 | docker build -t miapache-php . 5 | docker run -dit --name miapache-php -p 5555:80 miapache-php 6 | -------------------------------------------------------------------------------- /ejemplos/ejem08/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Apache en Docker 7 | 8 | 9 | 10 | 11 |

¡Hola, mundo!

12 |

Mi web ejecutada desde Docker :)

13 |

Y Compartida en Docker Hub :)

14 | 15 | 16 | -------------------------------------------------------------------------------- /ejemplos/ejem08/src/otra.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Apache en Docker 7 | 8 | 9 | 10 | 11 |

¡Otra web!

12 |

Otra web desde Docker :)

13 | 14 | 15 | -------------------------------------------------------------------------------- /ejemplos/ejem08/src/prueba.php: -------------------------------------------------------------------------------- 1 | Mi fichero PHP'); 3 | echo ('

Mas info

'); 4 | echo ('

Mas info

'); 5 | -------------------------------------------------------------------------------- /ejemplos/ejem09/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | reverseproxy: 5 | build: ./reverse 6 | container_name: reverseproxy 7 | ports: 8 | - 8080:8080 9 | - 8081:8081 10 | networks: 11 | - mi-red 12 | restart: always 13 | 14 | nginx: 15 | # image: nginx:alpine 16 | build: ./site1 17 | container_name: nginx 18 | # Si queremos montar directorios en modo desarrollo, si no copia lo del dockerfile 19 | # volumes: 20 | # - ./site1/src/.:/usr/share/nginx/html/ 21 | depends_on: 22 | - reverseproxy 23 | networks: 24 | - mi-red 25 | restart: always 26 | 27 | apache: 28 | # image: httpd:alpine 29 | build: ./site2 30 | container_name: apache 31 | # Si queremos montar directorios en modo desarrollo, si no copia lo del dockerfile 32 | # volumes: 33 | # - './site2/src/.:/usr/local/apache2/htdocs/' 34 | depends_on: 35 | - reverseproxy 36 | networks: 37 | - mi-red 38 | restart: always 39 | 40 | networks: 41 | mi-red: 42 | driver: bridge 43 | -------------------------------------------------------------------------------- /ejemplos/ejem09/reverse/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | COPY nginx.conf /etc/nginx/nginx.conf -------------------------------------------------------------------------------- /ejemplos/ejem09/reverse/nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 1; 2 | 3 | events { worker_connections 1024; } 4 | 5 | http { 6 | 7 | sendfile on; 8 | 9 | upstream docker-nginx { 10 | server nginx:80; 11 | } 12 | 13 | upstream docker-apache { 14 | server apache:80; 15 | } 16 | 17 | server { 18 | listen 8080; 19 | 20 | location / { 21 | proxy_pass http://docker-nginx; 22 | proxy_redirect off; 23 | proxy_set_header Host $host; 24 | proxy_set_header X-Real-IP $remote_addr; 25 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 26 | proxy_set_header X-Forwarded-Host $server_name; 27 | } 28 | } 29 | 30 | server { 31 | listen 8081; 32 | 33 | location / { 34 | proxy_pass http://docker-apache; 35 | proxy_redirect off; 36 | proxy_set_header Host $host; 37 | proxy_set_header X-Real-IP $remote_addr; 38 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 39 | proxy_set_header X-Forwarded-Host $server_name; 40 | } 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /ejemplos/ejem09/site1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | COPY src/. /usr/share/nginx/html/ -------------------------------------------------------------------------------- /ejemplos/ejem09/site1/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | site1.example.com 5 | 6 | 7 |

site1.example.com

8 | 9 | 10 | -------------------------------------------------------------------------------- /ejemplos/ejem09/site2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM httpd:alpine 2 | COPY src/. /usr/local/apache2/htdocs/ -------------------------------------------------------------------------------- /ejemplos/ejem09/site2/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | site2.example.com 5 | 6 | 7 |

site2.example.com

8 | 9 | 10 | -------------------------------------------------------------------------------- /ejemplos/ejem10/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | reverseproxy: 5 | image: jwilder/nginx-proxy 6 | container_name: reverseproxy 7 | ports: 8 | - '80:80' 9 | - '443:443' 10 | volumes: 11 | - /var/run/docker.sock:/tmp/docker.sock:ro 12 | networks: 13 | - mi-red 14 | restart: always 15 | privileged: true 16 | 17 | nginx: 18 | # image: nginx:alpine 19 | build: ./site1 20 | container_name: nginx 21 | # Como variable le pasamos el nombre del sitio 22 | environment: 23 | VIRTUAL_HOST: site1.example.com 24 | # Si queremos montar directorios en modo desarrollo, si no copia lo del dockerfile 25 | # volumes: 26 | # - ./site1/src/.:/usr/share/nginx/html/ 27 | depends_on: 28 | - reverseproxy 29 | networks: 30 | - mi-red 31 | restart: always 32 | 33 | apache: 34 | # image: httpd:alpine 35 | build: ./site2 36 | container_name: apache 37 | environment: 38 | VIRTUAL_HOST: site2.example.com 39 | # Si queremos montar directorios en modo desarrollo, si no copia lo del dockerfile 40 | # volumes: 41 | # - './site2/src/.:/usr/local/apache2/htdocs/' 42 | depends_on: 43 | - reverseproxy 44 | networks: 45 | - mi-red 46 | restart: always 47 | 48 | networks: 49 | mi-red: 50 | driver: bridge 51 | -------------------------------------------------------------------------------- /ejemplos/ejem10/site1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | COPY src/. /usr/share/nginx/html/ -------------------------------------------------------------------------------- /ejemplos/ejem10/site1/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | site1.example.com 5 | 6 | 7 |

site1.example.com

8 | 9 | 10 | -------------------------------------------------------------------------------- /ejemplos/ejem10/site2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM httpd:alpine 2 | COPY src/. /usr/local/apache2/htdocs/ -------------------------------------------------------------------------------- /ejemplos/ejem10/site2/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | site2.example.com 5 | 6 | 7 |

site2.example.com

8 | 9 | 10 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.dockerignore: -------------------------------------------------------------------------------- 1 | target/* -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/ejemplos/ejem11/gs-rest-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.tar.gz 3 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | rest-service 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/test/java=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.methodParameters=generate 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 8 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 9 | org.eclipse.jdt.core.compiler.release=disabled 10 | org.eclipse.jdt.core.compiler.source=1.8 11 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Build stage 3 | # 4 | FROM maven:3.6.3-jdk-11-slim AS maven_build 5 | 6 | WORKDIR 'usr/src/app' 7 | 8 | COPY . ./ 9 | 10 | RUN mvn clean package 11 | 12 | # 13 | # Package stage 14 | # 15 | FROM openjdk:11-jre-slim 16 | 17 | ARG JAR_NAME="hello-wordl-example" 18 | 19 | WORKDIR '/usr/src/app' 20 | 21 | # EXPOSE ${HTTP_PORT} 22 | 23 | COPY --from=maven_build /usr/src/app/target/${JAR_NAME}.jar ./app.jar 24 | CMD ["java","-jar", "./app.jar"] -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | https://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "{}" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright {yyyy} {name of copyright owner} 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | https://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/LICENSE.writing.txt: -------------------------------------------------------------------------------- 1 | Except where otherwise noted, this work is licensed under https://creativecommons.org/licenses/by-nd/3.0/ 2 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/README.md: -------------------------------------------------------------------------------- 1 | # Hello World Example 2 | 3 | Un ejemplo de Hola Mundo con Java. 4 | 5 | # Caracteristicas 6 | • RESTful API 7 | • Java 8 8 | • Spring Boot 9 | • Maven 10 | • Docker 11 | • Swagger (Documentacion API Automatica) 12 | • JUnit 5 (Tests) 13 | 14 | ### Fuente 15 | 16 | Hello World Example esta basado en este proyecto [tutorial](https://spring.io/guides/gs/rest-service/) de Spring. 17 | 18 | ## Ejecutar los tests 19 | 20 | Los tests pueden ser lanzados desde una consola. 21 | Desde la raiz del proyecto ejecuta: 22 | ```sh 23 | $ ./mvnw clean test 24 | ``` 25 | ## Ejectuar la aplicacion desde la consola 26 | Para lanzar el proyecto simplemente ejecuta el siguiente comando desde una consola: 27 | 28 | ```sh 29 | $ ./mvnw spring-boot:run 30 | ``` 31 | 32 | ## Ejectuar la aplicacion con Docker 33 | Docker construira el .jar con Maven y ejecutara la aplicacion 34 | 35 | Construir la imagen con Docker: 36 | 37 | ```sh 38 | $ docker build -t hello-world . 39 | ``` 40 | Crear y lanzar el contenedor en segundo plano mapeando el puerto: 41 | ```sh 42 | $ docker run -d -p 8080:8080 hello-world 43 | ``` 44 | Parar la aplicacion: 45 | ```sh 46 | $ docker stop [CONTAINER_ID] 47 | ``` 48 | Entrar en un contenerdor que se esta ejecutando: 49 | ```sh 50 | $ docker exec -it [CONTAINER_NAME] sh 51 | ``` 52 | 53 | ## RESTful API 54 | Una vez que la aplicacion este funcionando. Abre un navegador y escribe la siguiente URL 55 | > http://localhost:8080 56 | 57 | Debes ver el nombre de la aplicacion en la pantalla. 58 | 59 | Dirigete a la siguiente URL para acceder a la RESTful API 60 | > http://localhost:8080/swagger-ui/ 61 | 62 | Desde aqui el Greeting-Controller esta disponible. Hay disponible un solo entry point con GET. 63 | Puedes probar la funcionalidad disponible con el boton _TRY IT OUT_. 64 | Naturalmente tambien puedes utilizar el metodo GET directamente desde el navegador o con **Postman**. 65 | 66 | > http://localhost:8080/greeting 67 | 68 | ## Docker por pasos 69 | El fichero Dockerfile contiene dos instrucciones **FROM** porque tiene dos pasos: 70 | - Fase de Construccion (usamos Maven para crear el .jar) 71 | - Fase de Empaquetado (creamos la imagen que lanza dicho .jar) 72 | 73 | ### Fase de Construccion 74 | Se creara una imagen basada en Maven para construir el proyecto (.jar) 75 | >FROM maven:3.6.3-jdk-11-slim **AS maven_build** 76 | RUN mvn clean package 77 | 78 | ### Fase de Empaquetado 79 | Ahora que tenemos el .jar usaremos esta imagen que hemos nombrado **maven_build** 80 | para construir la imagen que ejecutara la aplicacion. 81 | 82 | > FROM openjdk:11-jre-slim 83 | COPY **--from=maven_build** /usr/src/app/target/${JAR_NAME}.jar ./app.jar 84 | CMD ["java","-jar", "./app.jar"] 85 | 86 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: gs-rest-service 4 | memory: 256M 5 | instances: 1 6 | host: rest-service 7 | domain: guides.spring.io 8 | path: build/libs/gs-rest-service-0.1.0.jar 9 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ "$MVNW_REPOURL" = true]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 300 | 301 | exec "$JAVACMD" \ 302 | $MAVEN_OPTS \ 303 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 304 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 305 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 306 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | echo Found %WRAPPER_JAR% 133 | ) else ( 134 | if not "%MVNW_REPOURL%" == "" ( 135 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.2/maven-wrapper-0.5.2.jar" 136 | ) 137 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 138 | echo Downloading from: %DOWNLOAD_URL% 139 | 140 | powershell -Command "&{"^ 141 | "$webclient = new-object System.Net.WebClient;"^ 142 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 143 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 144 | "}"^ 145 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 146 | "}" 147 | echo Finished downloading %WRAPPER_JAR% 148 | ) 149 | @REM End of extension 150 | 151 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 152 | if ERRORLEVEL 1 goto error 153 | goto end 154 | 155 | :error 156 | set ERROR_CODE=1 157 | 158 | :end 159 | @endlocal & set ERROR_CODE=%ERROR_CODE% 160 | 161 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 162 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 163 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 164 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 165 | :skipRcPost 166 | 167 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 168 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 169 | 170 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 171 | 172 | exit /B %ERROR_CODE% 173 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.4.3 9 | 10 | 11 | com.example 12 | rest-service 13 | 0.0.1-SNAPSHOT 14 | rest-service 15 | Demo project for Spring Boot 16 | 17 | 1.8 18 | 19 | jar 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | 34 | io.springfox 35 | springfox-swagger2 36 | 3.0.0 37 | 38 | 39 | io.springfox 40 | springfox-swagger-ui 41 | 3.0.0 42 | 43 | 44 | io.springfox 45 | springfox-boot-starter 46 | 3.0.0 47 | 48 | 49 | 50 | 51 | 52 | 53 | hello-wordl-example 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-maven-plugin 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/src/main/java/com/example/restservice/Greeting.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice; 2 | 3 | public class Greeting { 4 | 5 | private final long id; 6 | private final String content; 7 | 8 | public Greeting(long id, String content) { 9 | this.id = id; 10 | this.content = content; 11 | } 12 | 13 | public long getId() { 14 | return id; 15 | } 16 | 17 | public String getContent() { 18 | return content; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/src/main/java/com/example/restservice/GreetingController.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice; 2 | 3 | import java.util.concurrent.atomic.AtomicLong; 4 | 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | public class GreetingController { 11 | 12 | private static final String template = "Hello, %s!"; 13 | private final AtomicLong counter = new AtomicLong(); 14 | 15 | @GetMapping("/greeting") 16 | public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) { 17 | return new Greeting(counter.incrementAndGet(), String.format(template, name)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/src/main/java/com/example/restservice/RestServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class RestServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(RestServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/src/main/java/com/example/restservice/config/SpringFoxConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.restservice.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | @Configuration 13 | @EnableSwagger2 14 | public class SpringFoxConfig { 15 | 16 | @Bean 17 | public Docket api() { 18 | return new Docket(DocumentationType.SWAGGER_2) 19 | .select() 20 | .apis(RequestHandlerSelectors.any()) 21 | .paths(PathSelectors.any()) 22 | .build(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Greeting Example 5 | 6 | 7 | 8 |

Hello World Example

9 | 10 | 11 | -------------------------------------------------------------------------------- /ejemplos/ejem11/gs-rest-service/src/test/java/com/example/restservice/GreetingControllerTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.example.restservice; 17 | 18 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 19 | import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; 20 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 21 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.springframework.beans.factory.annotation.Autowired; 25 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; 26 | import org.springframework.boot.test.context.SpringBootTest; 27 | import org.springframework.test.web.servlet.MockMvc; 28 | 29 | @SpringBootTest 30 | @AutoConfigureMockMvc 31 | class GreetingControllerTests { 32 | 33 | @Autowired 34 | private MockMvc mockMvc; 35 | 36 | @Test 37 | void noParamGreetingShouldReturnDefaultMessage() throws Exception { 38 | 39 | this.mockMvc.perform(get("/greeting")).andDo(print()).andExpect(status().isOk()) 40 | .andExpect(jsonPath("$.content").value("Hello, World!")); 41 | } 42 | 43 | @Test 44 | void paramGreetingShouldReturnTailoredMessage() throws Exception { 45 | 46 | this.mockMvc.perform(get("/greeting").param("name", "Spring Community")) 47 | .andDo(print()).andExpect(status().isOk()) 48 | .andExpect(jsonPath("$.content").value("Hello, Spring Community!")); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,ts,tsx,vue}] 2 | indent_style = space 3 | indent_size = 2 4 | end_of_line = lf 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | max_line_length = 100 8 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true, 5 | }, 6 | extends: [ 7 | 'plugin:vue/vue3-essential', 8 | '@vue/airbnb', 9 | '@vue/typescript/recommended', 10 | ], 11 | parserOptions: { 12 | ecmaVersion: 2020, 13 | }, 14 | rules: { 15 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 16 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/Dockerfile: -------------------------------------------------------------------------------- 1 | # Elegimos la imagen, e este caso la 14 que es la última LTS: 2 | # https://hub.docker.com/_/node 3 | 4 | FROM node:14-alpine 5 | 6 | # instalar un simple servidor http para servir nuestro contenido estático 7 | RUN npm install -g http-server 8 | 9 | # hacer la carpeta 'app' el directorio de trabajo actual 10 | WORKDIR /app 11 | 12 | # copiar 'package.json' y 'package-lock.json' (si están disponibles) 13 | COPY package*.json ./ 14 | 15 | # instalar dependencias del proyecto 16 | RUN npm install 17 | 18 | # copiar los archivos y carpetas del proyecto al directorio de trabajo actual (es decir, la carpeta 'app') 19 | COPY . . 20 | 21 | # construir aplicación para producción minificada 22 | RUN npm run build 23 | 24 | # Exponemos el puerto y ejecutamos el servidor 25 | EXPOSE 8080 26 | CMD [ "http-server", "dist" ] 27 | 28 | # Puede parecer redundante copiar primero package.json ypackage-lock.json y luego todos los archivos y carpetas del proyecto en dos pasos separados, 29 | # pero en realidad hay una muy buena razón para eso (adelanto: nos permite aprovechar las capas de Docker almacenadas en caché). 30 | 31 | # Para subirla al registro, primero le ponemos una tag 32 | # docker build -t joseluisgs/joseluisgs/docker-vuejs-app . 33 | # Subirla: 34 | # docker push joseluisgs/docker-vuejs-app 35 | # Ejecutarla: 36 | # docker run -it -p 8080:8080 --rm --name docker-vuejs-app-1 joseluisgs/docker-vuejs-app 37 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/README.md: -------------------------------------------------------------------------------- 1 | # dockervue 2 | 3 | Aplicación Vue 3 + TypeScrypt con Docker 4 | Te recomiendo leas el dockerfile y dockercompose 5 | 6 | ## Project setup 7 | ``` 8 | npm install 9 | ``` 10 | 11 | ### Compiles and hot-reloads for development 12 | ``` 13 | npm run serve 14 | ``` 15 | 16 | ### Compiles and minifies for production 17 | ``` 18 | npm run build 19 | ``` 20 | 21 | ### Lints and fixes files 22 | ``` 23 | npm run lint 24 | ``` 25 | 26 | ### Customize configuration 27 | See [Configuration Reference](https://cli.vuejs.org/config/). 28 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset', 4 | ], 5 | }; 6 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | docker-vuejs-app: 5 | # Si hemos subido la imagen al registro, la usamos del registro de Docker Hub 6 | image: joseluisgs/docker-vuejs-app 7 | # Si queremos usar nuestro Dockerdile si no lo hemos subido al registro 8 | # build: . 9 | container_name: docker-vuejs-app 10 | ports: 11 | - '8080:8080' 12 | networks: 13 | - mi-red 14 | restart: always 15 | privileged: true 16 | 17 | networks: 18 | mi-red: 19 | driver: bridge 20 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dockervue", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "core-js": "^3.6.5", 12 | "vue": "^3.0.0" 13 | }, 14 | "devDependencies": { 15 | "@typescript-eslint/eslint-plugin": "^4.18.0", 16 | "@typescript-eslint/parser": "^4.18.0", 17 | "@vue/cli-plugin-babel": "~4.5.0", 18 | "@vue/cli-plugin-eslint": "~4.5.0", 19 | "@vue/cli-plugin-typescript": "~4.5.0", 20 | "@vue/cli-service": "~4.5.0", 21 | "@vue/compiler-sfc": "^3.0.0", 22 | "@vue/eslint-config-airbnb": "^5.0.2", 23 | "@vue/eslint-config-typescript": "^7.0.0", 24 | "eslint": "^6.7.2", 25 | "eslint-plugin-import": "^2.20.2", 26 | "eslint-plugin-vue": "^7.0.0", 27 | "typescript": "~4.1.5" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/ejemplos/ejem12/dockervue/public/favicon.ico -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/src/App.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 17 | 18 | 28 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/ejemplos/ejem12/dockervue/src/assets/logo.png -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/src/assets/vuedocker.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/ejemplos/ejem12/dockervue/src/assets/vuedocker.jpg -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/src/assets/vuedocker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseluisgs/docker-tutorial/20fad30f04c1797490d9ced1b9adefb91103647b/ejemplos/ejem12/dockervue/src/assets/vuedocker.png -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 33 | 34 | 44 | 45 | 46 | 62 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue'; 2 | import App from './App.vue'; 3 | 4 | createApp(App).mount('#app'); 5 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | declare module '*.vue' { 3 | import type { DefineComponent } from 'vue' 4 | const component: DefineComponent<{}, {}, any> 5 | export default component 6 | } 7 | -------------------------------------------------------------------------------- /ejemplos/ejem12/dockervue/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "esnext", 5 | "strict": true, 6 | "jsx": "preserve", 7 | "importHelpers": true, 8 | "moduleResolution": "node", 9 | "skipLibCheck": true, 10 | "esModuleInterop": true, 11 | "allowSyntheticDefaultImports": true, 12 | "sourceMap": true, 13 | "baseUrl": ".", 14 | "types": [ 15 | "webpack-env" 16 | ], 17 | "paths": { 18 | "@/*": [ 19 | "src/*" 20 | ] 21 | }, 22 | "lib": [ 23 | "esnext", 24 | "dom", 25 | "dom.iterable", 26 | "scripthost" 27 | ] 28 | }, 29 | "include": [ 30 | "src/**/*.ts", 31 | "src/**/*.tsx", 32 | "src/**/*.vue", 33 | "tests/**/*.ts", 34 | "tests/**/*.tsx" 35 | ], 36 | "exclude": [ 37 | "node_modules" 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /ejemplos/ejem13/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | services: 3 | frontend: 4 | image: 0gis0/frontend 5 | deploy: 6 | replicas: 5 7 | ports: 8 | - 4000:3000 9 | depends_on: 10 | - backend 11 | networks: 12 | - webnet 13 | backend: 14 | image: 0gis0/backend 15 | deploy: 16 | replicas: 2 17 | ports: 18 | - 8080:8080 19 | depends_on: 20 | - mongodb 21 | networks: 22 | - webnet 23 | mongodb: 24 | image: mongo:latest 25 | networks: 26 | - webnet 27 | networks: 28 | webnet: -------------------------------------------------------------------------------- /ejemplos/ejem13/ejem.txt: -------------------------------------------------------------------------------- 1 | Creamos tres nodos virtuales. Podríamos hacerlo con VirtualBox, pero mola easí porque ya tienen docker 2 | 3 | docker-machine create --driver virtualbox vm-manager 4 | docker-machine create --driver virtualbox vm-worker1 5 | docker-machine create --driver virtualbox vm-worker2 6 | 7 | Iniciamos el Cluster, Maestro 8 | docker-machine ssh vm-manager "docker swarm init --advertise-addr 192.168.99.102" 9 | 10 | Iniciamos los Workers, 11 | docker-machine ssh vm-worker1 "docker swarm join \ 12 | --token SWMTKN-1-0jmngpcawsd089d88lihjsfmztg6fqakq0cl251v0ccjugy9ra-az2kvtarkzhj3ajk98ckgd38b \ 13 | 192.168.99.102:2377" 14 | Una vez que lo hayas hecho con las dos máquinas, desde vm-manager puedes listar todos los nodos disponibles: 15 | 16 | docker-machine ssh vm-manager "docker node ls" 17 | 18 | Como es lógico, el archivo docker-compose.yml lo has creado en tu máquina local, pero realmente necesitas lanzarlo desde vm-manager, 19 | que es quien puede mandar órdenes a los nodos que tiene tu clúster. Existe una forma muy cómoda para mapear el terminal de vm-manger 20 | con el terminal de nuestro equipo local: 21 | 22 | docker-machine env vm-manager 23 | 24 | Al lanzar este comando se generan unas variables de entorno que nos permiten hacer esta conexión. Ahora ejecuta el siguiente para terminar con la configuración. 25 | 26 | eval $(docker-machine env vm-manager) 27 | Sin ningún tipo de aviso, ahora ya puedes lanzar comandos en el terminal como si estuvieras dentro de vm-manager, pero además puedes utilizar todo de lo que dispones en tu máquina local, como el archivo docker-compose.yml. Para materializar todo lo descrito en él debes aprender otro comando más, docker stack, que funciona de la siguiente manera: 28 | 29 | docker stack deploy -c docker-compose.yml myapp 30 | 31 | Al cabo de unos segundos todos los contenedores con todas sus replicas serán repartidos entre todos los nodos de tu clúster. Para ver el estado usa este comando: 32 | 33 | docker stack ps myapp 34 | 35 | Podrás ver que tu aplicación, o stack, está desplegado correctamente (Running) y podrás acceder al frontend a través del puerto 4000 y al backend a través del puerto 8080 ¿pero de qué IP? Pues en realidad de cualquiera de las IP de cualquiera de los nodos, por ejemplo http://192.168.99.102:4000, ya que todos ellos tienen por delante lo que se conoce como el swarm load balancer, el cual conoce dónde hay réplicas del contenedor al que quieres acceder y nos hace transparente esta gestión. 36 | 37 | -------------------------------------------------------------------------------- /ejemplos/ejem14/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | web: 5 | image: 'dockercloud/hello-world:latest' 6 | lb: 7 | image: 'dockercloud/haproxy:latest' 8 | links: 9 | - web 10 | ports: 11 | - '8080:80' -------------------------------------------------------------------------------- /ejemplos/ejem15/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | RUN apt-get update && apt-get install -y firefox 3 | CMD ["/usr/bin/firefox"] 4 | -------------------------------------------------------------------------------- /ejemplos/ejem15/firefox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker build -t firefox-app . 3 | docker run --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" firefox-app -------------------------------------------------------------------------------- /updates/joseluisgs-03-2021.md: -------------------------------------------------------------------------------- 1 | # Cambios de JL González 2 | 3 | ## Mis cambios y propuestas 4 | 5 | Ejemplo 12: Aplicación de Vue.js con Docker 6 | Ejemplo 13: Cluster Docker Swarm 7 | Transparencias: Docker Swarm 8 | -------------------------------------------------------------------------------- /updates/joseluisgs.md: -------------------------------------------------------------------------------- 1 | # Cambios de JL González 2 | 3 | ## Mis cambios y propuestas 4 | 5 | Este es un ejemplo de fichero markdwon para hacer los cambios como indica en README.md 6 | 7 | ### ¿Cómo colaborar o corregir un cambio? 8 | 9 | Para solicitar un cambio o ayudarme a pulir errores o a mejorar el contenido del curso y las trasparencias lo podéis hacer de la siguiente manera: 10 | 11 | - Siempre debéis hacer un fork del proyecto para trabajar con él. 12 | - Lo priemero es crear una rama con tu nombre de usuario de GitHub (vamos a ser ordenados) 13 | - En la carpeta updates de tu rama añadís un fichero con vuestro nombre de GitHub para que en dicho fichero vayáis actualizando con las cosas que queráis aportar. Este fichero debe estar redactado usando [markdown](https://www.markdownguide.org/basic-syntax/). 14 | - Indicáis el número de la página de la presentación (por ejemplo página 34). Indicáis el texto y remarcáis la palabra o error detectado. 15 | - De la misma manera si queréis incorporar un gráfico o figura lo indicáis en qué página, o si es nueva donde iría y subís ese recurso en la carpeta updates. 16 | - También podéis aportar referencias, herramientas y cosas útiles que os han servidor para dominar Git y GitHub. 17 | - Posteriormente hacéis un commit en vuestro repositorio y luego un pull request de los cambios indicados een tu rama y en la conversación me detallas algo de información y si el cambio se aprueba lo verás en la próxima versión Mira este [vídeo](https://www.youtube.com/watch?v=_M8oalUyz10) y este [otro](https://www.youtube.com/watch?v=QntLv5BjUr0). 18 | 19 | Gracias por colaborar y entre todos mejoramos usando GitHub. Espero vuestros pull request :smile: 20 | -------------------------------------------------------------------------------- /updates/mamoreo.md: -------------------------------------------------------------------------------- 1 | # Cambios de MA Moreo 2 | 3 | ## Mis cambios y propuestas 4 | 5 | - Corrección de algunas erratas en el fichero README.md 6 | priemero --> primero 7 | trasparencias --> transparencias 8 | pull requests :smile: s --> pull requests :smile: 9 | 10 | - Aniadido ejemplo 11 en ejemplos/ejem11: Docker por pasos 11 | 12 | --------------------------------------------------------------------------------
NombreEmail
{$row['nombre']}{$row['email']}