Coder Social home page Coder Social logo

spring-boot-container-demo's Introduction

Spring Boot Docker Example

This is an example Spring Boot "Hello World" micro-service application that can be containerized and subsequently executed in Docker, Kubernetes, and Google App Engine!

This is not an official Google product.

Building

Regular Maven build:

mvn package

Build Docker container:

mvn docker:build

Running

Java

Pretty straight forward:

mvn exec:java

Docker

Without Redis for session:

docker run -ti spring-boot-demo

With Redis for session:

docker run -d --name redis -p 6379:6379 redis
docker run -ti --rm --link redis:redis -p 8080:8080 spring-boot-demo

Docker Compose

Docker Compose uses a descriptor to describe the Docker container and linking configurations. Rather than manually executing commands like the previous section, you can start the demo with Redis by running:

cd src/test/docker-compose
docker-compose up

The configuration is stored in docker-compose.yml

Kubernetes

The following instructions assume that you already have Kubernetes cluster up and running. If not, check out Google Container Engine to get started quickly.

Change directory to where all the Kubernetes configuration files are:

cd src/test/kubernetes

Deploy Redis master pod:

kubectl create -f redis-master-pod.yaml

Create a Redis master service:

kubectl create -f redis-master-service.yaml

Deploy Spring Boot Demo replication controller:

kubectl create -f spring-boot-demo-controller.yaml

Create a service:

kubectl create -f spring-boot-demo-service.yaml

If you are on Google Container Engine, or Kubernetes deployment that supports external services, you can create an external service:

kubectl create -f spring-boot-demo-external-service.yaml

Google App Engine

The instruction assumes that you have Google Cloud SDK already installed and that you are familiar with Google App Engine Managed VMs.

To run locally:

mvn gcloud:run

To deploy into Google App Engine, you'll first need to create a Redis server. You can deploy Redis easily by using Click to Deploy.

Once deployed, update src/main/resources/application-gae.properties file, and set:

spring.redis.host=YOUR_REDIS_MASTER_INSTANCE_NAME

Build the Docker image, so that it generates Dockerfile

mvn docker:build

Finally, deploy the application using gcloud plugin:

mvn gcloud:deploy -Dgcloud.project=YOUR_PROJECT_ID

spring-boot-container-demo's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.