DevSecOps Repository
This project can be packaged as a Java JAR and run inside a Docker container. Below are concise instructions for building the JAR, creating a Docker image, and running it.
Prerequisites:
- Docker installed and running
- A built JAR (for Maven:
mvn -DskipTests package)
- Example Dockerfile
FROM eclipse-temurin:17-jdk
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]- Build the app (Maven example)
mvn -DskipTests package- Build the Docker image
docker build -t myapp:latest .- Run the container
docker run -d --name myapp -p 8080:8080 myapp:latestAlternative: run without building an image (mount the JAR into an OpenJDK image)
docker run --rm -v "$(pwd)/target/your-app.jar:/app/app.jar" -p 8080:8080 eclipse-temurin:17-jdk java -jar /app/app.jarNotes:
- Replace
your-app.jarortarget/*.jarwith your actual built JAR filename. - Adjust
-pport mapping and environment variables as needed (use-e VAR=value). - For Apple Silicon (M1/M2) you can use multi-arch base images or add
--platform linux/amd64todocker build/docker runif required.
Optional docker-compose (minimal)
version: '3.8'
services:
app:
build: .
image: myapp:latest
ports:
- "8080:8080"
environment:
- JAVA_OPTS=-Xmx256m``