https://github.com/danielfreitassc/java-docker-templates
https://github.com/danielfreitassc/java-docker-templates
dockerfile java
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielfreitassc/java-docker-templates
- Owner: DanielFreitassc
- License: mit
- Created: 2024-03-16T16:21:29.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-05T02:41:17.000Z (12 months ago)
- Last Synced: 2025-02-05T03:25:53.483Z (12 months ago)
- Topics: dockerfile, java
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dockerfile rodar aplicação backend springboot
# JDK 22
```dockerfile
# Use a base image that includes OpenJDK 22
FROM eclipse-temurin:22-jdk-alpine
# Install Maven
RUN apk add --no-cache maven
# Set the working directory
WORKDIR /app
# Copy the Maven project files
COPY . .
# Run Maven to build the project
RUN mvn clean install
EXPOSE 8080
RUN cp target/*.jar app.jar
ENTRYPOINT [ "java", "-jar", "app.jar" ]
```
# JDK 21
```dockerfile
# Etapa 1: Build com Maven
FROM maven:3.9.9-eclipse-temurin-21-alpine AS build
WORKDIR /app
COPY . .
RUN mvn clean package -DskipTests
# Etapa 2: Execução com OpenJDK 21
FROM azul/zulu-openjdk-alpine:21
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
```
# JDK 17
```dockerfile
FROM ubuntu:latest AS build
RUN apt-get update
RUN apt-get install openjdk-17-jdk -y
COPY . .
RUN apt-get install maven -y
RUN mvn clean install
FROM openjdk:17-jdk-slim
EXPOSE 8080
COPY --from=build /target/*.jar app.jar
ENTRYPOINT [ "java", "-jar", "app.jar" ]
```