Giter VIP home page Giter VIP logo

skildring-abakus's Introduction

template-spring-boot-docker

Template Spring Boot Docker Project

Key Aspects

The idea behind this template is for you to be able to clone it and quickly start using it in your enterprise with the following way of working:

The use of com.spotify's plugin delivers on a key requirement, which is the ability to bind the build, tag & push goals to the Maven phases. You can configure the cited plugin so that the container will be built, tagged and pushed when you run just mvn deploy.

Build and Run

$ mvn package docker:build

$ docker images
REPOSITORY                              TAG                 IMAGE ID            CREATED              SIZE
nicodewet/spring-boot-docker-template   0.0.1-SNAPSHOT      6e923d0dbec1        About a minute ago   193.9 MB
frolvlad/alpine-oraclejdk8              slim                3f6e317fc0fb        2 weeks ago          166.9 MB

$ docker run -p 8080:8080 --name spr-boot-templ -t nicodewet/spring-boot-docker-template:0.0.1-SNAPSHOT

$ docker ps
CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS                    NAMES
83429f3       nicodewet/spring-boot-docker-template:0.0.1-SNAPSHOT   "java -Djava.security"   25 seconds ago      Up 24 seconds       0.0.0.0:8080->8080/tcp   spr-boot-templ

mvn package docker:build

This builds the SNAPSHOT Spring Boot jar and wraps it with Docker as specified in the Dockerfile in src/main/docker.

The following configuration includes :${project.version} so that the Maven version number will become the Docker tag and so conceptually the Maven version number and the Docker tag are the same thing.

<imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>

docker images

This command confirms our expectations in terms of seeing a Docker image with REPOSITORY nicodewet/spring-boot-docker-template and TAG 0.0.1-SNAPSHOT. It also confirms a small image size of only 193.9MB.

docker run -p 8080:8080 --name spr-boot-templ -t nicodewet/spring-boot-docker-template:0.0.1-SNAPSHOT

Here we run the newly minted image and so it becomes a named container with the web app on port 8080.

docker ps

You can run this in another console tab. This is just a sanity check. Naturally you can just Ctrl + C to stop the container or docker stop spr-boot-templ.

Cleanup

Delete all containers and images.

./delete_all_containers_and_images.sh

skildring-abakus's People

Contributors

nicodewet avatar vhellem avatar

Watchers

 avatar  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.