Create a docker image from a spring boot project

In order to create a docker image from a spring boot project, First, your pom.xml has to be configured. <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!-- Cofiguration for creating a docker image --> <image> <name>chamow01/${project.artifactId}</name> </image> </configuration> </plugin> </plugins> </build> Then, the next maven command needs to be applied, so spring boot uses paketo-buildpacks in order to create a docker image based on you Java code mvn spring-boot:build-image ... [INFO] > Running creator [INFO] [creator] ===> DETECTING [INFO] [creator] 6 of 24 buildpacks participating [INFO] [creator] paketo-buildpacks/ca-certificates 3.2.0 [INFO] [creator] paketo-buildpacks/bellsoft-liberica 9.3.2 [INFO]

Configuración en Apache para evitar bloqueos tipo CORS-Origin

Es posible evitar el bloqueo por tipo CORS-Origin, realizando la siguiente configuración:

<Location /ws-api-login>
      SetEnvIf Origin "http(s)?://(.+\.)?(localhost|host\.com)(:\d{1,5})?$" CORS=$0
      Header always set Access-Control-Allow-Origin "%{CORS}e" env=CORS   
      Header merge  Vary "Origin"
      Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
      Header always set Access-Control-Max-Age "1000"
      Header always set Access-Control-Allow-Headers "*"   
      RewriteEngine On
      RewriteCond %{REQUEST_METHOD} OPTIONS
      RewriteRule ^(.*)$ $1 [R=200,L]
</Location>

Nota: Se debe habilitar el módulo rewrite
LoadModule rewrite_module modules/mod_rewrite.so


Fuentes: 
  1. https://tecadmin.net/enable-cors-apache/
  2. https://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains

Comentarios

Entradas populares de este blog

Create a docker image from a spring boot project

Comandos docker

Kubernetes -Tipos de objetos