persiliao/samantha

By persiliao

Updated 1 day ago

Production for Spring Boot applications based on Liberica JDK 8/17/21 Alpine

Image
Languages & frameworks
Web servers
0

7.4K

persiliao/samantha repository overview

Spring Boot Application Docker Image

Production-grade, secure, lightweight Docker image for Spring Boot applications based on Liberica JDK 8/17/21 Alpine


1. Image Overview

  • Base Image: bellsoft/liberica-openjdk-alpine:java-version-cds
  • Java Version: 8/17/21
  • OS: Alpine Linux (lightweight & secure)
  • Application: Spring Boot backend service
  • Environment: Production ready
  • Security: Non-root user, proper permissions, tini init process
  • Maintainer: Persi.Liao [email protected]
  • License: MIT

2. Key Features & Best Practices

Lightweight & Stable:Alpine-based minimal footprint
Production Security:Non-root user (UID 1000),no root runtime
Process Safety:tini as init process,prevents zombie processes
Fast Dependency Installation:Aliyun Alpine mirror
Health Check:Built-in Spring Boot Actuator health check
Configurable:All JVM & runtime params via environment variables
Log & Dump Directory:Pre-created /app/logs /app/heapdump with correct permissions
Clean Image:No cache,minimal layers


3. Directory Structure

/app/
  ├── app.jar               # Spring Boot application JAR
  ├── docker-entrypoint.sh  # Startup script
  ├── logs/                 # Application logs
  └── heapdump/             # JVM heap dump files

4. Environment Variables

All variables can be overridden at runtime (docker run -e KEY=VALUE).

Core Runtime
NameDefaultDescription
SPRING_PROFILES_ACTIVEprodSpring profile
SERVER_PORT8080Application listening port
TZAsia/ShanghaiTimezone
LANGC.UTF-8System encoding

5. Exposed Port

  • 8080 (configurable via SERVER_PORT)

6. Health Check

Auto-check every 30s:

curl -f http://127.0.0.1:8080/actuator/health || exit 1

Parameters:

  • interval: 30s
  • timeout: 3s
  • retries: 3
  • start-period: 60s

docker run -d \
  --name spring-boot-app \
  -p 8080:8080 \
  -e SPRING_PROFILES_ACTIVE=prod \
  -v $(pwd)/app.jar:/app/app.jar \
  -v $(pwd)/logs:/app/logs \
  -v $(pwd)/heapdump:/app/heapdump \
  --restart always \
  <your-image-name>:<tag>

8. Security Features

  • Runs as non-root user appuser (UID 1000)
  • Read-only base application directory
  • Log/heapdump with write-only access
  • No unnecessary packages
  • Clean APK cache

9. Build & Maintainance

Build Image
docker build -t spring-boot-app:jdk8-alpine .
Check Image Info
docker inspect <image-id>
docker image inspect --format '{{.Config.Labels}}' <image-id>

10. Labels

org.opencontainers.image.title=Spring Boot Application
org.opencontainers.image.description=Production-ready Spring Boot service with JDK 8 Alpine
org.opencontainers.image.version=8
org.opencontainers.image.licenses=MIT
org.opencontainers.image.base.name=bellsoft/liberica-openjdk-alpine
org.opencontainers.image.base.tag=8-cds
maintainer=Persi.Liao <[email protected]>
java.version=8
os=Alpine Linux
app=spring-boot
env=production
component=backend

11. License

MIT

Tag summary

Content type

Image

Digest

sha256:cad2f89e6

Size

130.2 MB

Last updated

1 day ago

docker pull persiliao/samantha:17-sba