Coder Social home page Coder Social logo

docker-springboot-runner's Introduction

license

Docker Automated buil Docker Pulls Docker Stars

SPRINGBOOT Runner

Based on openjdk:8u121-jre-alpine docker image.

This image is more that just a Spring Boot runner. I can launch any java command.

I created it first because I needed to launch a spring boot application in a container. But I didn't want to:

  • recreate an image for every version
  • customize the docker run command per environment.

Usage

Long story short

docker run -name <myapp> -v <myappfolder>:/app -p 8080:8080 wattazoum/springboot-runner

Then access to http://localhost:8080 .

Using the java command

This is not the purpose of this image, but if needed, you can use it to launch a java custom command.

$ docker run --rm -it wattazoum/springboot-runner -version

openjdk version "1.8.0_111-internal"
OpenJDK Runtime Environment (build 1.8.0_111-internal-alpine-r0-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

Every command passed to the container will directly be fed to the java executable inside the container.

Caracteristics

Specificities of this image consist in:

a springboot user (uid=1000)

The container runs on a user called springboot with the uid 1000. This allows every file created by the application to be used by user uid=1000 on the docker host.

a volume /app

The WORKDIR of the container. This folder might contain one and only one jar/war, which is the springboot application jar.
Creating a /app/config/ directory will be automatically detected by Springboot as the configuration folder. See SpringBoot documentation on externalizing configuration. We also recommend the creation of the logs folder inside the /app folder. The /app folder may also contain the setenv.sh file mentionned bellow.

Note: The /app folder seen in the container will usually be a storage mapped to an external resource (docker storage, host folder ...). So creating a subdirectory can be done externally.

Now if you want to play with the internal of the container, you can launch:

docker run -it --rm --entrypoint /bin/sh wattazoum/springboot-runner

You can launch /usr/local/bin/entrypoint.sh to test the normal behavior of the container.

a port 8080

The defaut springboot http port is 8080. This port is exposed by the container. So no need to change it in your configuration.

a (optional) setenv.sh file

This file allows you to set options to be passes to the java command. The resulting command will be in the form of :

java $JAVA_OPTS -jar my_detected_jar $APP_ARGS

The following options are available (both optional):

  • JAVA_OPTS: sets the java options to be passed. It can contain:
    • JVM behavior settings. eg. -Xmx1g
    • system properties. eg. -Dfile.encoding=utf8
  • APP_ARGS: usually argument to be passed to the main class of the jar.

Here is an exemple of content:

JAVA_OPTS="-Xmx1g -Dfile.encoding=utf8"
APP_ARGS="--loglevel=debug"

Note: The content of the file can be more complex than the sample above. It will be interpreted by /bin/sh so all of the DASH syntax is supported

Changelog

v1.1

v1.0

  • JRE is 8r111

docker-springboot-runner's People

Contributors

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