Giter Club home page Giter Club logo

spring-boot-docker's Introduction

Lightweight Spring Boot Docker image based on Alpine + Docker Compose file

Features:

Available environment variables

Name Default Description
JAVA_OPTS JAVA_OPTS
DEBUG false Enable or disable debug mode
DEBUG_PORT 8000 Debug port

How to use ?

  1. Simply extend your image from flopes/spring-boot-docker and set your application name as an environment variable:

    FROM flopes/spring-boot-docker:1.1
    
  2. Copy your Spring Boot executable jar into an assets folder, rename it to spring-boot.jar and build you image: docker build -t spring-boot-image .

  3. Start your application:

    • Using Docker CLI docker run -d -p 8080:8080 spring-boot-image

    • Using the provided docker-compose.yml in the sample directory: docker-compose up -d

Inject environment variables:

docker run -d -p 8080:8080 -e JAVA_OPTS="-Xms256m -Xmx512m" spring-boot-image

Using Docker Compose

The docker-compose.yml file picks its configuration from the .env one.

Using this file, you can set the desired properties:

# Application properties
SERVER_PORT=8080
DEBUG_PORT=8000
SPRING_PROFILES_ACTIVE=dev
DEBUG=false
# -Dprop=... -Dparameter=...
JAVA_OPTS=

# Host properties
HOST_SERVER_PORT=8080
HOST_DEBUG_PORT=8000

Debug mode

To run the application in debug mode, simply set the DEBUG variable to true in the .env file.

Launch the application: docker-compose up -d

By default, the debug port used is the 8000.

Spring profile(s)

By default, the application will run with dev Spring profile

To run the application with a specific Spring profile, set the desired one in the .env file:

SPRING_PROFILES_ACTIVE=dev

PID 1

$ docker run -d --name spring-boot -p 8080:8080 spring-boot-extends
a5b3036136dffa34af0cdeff6153e87f9a20ba1cdc54c36fe9113b385bfb3264

lopes_f@lopes-f-laptop MINGW64 /d/WORK/git/docker-poc/docker (develop)
$ docker exec -it a5b3036136dffa34af0cdeff6153e87f9a20ba1cdc54c36fe9113b385bfb3264 sh
/app $ ps -ef
PID   USER     TIME   COMMAND
    1 spring-b   0:10 java -Djava.security.egd=file:/dev/./urandom -jar /app/spring-boot.jar
   23 spring-b   0:00 sh
   27 spring-b   0:00 ps -ef
/app $

spring-boot-docker's People

Contributors

f-lopes avatar

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.